Solution that works for me:
- Compile the kernel with everything built-in leaving modules for the
few things that really need to be reloadable. Turn everything in
the bloody thing off. This avoids the need for a kernel-specific
filestem in the initrd.
- This since you don't need any modules in the initrd a
simple, static solution with busybox and init something
like:
#!/bin/busybox sh
/bin/busybox --install -s;
sync;
mount -t proc none /proc;
mount -t sysfs none /sys;
/sbin/mdadm --verbose --assemble --scan;
/sbin/vgscan --verbose;
/sbin/vgchange --verbose -a y /dev/vg00/root;
mount /dev/vg00/root /mnt/root;
mount;
exec /sbin/switch_root /mnt/root /sbin/init;
Add whatever you need for encryped filesytems, but it
won't have to change over time unless you change the
boot requirements.
Add a copy of busybox, switch_root, init, a static copy of lvm
into something like /boot/standard-init.cpio.gz. Mine is in
/usr/src/initrd with two sub's "standard" and "rescue" differing
only in the init script. A second initrd the last line commented
out as /boot/rescue-init.cpio.gz for cases where switch_root gets
unhappy.
#!/bin/bash --login
cd $(dirname $0);
for i in */init;
do
dir=$(dirname $i);
name=$(basename $dir);
(
cd $dir;
kleenfilz;
find . |
cpio -o -Hnewc |
gzip -9v > /boot/$name.cpio.gz) &
done
wait;
ls -lt /boot;
exit 0;
builds and installs the initrd's easily enough ("kleenfilz"
is a shell sub that removes editor cruft, no reason to leave
*~ files :-).
- Add /etc/grub.d/09_custom (i.e., into the config *before* the
junk that 10 adds in) like the one below. Note that this uses
the symlink /boot/vmlinuz with the static init. The "current"
portion comes from a second "vmlinuz.stable" symlink I curate
manually to the last kernel that lived for a while and never,
ever caused problems [not that I've ever botched a config
siwtch. no, really...].
The standard link and fixed init-script allow a static copy of the
grub config file with "/boot/vmlinuz" and "/boot/standard.cpio.gz"
hardwired.
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
menuentry 'current standard' --class gentoo --class gnu-linux --class gnu
--class os $menuentry_id_option
'gnulinux-simple-e18157fe-1330-4cbb-8374-125d9c26e360' {
load_video
if [ "x$grub_platform" = xefi ]; then
set gfxpayload=keep
fi
insmod gzio
insmod part_msdos
insmod xfs
set root='hd0,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1
--hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1
e18157fe-1330-4cbb-8374-125d9c26e360
else
search --no-floppy --fs-uuid --set=root
e18157fe-1330-4cbb-8374-125d9c26e360
fi
echo 'Loading Linux ...'
linux /boot/vmlinuz root=/dev/sdc1 ro
echo 'Loading initrd ...'
initrd /boot/standard.cpio.gz
}
menuentry 'current rescue' --class gentoo --class gnu-linux --class gnu --class
os $menuentry_id_option 'gnulinux-simple-e18157fe-1330-4cbb-8374-125d9c26e360' {
load_video
if [ "x$grub_platform" = xefi ]; then
set gfxpayload=keep
fi
insmod gzio
insmod part_msdos
insmod xfs
set root='hd0,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1
--hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1
e18157fe-1330-4cbb-8374-125d9c26e360
else
search --no-floppy --fs-uuid --set=root
e18157fe-1330-4cbb-8374-125d9c26e360
fi
echo 'Loading Linux ...'
linux /boot/vmlinuz root=/dev/sdc1 ro
echo 'Loading initrd ...'
initrd /boot/rescue.cpio.gz
}
- Run grub2-mkconfig once.
- Never touch the grub.cfg file ever again (unless you switch the
boot filesystem type). If I went from XFS -> btrfs for the root
filesystem I'd have to hack the "insmod xfs" entries, nothing
more.
--
Steven Lembark 3646 Flora Pl
Workhorse Computing St Louis, MO 63110
[email protected] +1 888 359 3508