Table of Contents

Set up SYSLINUX as boot loader on UEFI based hardware

SYSLINUX is a boot loader that loads Linux (among other things) from FAT filesystem. The Syslinux Project, of which SYSLINUX the boot loader is a part, contains also ISOLINUX, EXTLINUX and PXELINUX, basically its variants to boot from optical media, ext2/3/4, Btrfs, XFS, UFS/FFS and NTFS or from network.

UEFI support seems to have been added in version 6 of SYSLINUX, while Slackware comes with version 4, which means it can not be set up during Slackware installation, unless one prepares SYSLINUX files on another machine.

Why SYSLINUX

That being said, why bother with SYSLINUX? A couple of reasons:

Why UEFI

It is not as though there is some choice; machines nowadays are UEFI. One can, however, choose to set UEFI to so called “CSM” or sometimes “Legacy” mode. In this mode, UEFI acts as BIOS, i.e. reads the first sector (MBR) of a hard drive and loads and executes non-UEFI boot loader such as LILO from there. As opposed to UEFI in, say, UEFI mode, when it reads, loads and executes UEFI-aware boot loader from EFI boot partition.

Frankly, there are no compelling reasons not to use CSM (note that it is possible to use GPT partitions without UEFI). On the contrary, there are reasons to avoid UEFI booting, because:

But, as with LILO, the day may come we will need to move on.

Installation

There are basically two steps: first, preferably before you even install Slackware, partition the disk using GPT and create EFI boot partition, second, compile and install SYSLINUX.

But before you begin:

Create EFI Boot Partition

It is the place where UEFI will look for a boot loader. Several tools can be used to partition a drive and create EFI boot partition,:

Let's assume you have empty 10GB drive /dev/sda.

# sgdisk -Z /dev/sda
# gdisk -l /dev/sda
GPT fdisk (gdisk) version 1.0.0

Partition table scan:
  MBR: not present
  BSD: not present
  APM: not present
  GPT: not present

Creating new GPT entries.
Disk /dev/sda: 20971520 sectors, 10.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 8C026A41-F188-4521-A72C-D2B826EAA1D1
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 20971486
Partitions will be aligned on 2048-sector boundaries
Total free space is 20971453 sectors (10.0 GiB)

Number  Start (sector)    End (sector)  Size       Code  Name
# sgdisk -n 1:0:+512M /dev/sda
# sgdisk -n 2:0:+9G /dev/sda
# sgdisk -n 3 /dev/sda
# sgdisk -t 1:ef00 /dev/sda
# sgdisk -t 2:8300 /dev/sda
# sgdisk -t 3:8200 /dev/sda
# gdisk -l /dev/sda
GPT fdisk (gdisk) version 1.0.0

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.
Disk /dev/sda: 20971520 sectors, 10.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 3F2101FB-0D6B-481F-98B9-1C6621DB0981
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 20971486
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         1050623   512.0 MiB   EF00  
   2         1050624        19924991   9.0 GiB     8300  
   3        19924992        20971486   511.0 MiB   8200
# mkfs.vfat -F 32 /dev/sda1

That is pretty much it for EFI boot partition. You can do whatever you like with /dev/sda2 (RAID, LUKS, LVM, any filesystem) and install Slackware there, but leave EFI partition alone, that partition needs to be unencrypted and FAT32 formatted.

Set up SYSLINUX

Compilation

Download sources and compile.

$ unxz -c syslinux-6.03.tar.xz | tar -x
$ cd syslinux-6.03/
$ make
$ make INSTALLROOT=/some/where install

Set up boot loader

Now copy the boot loader and a few modules, as well as kernel and initrd to EFI boot partition created earlier. Let's asssume /dev/sda1 is mounted as /boot/efi.

# cd /boot/efi
# mkdir EFI
# mkdir EFI/SYSLINUX
# cd EFI/SYSLINUX
# cp /some/where/usr/share/syslinux/efi64/syslinux.efi .
# cp /some/where/usr/share/syslinux/efi64/ldlinux.e64 .
# cp /some/where/usr/share/syslinux/efi64/libutil.c32 . 
# cp /some/where/usr/share/syslinux/efi64/menu.c32 .
/boot/efi/EFI/SYSLINUX/syslinux.cfg
UI menu.c32
PROMPT 0
TIMEOUT 100
DEFAULT Slackware 14.2

MENU TITLE Machine Boot Menu

LABEL Slackware 14.2
	MENU LABEL Slackware 14.2
	LINUX vmlinuz-huge-4.4.14
	APPEND /dev/vgroot/V_ROOT 4
	INITRD initrd.gz-4.4.14

LABEL Slackware 14.2 no X
	MENU LABEL Slackware 14.2 no X
	LINUX vmlinuz-huge-4.4.14
	APPEND /dev/vgroot/V_ROOT
	INITRD initrd.gz-4.4.14
# cp /boot/vmlinuz-huge-4.4.14 .
# mkinitrd -c -k 4.4.14 -C /dev/sda2 -L -R -f xfs -m xfs:hid:hid-generic:usbhid:xhci-hcd:xhci-pci:ehci-hcd:ehci-pci:ohci-hcd:ohci-pci:uhci-hcd:uhci-pci:usb-storage -r /dev/vgroot/V_ROOT -o /boot/initrd.gz-4.4.14
# cp /boot/initrd.gz-4.4.14 .

The second boot menu is that of SYSLINUX, i.e. what you typed to syslinux.cfg and will show up either if you do not tigger UEFI boot menu or trigger it and then select either SYSLINUX or device (hard drive) it is on.

# efibootmgr -c -d /dev/sda -p 1 -l \\EFI\\SYSLINUX\\syslinux.efi -L "SYSLINUX"
Timeout: 2 seconds
BootOrder: 0000,0001,0002
Boot0000* SYSLINUX
Boot0001* UEFI: IP4 Realtek PCIe GBE Family Controller
Boot0002* UEFI: IP6 Realtek PCIe GBE Family Controller
# efibootmgr -o 0000,0001,0002

Troubleshooting

If your machine complains it has nothing to boot, that may indicate efibootmgr command was incorrect or somehow did not register. You may then try to force it to boot SYSLINUX by moving and renaming it to EFI\Boot\bootx64.efi, which is kind of fallback option; the machine will try to boot that at some point.

# cd /boot/efi/EFI
# mv SYSLINUX Boot
# cd Boot
# cp syslinux.efi bootx64.efi

Sources