LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Improving the compatibility with some UEFI firmware of the LiveSlak installed in an USB flash drive (https://www.linuxquestions.org/questions/slackware-14/improving-the-compatibility-with-some-uefi-firmware-of-the-liveslak-installed-in-an-usb-flash-drive-4175720564/)

LuckyCyborg 01-06-2023 02:40 AM

Improving the compatibility with some UEFI firmware of the LiveSlak installed in an USB flash drive
 
While experimenting with a LiveSlak (for Slackware 14.2) installed in an USB flash drive, I have discovered that there are boot issues on UEFI mode with some of computers, while in another it works.

Basically, the USB flash drive hosting the LiveSlak is not recognized as a valid EFI boot entry by UEFI BIOS on the affected computers, even there exists a valid configured EFI System partition hosting a GRUB2 installation. How the same computers boot quite fine my own made USB hard drives with full installations of Slackware(15.0 and -current), I looked on how LiveSlak partitions and setup the flash drive.

So, when you install LiveSlak on a flash drive using iso2usb.sh , by default it creates 3 partitions on a GPT disk label:

- 1st partition is of 1MB as size and type BIOS Boot, which partition is formatted FAT16 with the label "DOS".
- 2nd partition is of 100MB as size and type EFI System, which partition is formatted FAT32 with the label "EFI".
- 3rd partition uses the rest of drive, has the type Linux filesystem, which partition is formatted EXT4FS with the label "LIVESLAK"

There I identified 2 distinct issues:

1. the first partition of type BIOS Boot, because it's formatted as FAT16 manages to create confusion for the firmware of one of my computers, which somehow ends with ignoring the real EFI partition. In other hand, those GPT of type BIOS Boot are usually used by GRUB2 for installing in legacy BIOS mode. They does not need to be formatted (could be initially wiped as well) and anyway, a 1MB partition is too small even for the GRUB2 from Slackware 14.2 because there is supposed to be installed the second stage of it, which could be bigger.

So, I have chosen to grow just in case this BIOS Boot partition to 10MB and to thoughtfully wipe it with dd instead of formatting. And what the heck? In the end, a space consumption of 10MB is anyway insignificant on an USB flash drive of 4GB, which is minimum for hosting a full Slackware 14.2 LiveSlak, while Slackware 15.0 LiveSlak needs at least an USB flash drive of 8GB.

Because it actually is not used at all today, it's possible to wipe it even on an actual flash drive with LiveSlak, if there's suspicion of interfering with the UEFI boot.

2. the second partition of type EFI System seems to create problems with 3 of my computers, because they does not like, well... its filesystem label.

Believe or not, by changing the label from "EFI" to "ESP" had been fixed the EFI boot issues in those computers.

For convenience, if you intend to apply directly those changes to iso2usb.sh, there's a patch for the latest sources code.
Code:

--- iso2usb.sh.orig        2023-01-01 20:48:17.762329651 +0200
+++ iso2usb.sh        2023-01-06 09:47:16.371370613 +0200
@@ -30,12 +30,12 @@
 FORCE=0
 
 # The default layout of the USB stick is:
-#  partition 1 (1MB),
+#  partition 1 (10MB),
 #  partition 2 (100 MB)
 #  partition 3 (claim all free space - specified as 0 MB).
 # The script allows for an amount of free space to be left at the end
 # (partition 4, unused by liveslak) in case you need this:
-DEF_LAYOUT="1,100,-1,"
+DEF_LAYOUT="10,100,-1,"
 
 # By default, we use 'slhome.img' as the name of the LUKS home containerfile.
 DEF_SLHOME="slhome"
@@ -195,7 +195,7 @@
 #
 # $(basename $0) -i ~/download/slackware64-live-14.2.iso -o /dev/sdX
 # $(basename $0) -i slackware64-live-xfce-current.iso -o /dev/mmcblkX -c 750M -w 15
-# $(basename $0) -i slackware-live-current.iso -o /dev/sdX -y 1,200,-1,4096
+# $(basename $0) -i slackware-live-current.iso -o /dev/sdX -y 10,200,-1,4096
 #
 EOT
 }
@@ -702,10 +702,10 @@
  TARGETP2=$(fdisk -l $TARGET |grep ^$TARGET |cut -d' ' -f1 |grep -E '[^0-9]2$')
  TARGETP3=$(fdisk -l $TARGET |grep ^$TARGET |cut -d' ' -f1 |grep -E '[^0-9]3$')
 
-  # Create filesystems:
-  # Not enough clusters for a 32 bit FAT:
-  mkdosfs -s 2 -n "DOS" ${TARGETP1}
-  mkdosfs -F32 -s 2 -n "EFI" ${TARGETP2}
+  # Wipe the BIOS Boot partition:
+  dd if=/dev/zero of=${TARGETP1} bs=512
+  # Create EFI System filesystem:
+  mkdosfs -F32 -s 2 -n "ESP" ${TARGETP2}
  # KDE tends to automount.. so try an umount:
  if mount |grep -qw ${TARGETP3} ; then
    umount ${TARGETP3} || true

As well, you can wipe manually (and safely) the 1st partition with dd and to tune the label of ESP with fatlabel in an USB flash drive already configured for LiveSlak - I tested also this way with success.

If you wonder from where "ESP" come, this is usually the name of EFI partition used in documentation (I guess it's from EFI System Partition) and I used this label for ESPs with great success in various Linux distributions since at least 10 years.

Didier Spaier 01-06-2023 04:14 AM

As an aside, the BIOS Boot partition is only needed by GRUB if booting in BIOS aka Legacy mode (not EFI mode) and in case of a GUID partition table aka GPT. In this case, it should not be formatted at all (no file system in it). A size of 10M would be an overkill, 1M for a BIOS Boot partition could be too small but 2M is good enough. And yes, ESP is an abbreviation of EFI System Partition.

LuckyCyborg 01-06-2023 05:23 AM

Quote:

Originally Posted by Didier Spaier (Post 6402545)
As an aside, the BIOS Boot partition is only needed by GRUB if booting in BIOS aka Legacy mode (not EFI mode) and in case of a GUID partition table aka GPT. In this case, it should not be formatted at all (no file system in it). A size of 10M would be an overkill, 1M for a BIOS Boot partition could be too small but 2M is good enough. And yes, ESP is an abbreviation of EFI System Partition.

That's exactly WHY I have said that this particular BIOS Boot partition on the LiveSlak flash drive is NOT used at all and it's safe to be wiped even later, in a functional LiveSlak.

In fact, while using a GPT disk label, for the legacy BIOS, LiveSlak use the EXTLINUX (part of SYSLINUX) to boot from the Linux partition, while GRUB2 is used only for EFI mode boot. However, probably in future Mr. Hameleers considers to use GRUB2 for legacy BIOS boot, and that's the explanation of the setting up this BIOS Boot partition.

Anyway, the practice demonstrate that formatting it as FAT16 is a bad idea (confusing particular UEFI firmware) and the discussion about sizing it at 10MB being overkill, I believe that's well, overkill. ;)

I use this BIOS Boot partition sized at 10MB since long time and my tomcat still don't killed my dogs until today - they being Caucasian Shepherds (known also as bear dogs) probably helped too. ;)

In practice both 2MB and 10MB sized partitions are insignificant in the economy of space in an USB flash drive, sized at least 4GB or 8GB.


All times are GMT -5. The time now is 09:48 PM.