2

I followed the steps here and compiled the kernel successfully in usermode: https://btrfs.wiki.kernel.org/index.php/Debugging_Btrfs_with_GDB

But when I start ./linux in various ways it always gives me a very similar error:

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)

I have now tried everything I could think of to satisfy the ./linux root= option but nothing seems to work.

  1. I created a root filesystem with https://buildroot.org/, passed that as .gz, .tar, .tar.gz, uncompressed folder
  2. I put the contents of the buildroot.org into the btrfs loop device, then right clicked in the disks utility and created an .img file. Tried starting with that.
  3. Of course I tried all the usual options I could think of, like ./linux root=/mnt, ./linux root=/dev/loop0

I don't know what else to try. Why is this not working? I tried finding out what the -6 error code means, but it seems all the Linux kernel error codes are positive numbers. https://gist.github.com/nullunar/4553641

I really don't know what else to do, I guess I could start reading up for hours and hours about what exactly the udb stuff means, but I was really hoping somebody could just tell me what I need to pass to the command line as my interest right now is only in debugging btrfs, not Linux in general.

Jeff Schaller
  • 66,199
  • 35
  • 114
  • 250
Blub
  • 165
  • 1
  • 6

2 Answers2

5

From 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
The ubda parameter in this command is giving the UML kernel the name of a file to use to create the virtual machine's /dev/ubda virtual block device, which will be its root filesystem.
JigglyNaga
  • 7,706
  • 1
  • 21
  • 47
  • Thank you, I actually get the feeling that I found that article before but it looked too much like blog spam for me to actually read enough. It's a very good article. – Blub Mar 31 '17 at 15:52
  • The reason why my filesystem created from buildroot.org probably didn't work, was because the format was wrong. It has to be in 'rawdisk' format, which seems to be a file created by dd and then populated with the necessary content and partitions and partition tables via extra tools. – Blub Mar 31 '17 at 15:56
  • What would be nice to know though, is why the root filesystem is read-only. – Blub Mar 31 '17 at 15:58
0

I have described a working Buildroot setup in great detail at: How to create rootfs for user mode Linux on Fedora 18?

The main catch is that I had to hack up the BusyBox init to add ::sysinit:/sbin/mdev -s to the inittab.