Skip to content

Commit

Permalink
/etc/functions:mount_possible_boot_device; puch exclusion of mount at…
Browse files Browse the repository at this point in the history
…tempt on partitions <2Mb (4096 sectors)

Removes spurious errors thrown for exfat in dmesg. Something better to propose?

Signed-off-by: Thierry Laurion <[email protected]>
  • Loading branch information
tlaurion committed Sep 8, 2024
1 parent bdc3460 commit 0532b5c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions initrd/etc/functions
Original file line number Diff line number Diff line change
Expand Up @@ -697,8 +697,17 @@ mount_possible_boot_device() {
return 1
fi

TRACE "Try mounting $BOOT_DEV as /boot"
if mount -o ro "$BOOT_DEV" /boot >/dev/null 2>&1; then
# Get the size of BOOT_DEV in 512-byte sectors
sectors=$(blockdev --getsz "$BOOT_DEV")

# Check if the partition is small (less than 2MB, which is 4096 sectors)
if [ "$sectors" -lt 4096 ]; then
TRACE_FUNC
DEBUG "Partition $BOOT_DEV is very small, likely BIOS boot. Skipping mount."
return 1
TRACE_FUNC
DEBUG "Try mounting $BOOT_DEV as /boot"
elif mount -o ro "$BOOT_DEV" /boot >/dev/null 2>&1; then
if ls -d /boot/grub* >/dev/null 2>&1; then
# This device is a reasonable boot device
return 0
Expand Down

0 comments on commit 0532b5c

Please sign in to comment.