From f58530ceb112d4c018a68e064b73c650d9c493f4 Mon Sep 17 00:00:00 2001 From: Eric Hameleers Date: Tue, 15 Aug 2023 22:20:57 +0200 Subject: Fix broken support for Ventoy on UEFI computers Changes in Slackware-current in March and May 2023 broke support for detection of Ventoy disk on UEFI computers. Liveslak's initrd needed to have efivarfs module added, so that /sys/firmware/efi/efivars can be mounted by the live init script. With kernel 6.x the content of what's found under efivars has changed - instead of being represented as a directory with the efi datastructures as files, liveslak now needs to deal with a single file instead and find the offset in there. --- liveinit.tpl | 12 ++++++++++++ make_slackware_live.sh | 2 +- upslak.sh | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/liveinit.tpl b/liveinit.tpl index 5d34592..44d6c1d 100644 --- a/liveinit.tpl +++ b/liveinit.tpl @@ -168,6 +168,11 @@ if grep devtmpfs /proc/filesystems 1>/dev/null 2>/dev/null ; then mount -n devtmpfs /dev -t devtmpfs -o size=8M fi +# Mount if this directory exists (so the kernel supports efivarfs): +if [ -d /sys/firmware/efi/efivars ]; then + mount -o rw -t efivarfs none /sys/firmware/efi/efivars +fi + # Parse command line for ARG in $(cat /proc/cmdline); do case $ARG in @@ -818,16 +823,23 @@ if [ "$RESCUE" = "" ]; then VENTID="VentoyOsParam-77772020-2e77-6576-6e74-6f792e6e6574" VENTVAR="/sys/firmware/efi/vars/${VENTID}" if [ ! -d "${VENTVAR}" ]; then + # Newer Slackware will use 'efivars' rather than 'vars' directory; VENTVAR="/sys/firmware/efi/efivars/${VENTID}" fi if [ -d "${VENTVAR}" ]; then echo "${MARKER}: (UEFI) Ventoy ISO boot detected..." ISOBOOT="ventoy" VENTOSPARM="${VENTVAR}/data" + elif [ -f "${VENTVAR}" ]; then + # Kernel >= 6.x does not offer a clean data sctructure, so we need to + # find the offset of the data block in the efivars file: + cat "${VENTVAR}" > /vent.dmp else # Detect Ventoy in memory (don't use the provided hooks), see # https://www.ventoy.net/en/doc_compatible_format.html: dd if=/dev/mem of=/vent.dmp bs=1 skip=$((0x80000)) count=$((0xA0000-0x80000)) 2>/dev/null + fi + if [ -f /vent.dmp ]; then # Use 'strings' to find the decimal offset of the magic string; # With 'xargs' we remove leading and ending spaces: if strings -t d /vent.dmp 1>/dev/null 2>/dev/null ; then diff --git a/make_slackware_live.sh b/make_slackware_live.sh index c55fc05..e380938 100755 --- a/make_slackware_live.sh +++ b/make_slackware_live.sh @@ -255,7 +255,7 @@ TESTINGLIST_DAW="" # List of kernel modules required for a live medium to boot properly; # Lots of HID modules added to support keyboard input for LUKS password entry; # Virtio modules added to experiment with liveslak in a VM. -KMODS=${KMODS:-"squashfs:overlay:loop:xhci-pci:ohci-pci:ehci-pci:xhci-hcd:uhci-hcd:ehci-hcd:mmc-core:mmc-block:sdhci:sdhci-pci:sdhci-acpi:rtsx_pci:rtsx_pci_sdmmc:usb-storage:uas:hid:usbhid:i2c-hid:hid-generic:hid-apple:hid-cherry:hid-logitech:hid-logitech-dj:hid-logitech-hidpp:hid-lenovo:hid-microsoft:hid_multitouch:jbd:mbcache:ext3:ext4:isofs:fat:nls_cp437:nls_iso8859-1:msdos:vfat:exfat:ntfs:virtio_ring:virtio:virtio_blk:virtio_balloon:virtio_pci:virtio_pci_modern_dev:virtio_net"} +KMODS=${KMODS:-"squashfs:overlay:loop:efivarfs:xhci-pci:ohci-pci:ehci-pci:xhci-hcd:uhci-hcd:ehci-hcd:mmc-core:mmc-block:sdhci:sdhci-pci:sdhci-acpi:rtsx_pci:rtsx_pci_sdmmc:usb-storage:uas:hid:usbhid:i2c-hid:hid-generic:hid-apple:hid-cherry:hid-logitech:hid-logitech-dj:hid-logitech-hidpp:hid-lenovo:hid-microsoft:hid_multitouch:jbd:mbcache:ext3:ext4:isofs:fat:nls_cp437:nls_iso8859-1:msdos:vfat:exfat:ntfs:virtio_ring:virtio:virtio_blk:virtio_balloon:virtio_pci:virtio_pci_modern_dev:virtio_net"} # Network kernel modules to include for NFS root support: NETMODS="kernel/drivers/net kernel/drivers/virtio" diff --git a/upslak.sh b/upslak.sh index b098199..cacc158 100644 --- a/upslak.sh +++ b/upslak.sh @@ -133,7 +133,7 @@ COMPR="xz --check=crc32" # List of kernel modules required for a live medium to boot properly; # Lots of HID modules added to support keyboard input for LUKS password entry; # Virtio modules added to experiment with liveslak in a VM. -KMODS=${KMODS:-"squashfs:overlay:loop:xhci-pci:ohci-pci:ehci-pci:xhci-hcd:uhci-hcd:ehci-hcd:mmc-core:mmc-block:sdhci:sdhci-pci:sdhci-acpi:rtsx_pci:rtsx_pci_sdmmc:usb-storage:uas:hid:usbhid:i2c-hid:hid-generic:hid-apple:hid-cherry:hid-logitech:hid-logitech-dj:hid-logitech-hidpp:hid-lenovo:hid-microsoft:hid_multitouch:jbd:mbcache:ext3:ext4:isofs:fat:nls_cp437:nls_iso8859-1:msdos:vfat:exfat:ntfs:virtio_ring:virtio:virtio_blk:virtio_balloon:virtio_pci:virtio_pci_modern_dev:virtio_net"} +KMODS=${KMODS:-"squashfs:overlay:loop:efivarfs:xhci-pci:ohci-pci:ehci-pci:xhci-hcd:uhci-hcd:ehci-hcd:mmc-core:mmc-block:sdhci:sdhci-pci:sdhci-acpi:rtsx_pci:rtsx_pci_sdmmc:usb-storage:uas:hid:usbhid:i2c-hid:hid-generic:hid-apple:hid-cherry:hid-logitech:hid-logitech-dj:hid-logitech-hidpp:hid-lenovo:hid-microsoft:hid_multitouch:jbd:mbcache:ext3:ext4:isofs:fat:nls_cp437:nls_iso8859-1:msdos:vfat:exfat:ntfs:virtio_ring:virtio:virtio_blk:virtio_balloon:virtio_pci:virtio_pci_modern_dev:virtio_net"} # Network kernel modules to include for NFS root support: NETMODS="kernel/drivers/net kernel/drivers/virtio" -- cgit v1.2.3