Set grub device in /etc/default/grub
Currently we run grub-mkconfig then go and edit the generated output in /boot/grub/grub.cfg to override the "root=" arguments to our label. If another element like project-config's finalise.d/99-fix-grub-timeout then goes and re-runs grub2-install, it overwrites these changes. Grub has GRUB_DEVICE which should override the root device. Let's try using this. Maybe it wasn't around at the time, this code is more-or-less unchanged from I7d83bb2b359e7a8c3858eca04c96e35cf4e1fe9e Change-Id: Ibaaa81124098f3c6febe48e455d3e1cd0a5f1761
This commit is contained in:
parent
50941b13bc
commit
6c8d7432a6
@ -133,6 +133,10 @@ function install_grub2 {
|
||||
GRUB_CFG=/boot/grub/grub.cfg
|
||||
fi
|
||||
|
||||
# Override the root device to the default label, and disable uuid
|
||||
# lookup.
|
||||
echo "GRUB_DEVICE=LABEL=${DIB_ROOT_LABEL}" >> /etc/default/grub
|
||||
echo 'GRUB_DISABLE_LINUX_UUID=true' >> /etc/default/grub
|
||||
echo "GRUB_TIMEOUT=${DIB_GRUB_TIMEOUT:-5}" >>/etc/default/grub
|
||||
echo 'GRUB_TERMINAL="serial console"' >>/etc/default/grub
|
||||
echo 'GRUB_GFXPAYLOAD_LINUX=text' >>/etc/default/grub
|
||||
@ -181,17 +185,7 @@ function install_grub2 {
|
||||
sed -i "s%search --no.*%%" $GRUB_CFG
|
||||
sed -i "s%set root=.*%set root=(hd0,1)%" $GRUB_CFG
|
||||
fi
|
||||
# force use of a LABEL:
|
||||
# NOTE: Updating the grub config by hand once deployed should work, its just
|
||||
# prepping it in a different environment that needs fiddling.
|
||||
sed -i "s%$PART_DEV%LABEL=${DIB_ROOT_LABEL}%" $GRUB_CFG
|
||||
sed -i "s%search --no-floppy --fs-uuid --set=root .*$%search --no-floppy --set=root --label ${DIB_ROOT_LABEL}%" $GRUB_CFG
|
||||
sed -i "s%root=UUID=[A-Za-z0-9\-]*%root=LABEL=${DIB_ROOT_LABEL}%" $GRUB_CFG
|
||||
if [ "$DISTRO_NAME" = 'fedora' ] ; then
|
||||
if [ "$DIB_RELEASE" = '19' ]; then
|
||||
sed -i "s%UUID=[A-Za-z0-9\-]*%LABEL=${DIB_ROOT_LABEL}%" /etc/fstab
|
||||
fi
|
||||
fi
|
||||
|
||||
# Fix efi specific instructions in grub config file
|
||||
if [ -d /sys/firmware/efi ]; then
|
||||
sed -i 's%\(initrd\|linux\)efi /boot%\1 /boot%g' $GRUB_CFG
|
||||
|
Loading…
Reference in New Issue
Block a user