Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Weird busybox behaviour in initramfs on new machine
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
Goverp
l33t
l33t


Joined: 07 Mar 2007
Posts: 804

PostPosted: Thu Jan 30, 2020 5:43 pm    Post subject: Weird busybox behaviour in initramfs on new machine Reply with quote

I've just moved my Gentoo installation to a new toy (Ryzen 3900X) on a 500GB M2 NVMe SSD. Quite a bit faster, but it took a day to make it work fully. It must be worth documenting in case someone else hits the same problems.

The filesystems had changed: the old box used ext4 everywhere, and had a RAID 5 setup in an initramfs busybox script. The new box has the SSD setup per the Handbook defaults, with p2=VFAT for EFI, p3=F2FS for everything else (I'll move the RAID 5 /home separately later.)

One problem was partly my own making: I use disk labels (LABEL=boot etc) in /etc/fstab, and put a dos name on the VFAT partition with "mkfs.vfat -n boot foo bah ...". It turns out that mount and findfs can't see that name, so the initial "mount -a" died a painful death - mea culpa - which killed the "boot" level in openrc, with no visible message. As I'd given the partitions identical GPT names, changing to "PARTLABEL=boot" solved that.

Another was some nasty interaction between f2fs and baselayout's assumptions - the initramfs mounted the ext4 setup "ro", and openrc did its fsck and remount rw without problem. But for some reason on the new box, the f2fs partition resolutely stayed "ro" - cure was to remove that from the mount in the initramfs script.

The third problem was weird. I'd be interested if anyone can explain. My busybox script is based on the one in the wiki, and is pretty simple. It ends:
Code:
info "Mounting rootfs $rootfs read-only"
mount -o ro $rootfs /mnt/root || rescue_shell "Error mounting rootfs"

info "Switch root to: $rootfs $initscript $level"

# Leave unmounting as late as possible to let printk work
umount /proc /sys /dev
exec switch_root /mnt/root $initscript $level

("info" is a funtion to write messages to syslog). It's worked OK for several years through many kernel and busybox rebuilds. But on the new machine, after some painful debugging, I found that switch_root left /proc, /sys and /dev unmounted. Removing the unmount had no effect. Eventually I cured the problem by explicitly mountng /mnt/root/{proc,sys,dev} before switching.
_________________
Greybeard


Last edited by Goverp on Fri Jan 31, 2020 12:18 pm; edited 1 time in total
Back to top
View user's profile Send private message
Goverp
l33t
l33t


Joined: 07 Mar 2007
Posts: 804

PostPosted: Fri Jan 31, 2020 12:18 pm    Post subject: Reply with quote

OK, weirder still. Having read the code in busybox's switch_root, it's clear it never moves /proc, /sys or /dev. (Whereas the copy in sys-apps/util-linux does move them to the new root.)
That explains the behaviour I see on the new box. But how in tarnation did it ever work on the old box? Without /proc et al, on the new box /sbin/init dies without issue, as it can't find a console to explain what's going wrong. (I found this out by changing the chosen init from /sbin/init to /bin/bash and looking around.)
Anyway, I see there's a subsequent section on the wiki saying you might need to move the directories.

<edit>Note that the wiki article uses util-linux's mount syntax, which is wrong for busybox - that needs "mount -o move", not "mount -move"</edit>
_________________
Greybeard
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum