This is not the more polite solution to this problem, but it works and mybe should be helpfull to some other so I brifly describe here how I solved my problem to have a DOM capable to change it boot device automatically.
Inside the linuxrc, the script of initrd, I detect wich device is available and based on that result I set the default startup option used by grub
my linuxrx i something like this
#!/bin/ash
restart=0
mntdev=""
target="hda"
echo "--> check fdisk ${target} "
mount -t ext2 /dev/${target}1 /mnt/tmp
if [ -f /mnt/tmp/etc/slackware-release ]; then
echo "Found $target "
mntdev="/dev/${target}1"
olddef=$( cat /mnt/tmp/boot/grub/default )
if [ $olddef -ne 0 ]; then
echo "0" > /mnt/tmp/boot/grub/default
restart=1
fi
fi
umount /mnt/tmp
# ================================
if [ -z $dskroot ]; then
target="hdc"
echo "--> check fdisk ${target} "
mount -t ext2 /dev/${target}1 /mnt/tmp
if [ -f /mnt/tmp/etc/slackware-release ]; then
echo "Found $target "
mntdev="/dev/${target}1"
olddef=$( cat /mnt/tmp/boot/grub/default )
if [ $olddef -ne 1 ]; then
echo "1" > /mnt/tmp/boot/grub/default
restart=1
fi
fi
umount /mnt/tmp
fi
# ================================
if [ $restart -eq 1 ]; then
echo "Changed grub default : Rebooting PC "
echo "===================================="
sleep 2
mount -t ext2 $mntdev /mnt/tmp
chroot /mnt/tmp <<EOF
/sbin/reboot -f
EOF
fi
And inside the grub menu I reserver the first two entry , the 0 for device hda and 1 for device hdc
default saved
title Linux-2.4.37.9_CCL_20130122 with INITRD hda pos 0
root (hd0,0)
kernel /boot/vmlinuz-2.4.37.9_CCL_20130122 ro root=/dev/hda1 console=ttyS0,9600 console=tty0 apm=off
initrd /boot/initrd-CCL.img.gz
title Linux-2.4.37.9_CCL_20130122 with INITRD hdc pos 1
root (hd0,0)
kernel /boot/vmlinuz-2.4.37.9_CCL_20130122 ro root=/dev/hdc1 console=ttyS0,9600 console=tty0 apm=off
initrd /boot/initrd-CCL.img.gz
menu.lst
are provided to the kernel. If you want to do something dynamic you should just do it in yourinitramfs
and mount the root device accordingly. The kernel or init don't really care about the root parameter as long as yourinitramfs
takes care of everything.