Skip to content

Commit faa77d4

Browse files
committed
/etc/functions:mount_possible_boot_device; punch exclusion of mount attempt on partitions <2Mb (4096 sectors)
Removes spurious errors thrown for exfat in dmesg in that function. Something better to propose? Signed-off-by: Thierry Laurion <insurgo@riseup.net>
1 parent 3574e12 commit faa77d4

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

initrd/etc/functions

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -697,13 +697,24 @@ mount_possible_boot_device() {
697697
return 1
698698
fi
699699

700-
TRACE "Try mounting $BOOT_DEV as /boot"
701-
if mount -o ro "$BOOT_DEV" /boot >/dev/null 2>&1; then
702-
if ls -d /boot/grub* >/dev/null 2>&1; then
703-
# This device is a reasonable boot device
704-
return 0
705-
fi
700+
# Get the size of BOOT_DEV in 512-byte sectors
701+
sectors=$(blockdev --getsz "$BOOT_DEV")
702+
703+
# Check if the partition is small (less than 2MB, which is 4096 sectors)
704+
if [ "$sectors" -lt 4096 ]; then
705+
TRACE_FUNC
706+
DEBUG "Partition $BOOT_DEV is very small, likely BIOS boot. Skipping mount."
707+
return 1
708+
else
709+
TRACE_FUNC
710+
DEBUG "Try mounting $BOOT_DEV as /boot"
711+
if mount -o ro "$BOOT_DEV" /boot >/dev/null 2>&1; then
712+
if ls -d /boot/grub* >/dev/null 2>&1; then
713+
# This device is a reasonable boot device
714+
return 0
715+
fi
706716
umount /boot || true
717+
fi
707718
fi
708719

709720
return 1

0 commit comments

Comments
 (0)