2

My machine is running inside a KVM virtual machine (Parallels Desktop v8), having a BIOS (not UEFI), having one SATA drive connected, one GPT partition on that disk, the partition is ext4 formatted, the bootloader is extlinux v. 4.05, and the kernel is Ubuntu 13.10 package linux-image-3.11.0-18-generic.

The system boots to (initramfs) prompt when only initrd and no boot argument is specified:

(initramfs) cat /proc/cmdline
initrd=/boot/initrd.img-3.11.0-18-generic ro quiet BOOT_IMAGE=/boot/vmlinuz-3.11.0-18-generic

Only after inserting boot=/dev/sda1 the system boots to bash prompt, as pointed out in the answer of question How to fix boot into initramfs prompt and "mount: can't read '/etc/fstab': No such file or directory" and "No init found"?

I have read that the kernel is usually able to find its boot partition without additional configuration.

Environment:

$ sudo efibootmgr
Fatal: Couldn't open either sysfs or procfs directories for accessing EFI variables.
$ sudo modprobe efivars
(no result)

Faulty (initramfs) prompt:

mount: can't read '/etc/fstab': No such file or directory
mount: mounting /dev on /root/dev failed: No such file or directory
mount: mounting /sys on /root/sys failed: No such file or directory
mount: mounting /proc on /root/proc failed: No such file or directory
The filesystem doesn't have requested /sbin/init.
No init found. Try passing init= bootarg.

(initramfs) cd /root || mkdir /root
(initramfs)

Update #1 - (initramfs) echo $(pwd) output

(initramfs) cd /root && echo $(pwd) || mkdir /root?
/root
(initramfs)

Update #2 - (initramfs) ls /dev output

(initramfs) ls /dev
vga_arbiter rfkill mem null port zero full random urandom kmsg tty console
tty0-tty63 vcs vcsa vcs1 vcsa1 snapshot ecryptfs fuse ptmx ttyS0-ttyS31
ttyprintk hpet ram0-ram15 loop-control loop0-loop7 net ppp bus input psaux
uinput rtc0 mapper mcelog cpu_dma_latency network_latency network_throughput
pts core fd stdin stdout stderr btrfs-control char rtc sg0 bsg sda sda1

Update #3 - (initramfs) ls / && ls /*/ output

(initramfs) ls /
dev root conf bin etc sbin run init lib64 scripts lib sys proc tmp var
(initramfs) ls /*/
/var/:
lock

/tmp/:

/sys/:
hypervisor kernel power block dev fs module firmware class devices bus

/scripts/:
panic init-bottom local-premount nfs functions local init-top

/sbin/:
blkid wait-for-root rmmod hwclock udevadm dumpe2fs modprobe

/run/:

/root/:

/proc/:
1-130 142-148 167-169 219-231 233 243-245 248 self ounts net sysvipc fs
driver tty bus sys cgroups irq mtrr fb acpi misc scsi mdstat execdomains
ioports imem schedstat sched_debug timer_list timer_stats dma modules
kallsyms latency_stats buddyinfo pagetypeinfo vmstat zoneinfo slabinfo
vmallocinfo swaps filesystems locks cmdline consoles cpuinfo devices 
interrupts loadavg meminfo stat uptime version softirqs kcore kmsg 
kpagecount kpageflags version_signature key-users crypto diskstats
partitions sysrq-trigger

/lib64/:
ld-linux-x86-64.so.2

/lib/:
udev klibc-dev6iJxsMLkI8yu6xMVSFDIuVsJk.so x86_64-linux-gnu modules firmware systemd

/etc/:
modprobe.d ld.so.conf.d udev ld.so.conf ls.so.cache mtab

/dev/:
...see above...

/conf/:
initramfs.conf arch.conf conf.d

/bin/:
kmod udevadm dmesg busybox poweroff fstype losetup ipconfig reboot halt sh
run-init pivot-root date dd insmod nfsmount sleep mount cpio resume

Update #4 - ls /scripts/* /conf/* /sys/firmware/*/ output

(initramfs) ls /scripts/* /conf/* /sys/firmware/*/
/scripts/functions /scripts/local /scripts/nfs /conf/initramfs.conf /conf/arch.conf  

/sys/firmware/memmap/:
9 8 7 6 5 4 3 2 1 0

/sys/firmware/acpi/:
hotplug tables pm_profiles interrupts

/conf/conf.d:

/scripts/panic:
ORDER keymap

/scripts/local-premount:
ORDER fixrtc resume

/scripts/init-top:
ORDER all_generic_ide blacklist udev

/scripts/init-bottom:
ORDER udev

Why isn't the kernel not able to find the boot partition in this case?

Pro Backup
  • 4,686
  • 12
  • 50
  • 82
  • What happens if you do cd /root && echo $(pwd) || mkdir /root? – mikeserv Mar 23 '14 at 11:13
  • @mikeserv `/root` is the output from `/root && echo $(pwd) || mkdir /root` on the `(initramfs)` prompt inside KVM. – Pro Backup Mar 23 '14 at 12:26
  • Ok, so that directory is there - but *`ls /dev`* returns empty? And you say *`kvm`* - do you mean *`qemu`?* how do you invoke the vm? Nevermind you say it - Paralells. Thats outside my experience. I know how to run EFI vms in qemu, but never that. – mikeserv Mar 23 '14 at 12:27
  • @mikeserv `ls /dev` is not empty, see update #2 in the edited question – Pro Backup Mar 23 '14 at 12:38
  • Ok... Then mount /dev/sd?? to /root should get you going, but the other answer to your other already established that. Common case is that *`init`* expects a *`root=`* kernel cmdline parameter OR /etc/fstab. You CAN include an fstab in your initramfs image and forego the root= parameter probably - but that depends on your init. Get an ls / and ls /*/ if you would. – mikeserv Mar 23 '14 at 12:45
  • @mikeserv `ls / && ls /*/` output is inserted in the question as update #3. – Pro Backup Mar 23 '14 at 13:13
  • You want to know *`cat /scripts/* /conf/*`* for certain. Possibly run-init is also a script, or it is only a Busybox link. Regarding efi - you also want to know ls /sys/firmware/*/ - starting to see what i mean about it just being a regular linux root doing regular linux root stuff? But probably you dont need to post all of that text up there - if you cant see right away what to look for post a link to a text file – mikeserv Mar 23 '14 at 13:23
  • Oh, and by the way, you dont really have to do this in initramfs busybox. I dont see a .gz or whatever tacked on to your img file name, but im willing to bet its compressed with something. If can figure out what then you just have to unpack the resulting cpio archive into whatever directory you like and inspect it at your leisure - getting /dev and /sys were all you needed a live system for. – mikeserv Mar 23 '14 at 14:01
  • Not ls /scripts. The files in there will be the shell functions busybox uses to manage your early userspace. Theyre just shell scripts. You want to read those scripts to figure out what its doing. And same goes for /conf - thosell be some configuration files that will set environment for /scripts. Thats why i suggested you *`cat`* them. – mikeserv Mar 23 '14 at 14:41
  • @mikeserv I am starting to get the picture. How does `init` start? In other words which script gets executed first? Or where does the output `Running /scripts/init-premount` come from? `Grep`ping the output from `cat /scripts/* /conf/*` doesn't match with `cat ... | grep -i /init-premount` or `cat ... | grep "Mounting root file system`. – Pro Backup Mar 23 '14 at 15:18
  • Its the default name of process id 1 - you can configure a different one when you compile your kernel or you can use the kernel cmdline parameter *`init=/path/to/different/init`*. Like i said in the other post - busybox is the real init - it completely owns userspace. One of those script files will instruct it to exec itself into another program once your root disk is mounted during the call to switchroot. Switchroot by the way, is cool - the kernel performs the mount and exec calls simultaneously. – mikeserv Mar 23 '14 at 15:23
  • Possibly your distro configures a cmdline in the kernel compilation - silly, but possible. More probably your init contains the argument you want in the link it makes to busybox. It is compiled in, you can probably get it with cat /sys/config – mikeserv Mar 23 '14 at 15:26
  • So usually - mount $root /$roottgt ; mount /$kernelpseudofs /$roottgt/$kernelpseudofs ; switchroot – mikeserv Mar 23 '14 at 15:33
  • Oh, well, there's init itself as well - its probably a script, too? Can you cat it? – mikeserv Mar 23 '14 at 15:40
  • 1
    “I have read that the kernel is usually able to find its boot partition”. Did you mean the *root* partition, i.e. the partition that is mounted on `/`? Where did you read this? The kernel normally knows because it's passed as the `boot` parameter on the command line. – Gilles 'SO- stop being evil' Mar 23 '14 at 22:39
  • @Gilles It took some time to find back where I read that initramfs might automatically find the root file system. At was in Patrick's answer for question http://unix.stackexchange.com/questions/92720/does-initramfs-use-etc-fstab stating: "*However it* (initramfs) *might also do something to automatically figure out where your root device is, and so there's no parameter* (root=) *at all.*" – Pro Backup Apr 06 '14 at 18:37
  • @ProBackup So the kernel is *not* finding the root partition then. You can put logic to find it in the initramfs (you can put whatever you like in there), but the way it's typically set up, the initramfs arranges to make the device specified by the `root` parameter available and mount it. – Gilles 'SO- stop being evil' Apr 06 '14 at 18:44

0 Answers0