Linux-Kernel
如何執行使用者態 linux 核心?
我按照這裡的步驟在使用者模式下成功編譯了核心: https ://btrfs.wiki.kernel.org/index.php/Debugging_Btrfs_with_GDB
但是當我
./linux
以各種方式開始時,它總是給我一個非常相似的錯誤:pc@linux-94q0:~/linux-4.11-rc4> ./linux root=/mnt Core dump limits : soft - 0 hard - NONE Checking that ptrace can change system call numbers...OK Checking syscall emulation patch for ptrace...OK Checking advanced syscall emulation patch for ptrace...OK Checking environment variables for a tempdir...none found Checking if /dev/shm is on tmpfs...OK Checking PROT_EXEC mmap in /dev/shm...OK Adding 33251328 bytes to physical memory to account for exec-shield gap Linux version 4.11.0-rc4 (pc@linux-94q0) (gcc version 4.8.5 (SUSE Linux) ) #1 Fri Mar 31 12:40:07 CEST 2017 Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16087 Kernel command line: root=/mnt PID hash table entries: 256 (order: -1, 2048 bytes) Dentry cache hash table entries: 8192 (order: 4, 65536 bytes) Inode-cache hash table entries: 4096 (order: 3, 32768 bytes) Memory: 26140K/65240K available (3518K kernel code, 770K rwdata, 948K rodata, 114K init, 195K bss, 39100K reserved, 0K cma-reserved) NR_IRQS:15 clocksource: timer: mask: 0xffffffffffffffff max_cycles: 0x1cd42e205, max_idle_ns: 881590404426 ns Calibrating delay loop... 6966.47 BogoMIPS (lpj=34832384) pid_max: default: 32768 minimum: 301 Mount-cache hash table entries: 512 (order: 0, 4096 bytes) Mountpoint-cache hash table entries: 512 (order: 0, 4096 bytes) Checking that host ptys support output SIGIO...Yes Checking that host ptys support SIGIO on close...No, enabling workaround devtmpfs: initialized Using 2.6 host AIO clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns futex hash table entries: 256 (order: 0, 6144 bytes) xor: measuring software checksum speed 8regs : 19749.600 MB/sec 8regs_prefetch: 17312.000 MB/sec 32regs : 18694.400 MB/sec 32regs_prefetch: 17317.600 MB/sec xor: using function: 8regs (19749.600 MB/sec) NET: Registered protocol family 16 raid6: int64x1 gen() 4139 MB/s raid6: int64x1 xor() 2318 MB/s raid6: int64x2 gen() 3758 MB/s raid6: int64x2 xor() 2685 MB/s raid6: int64x4 gen() 3413 MB/s raid6: int64x4 xor() 2153 MB/s raid6: int64x8 gen() 2865 MB/s raid6: int64x8 xor() 1626 MB/s raid6: using algorithm int64x1 gen() 4139 MB/s raid6: .... xor() 2318 MB/s, rmw enabled raid6: using intx1 recovery algorithm clocksource: Switched to clocksource timer VFS: Disk quotas dquot_6.6.0 VFS: Dquot-cache hash table entries: 512 (order 0, 4096 bytes) NET: Registered protocol family 2 TCP established hash table entries: 512 (order: 0, 4096 bytes) TCP bind hash table entries: 512 (order: 0, 4096 bytes) TCP: Hash tables configured (established 512 bind 512) UDP hash table entries: 256 (order: 1, 8192 bytes) UDP-Lite hash table entries: 256 (order: 1, 8192 bytes) NET: Registered protocol family 1 console [stderr0] disabled mconsole (version 2) initialized on /home/pc/.uml/y33GMV/mconsole Checking host MADV_REMOVE support...OK workingset: timestamp_bits=62 max_order=13 bucket_order=0 io scheduler noop registered io scheduler deadline registered (default) io scheduler mq-deadline registered NET: Registered protocol family 17 Initialized stdio console driver Console initialized on /dev/tty0 console [tty0] enabled Initializing software serial port version 1 console [mc-1] enabled Failed to initialize ubd device 0 :Couldn't determine size of device's file Btrfs loaded, crc32c=crc32c-generic, debug=on VFS: Cannot open root device "/mnt" or unknown-block(0,0): error -6 Please append a correct "root=" boot option; here are the available partitions: Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0) CPU: 0 PID: 1 Comm: swapper Not tainted 4.11.0-rc4 #1 Stack: 6381bd80 60066344 602a250a 62cab500 602a250a 600933ba 6381bd90 60297e6f 6381beb0 60092b41 6381be30 60380ea1 Call Trace: [<600933ba>] ? printk+0x0/0x94 [<6001c4d8>] show_stack+0xfe/0x158 [<60066344>] ? dump_stack_print_info+0xe1/0xea [<602a250a>] ? bust_spinlocks+0x0/0x4f [<602a250a>] ? bust_spinlocks+0x0/0x4f [<600933ba>] ? printk+0x0/0x94 [<60297e6f>] dump_stack+0x2a/0x2c [<60092b41>] panic+0x173/0x322 [<60380ea1>] ? klist_next+0x0/0xa6 [<600929ce>] ? panic+0x0/0x322 [<600cac33>] ? kfree+0x0/0x8a [<600f01da>] ? SyS_mount+0xae/0xc0 [<600933ba>] ? printk+0x0/0x94 [<600f012c>] ? SyS_mount+0x0/0xc0 [<60002378>] mount_block_root+0x356/0x374 [<6029e3f9>] ? strcpy+0x0/0x18 [<60002432>] mount_root+0x9c/0xa0 [<6029e543>] ? strncmp+0x0/0x25 [<60002614>] prepare_namespace+0x1de/0x238 [<600eb9d3>] ? SyS_dup+0x0/0x5e [<60001ee1>] kernel_init_freeable+0x300/0x31b [<600933ba>] ? printk+0x0/0x94 [<603835e9>] kernel_init+0x1c/0x14a [<6001b140>] new_thread_handler+0x81/0xa3 Aborted (core dumped)
我現在已經嘗試了我能想到的一切來滿足這個
./linux root=
選項,但似乎沒有任何效果。
- 我使用https://buildroot.org/創建了一個根文件系統,將其傳遞為 .gz、.tar、.tar.gz、未壓縮文件夾
- 我將 buildroot.org 的內容放入 btrfs 循環設備,然後右鍵點擊磁碟實用程序並創建一個 .img 文件。試著從那開始。
- 當然,我嘗試了所有我能想到的常用選項,例如
./linux root=/mnt
,./linux root=/dev/loop0
我不知道還能嘗試什麼。為什麼這不起作用?我試圖找出 -6 錯誤程式碼的含義,但似乎所有 Linux 核心錯誤程式碼都是正數。 https://gist.github.com/nullunar/4553641
我真的不知道還能做什麼,我想我可以開始閱讀幾個小時來了解 udb 的確切含義,但我真的希望有人能告訴我我需要傳遞給命令行的內容我現在的興趣只是調試 btrfs,而不是一般的 Linux。
來自https://www.linux.com/news/how-run-linux-inside-linux-user-mode-linux:
./linux-2.6.19-rc5 ubda=FedoraCore5-x86-root_fs mem=128M
此命令中的 ubda 參數為 UML 核心提供了一個文件名,該文件用於創建虛擬機的 /dev/ubda 虛擬塊設備,這將是它的根文件系統。
我已經詳細描述了一個有效的 Buildroot 設置:如何在 Fedora 18 上為使用者模式 Linux 創建 rootfs?
主要問題是我必須破解 BusyBox
init
才能添加::sysinit:/sbin/mdev -s to the inittab
.