Skip to content

Commit

Permalink
v7.5
Browse files Browse the repository at this point in the history
+ DietPi-FirstBoot | On x86_64 BIOS systems, set the GRUB install device to the obtained root drive. Naturally, we cannot know on image create, what the install drives path/name is, or what type it is and UUIDs do not exist for the raw drives, where the bootloader needs to be written to. With a wrong drive in debconf, on a GRUB upgrade or install, the system can become unbootable. GRUB (or the Debian GRUB maintainers) implemented some additional checks to prevent such cases, due to many bug tracker reports, but the issue is generally not ruled out 100% and it requires a manual selection of the bootloader drive on package upgrade, when the stored one does not exist, else the upgrade fails. For our x86_64 images we know that those are full drive images with "our" bootloader stored on the same drive where the DietPi root partition is found, so we can automatically detect and apply it. Even if it is a customised image, this step cannot make things worse compared to the hardcoded "/dev/sda", which is a pure guess that most x86_64 systems will run on the first SATA drive attached to the system.
  • Loading branch information
MichaIng committed Aug 19, 2021
1 parent dc7d8ee commit d430094
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions rootfs/var/lib/dietpi/services/dietpi-firstboot.bash
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,13 @@ _EOF_
# shellcheck disable=SC2015
(( $wifi_enabled )) && ifup wlan$index_wlan || ifup eth$index_eth

# x86_64 BIOS: Set GRUB install device: https://github.com/MichaIng/DietPi/issues/4542
if (( $G_HW_MODEL == 10 )) && dpkg-query -s grub-pc &> /dev/null
then
local root_drive=$(lsblk -npo PKNAME "$(findmnt -Ufnro SOURCE -M /)")
[[ $root_drive == '/dev/'* ]] && debconf-set-selections <<< "grub-pc grub-pc/install_devices multiselect $root_drive"
fi

}

#/////////////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit d430094

Please sign in to comment.