From c00c380d7aecda864f89cf322a0f9fb55d37b1d1 Mon Sep 17 00:00:00 2001 From: Pavel Cahyna Date: Sat, 20 Jul 2024 19:43:13 +0200 Subject: [PATCH] Remove FAT16 options to avoid kernel warning Upstream PR #2576 Resolves: RHEL-44900 --- rear-no-fat-16.patch | 84 ++++++++++++++++++++++++++++++++++++++++++++ rear.spec | 4 +++ 2 files changed, 88 insertions(+) create mode 100644 rear-no-fat-16.patch diff --git a/rear-no-fat-16.patch b/rear-no-fat-16.patch new file mode 100644 index 0000000..f41bcb5 --- /dev/null +++ b/rear-no-fat-16.patch @@ -0,0 +1,84 @@ +diff --git a/usr/share/rear/format/USB/default/300_format_usb_disk.sh b/usr/share/rear/format/USB/default/300_format_usb_disk.sh +index 0e0a2e080..fa6496b23 100644 +--- a/usr/share/rear/format/USB/default/300_format_usb_disk.sh ++++ b/usr/share/rear/format/USB/default/300_format_usb_disk.sh +@@ -94,7 +94,13 @@ sleep 5 + + if is_true "$EFI" ; then + LogPrint "Creating vfat filesystem on EFI system partition on '${RAW_USB_DEVICE}1'" +- if ! mkfs.vfat $v -F 16 -n REAR-EFI ${RAW_USB_DEVICE}1 >&2 ; then ++ # Make a FAT filesystem on the EFI system partition ++ # cf. https://github.com/rear/rear/issues/2575 ++ # and output/ISO/Linux-i386/700_create_efibootimg.sh ++ # and output/RAWDISK/Linux-i386/280_create_bootable_disk_image.sh ++ # Let mkfs.vfat automatically select the FAT type based on the size. ++ # I.e. do not use a '-F 16' or '-F 32' option and hope for the best: ++ if ! mkfs.vfat $v -n REAR-EFI ${RAW_USB_DEVICE}1 >&2 ; then + Error "Failed to create vfat filesystem on '${RAW_USB_DEVICE}1'" + fi + # create link for EFI partition in /dev/disk/by-label +diff --git a/usr/share/rear/output/ISO/Linux-i386/700_create_efibootimg.sh b/usr/share/rear/output/ISO/Linux-i386/700_create_efibootimg.sh +index 0eb5350f8..39bbebad8 100644 +--- a/usr/share/rear/output/ISO/Linux-i386/700_create_efibootimg.sh ++++ b/usr/share/rear/output/ISO/Linux-i386/700_create_efibootimg.sh +@@ -13,13 +13,33 @@ StopIfError "Failed to determine disk usage of EFI virtual image content directo + + # prepare EFI virtual image aligned to 32MiB blocks: + dd if=/dev/zero of=$TMP_DIR/efiboot.img count=$efi_img_sz bs=32M +-mkfs.vfat $v -F 16 $TMP_DIR/efiboot.img >&2 +-mkdir -p $v $TMP_DIR/efi_virt >&2 +-mount $v -o loop -t vfat -o fat=16 $TMP_DIR/efiboot.img $TMP_DIR/efi_virt >&2 + +-# copy files from staging directory ++# Make a FAT filesystem on the efiboot.img file and loop mount it ++# cf. https://github.com/rear/rear/issues/2575 ++# See output/RAWDISK/Linux-i386/280_create_bootable_disk_image.sh ++# Having a small EFI System Partition (ESP) might introduce problems: ++# - The UEFI spec seems to require a FAT32 EFI System Partition (ESP). ++# - syslinux/Legacy BIOS fails to install on small FAT32 partitions with "syslinux: zero FAT sectors (FAT12/16)". ++# - Some firmwares fail to boot from small FAT32 partitions. ++# - Some firmwares fail to boot from FAT16 partitions. ++# See: ++# - http://www.rodsbooks.com/efi-bootloaders/principles.html ++# - http://lists.openembedded.org/pipermail/openembedded-core/2012-January/055999.html ++# Let mkfs.vfat automatically select the FAT type based on the size. ++# See what "man mkfs.vfat" reads for the '-F' option: ++# "If nothing is specified, mkfs.fat will automatically select ++# between 12, 16 and 32 bit, whatever fits better for the filesystem size" ++# I.e. do not use a '-F 16' or '-F 32' option and hope for the best: ++mkfs.vfat $v $TMP_DIR/efiboot.img ++mkdir -p $v $TMP_DIR/efi_virt ++# Do not specify '-o fat=16' or '-o fat=32' when loop mounting the efiboot.img FAT file ++# but rely on the automatic FAT type detection (see what "man 8 mount" reads for 'fat=...'): ++mount $v -o loop -t vfat $TMP_DIR/efiboot.img $TMP_DIR/efi_virt || Error "Failed to loop mount efiboot.img" ++ ++# Copy files from staging directory into efiboot.img + cp $v -r $TMP_DIR/mnt/. $TMP_DIR/efi_virt + +-umount $v $TMP_DIR/efiboot.img >&2 +-mv $v -f $TMP_DIR/efiboot.img $TMP_DIR/isofs/boot/efiboot.img >&2 +-StopIfError "Could not move efiboot.img file" ++umount $v $TMP_DIR/efiboot.img ++ ++# Move efiboot.img into ISO directory: ++mv $v -f $TMP_DIR/efiboot.img $TMP_DIR/isofs/boot/efiboot.img || Error "Failed to move efiboot.img to isofs/boot/efiboot.img" +diff --git a/usr/share/rear/output/ISO/Linux-ia64/200_mount_bootimg.sh b/usr/share/rear/output/ISO/Linux-ia64/200_mount_bootimg.sh +index b5f603ec5..716d7d383 100644 +--- a/usr/share/rear/output/ISO/Linux-ia64/200_mount_bootimg.sh ++++ b/usr/share/rear/output/ISO/Linux-ia64/200_mount_bootimg.sh +@@ -1,6 +1,11 @@ + # 200_mount_bootimg.sh + dd if=/dev/zero of=$TMP_DIR/boot.img count=64000 bs=1024 +-# make sure we select FAT16 instead of FAT12 as size >30MB +-mkfs.vfat $v -F 16 $TMP_DIR/boot.img >&2 +-mkdir -p $v $TMP_DIR/mnt >&2 +-mount $v -o loop -t vfat -o fat=16 $TMP_DIR/boot.img $TMP_DIR/mnt >&2 ++# Make a FAT filesystem on the boot.img file and loop mount it ++# cf. https://github.com/rear/rear/issues/2575 ++# and output/ISO/Linux-i386/700_create_efibootimg.sh ++# and output/RAWDISK/Linux-i386/280_create_bootable_disk_image.sh ++# Let mkfs.vfat automatically select the FAT type based on the size. ++# I.e. do not use a '-F 16' or '-F 32' option and hope for the best: ++mkfs.vfat $v $TMP_DIR/boot.img ++mkdir -p $v $TMP_DIR/mnt ++mount $v -o loop -t vfat $TMP_DIR/boot.img $TMP_DIR/mnt || Error "Failed to loop mount boot.img" diff --git a/rear.spec b/rear.spec index a45ae76..557f611 100644 --- a/rear.spec +++ b/rear.spec @@ -79,6 +79,10 @@ Patch116: rear-fix-libsystemd-ldd-warning.patch # https://github.com/rear/rear/pull/3242 Patch117: rear-fix-ipv6.patch +# Remove obsolete FAT16 options to avoid kernel warning +# https://github.com/rear/rear/pull/2576 +Patch118: rear-no-fat-16.patch + ###################### # downstream patches # ######################