Syslinux is a package that contains a family of bootloaders. The package includes SYSLINUX (FAT filesystem bootloader), EXTLINUX (ext2/3/4, btrfs and xfs filesystem bootloader), PXELINUX (Network PXE bootloader) and ISOLINUX (ISO-9660) for CD/DVD bootloading.

Emerge

Setup on BIOS systems

The rest of this section will presume the boot partition is located at /dev/sda1 (which is a common location). If this is not the case be sure to make adjustments as needed.

To use EXTLINUX be sure to install the proper boot sector, then install the boot loader into the partition. If these steps are omitted EXTLINUX will not be operational. This type of a boot sector setup is not needed for the SYSLINUX, PXELINUX and ISOLINUX installations.

Boot sector

MBR (msdos)

NoteThese instructions are for a MBR (msdos) partition layout. For GPT, skip down to the GPT setup section.

First, install the boot sector provided by Syslinux. Use extra care with this command; if count=1 is not given it will overwrite the entire disk rather than just the first 440 bytes:

Boot loader installation

EXTLINUX

Use the extlinux command to install the necessary files to /boot/extlinux

root #mkdir /boot/extlinux

root #extlinux --install /boot/extlinux

root #ln -snf . /boot/boot

NoteThe "boot -> ." symlink is not necessary per se, but for the sake of consistency, it is made so the example configurations are the same for users with /boot on same partition and those with separate partitions.

The Syslinux package contains various modules to enable additional features. Starting with Syslinux version 5, some modules depends on others, so it is a good idea to copy most basic modules regardless of the use case. See Checking dynamic links to verify whether all dependencies are installed.

root #cd /usr/share/syslinux

root #cp menu.c32 memdisk libcom32.c32 libutil.c32 /boot/extlinux

ISOLINUX

To install ISOLINUX, start off with a base directory in which all the files that need to reside on the CD or DVD are situated. In the base directory, create a subdirectory called isolinux and copy the isolinux.bin file from the Syslinux package into the isolinux folder:

root #mkdir isolinux

root #cp /usr/share/syslinux/isolinux.bin isolinux/

Create the isolinux.cfg file according to the instructions mentioned below.

Next, create two more directories kernel and images in the base directory:

root #mkdir kernel images

Copy the memdisk binary into the kernel directory:

root #cp /usr/share/syslinux/memdisk kernel/

NoteIn order to use the mkisofs command the app-cdr/cdrtools package will need to be installed. This can be obtained by running:

root #emerge --ask app-cdr/cdrtools

When the configuration has been made, the following mkisofs command can be used to create the final ISO image (remember to substitute ${BASEDIR} with the same base directory used in the previous commands):

PXELINUX

With PXELINUX is possible to netboot using images that are shared through a TFTP server. This article will assume there is a TFTP server installed, and its TFTP root directory is located at /var/lib/tftpboot With this setup, copy the PXELINUX loader to the TFTP boot directory and create a configuration directory:

root #cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/pxelinux.0

root #mkdir /var/lib/tftpboot/pxelinux.cfg

NoteWhen copying the newer lpxelinux.0 instead of pxelinux.0, it is also possible to load the kernel and ramdisk via HTTP and to make use of DNS names in the configuration file.

The config directory can be used to store different configurations for the netbooted clients. When a client tries to boot, the MAC address or the IP address is used to determine the appropriate client config file. First it tries to look for the MAC address, followed by a try on the hexadecimal representation of the client IP. After that a character is stripped from the end of this hexadecimal representation until no more characters are left, or until a configuration file is located. If none of the tries match, the default config file is used.

The hexadecimal representation of an IP can be found by using the gethostip command:

NoteFor easy maintenance, create configuration files by hostname and symlink to the IP representation. To re-enable the defaults simply delete or rename the symlink.

SYSLINUX

Use the syslinux command to install the SYSLINUX bootloader on the (FAT) file system:

root #syslinux --install /dev/sda1

Setup on EFI systems

NoteEFI is supported since Syslinux 6.00.

EFI system partition

Create a partition of type EF (MBR) or EF00 (GPT) with a FAT32 file system. It is also possible to use an existing EFI system partition if one is present. It is advisable to mount this partition at /boot/efi/.

NoteThe following assumes that the system is booted in EFI mode, and that the EFI system partition is located at /dev/sda1.

Boot loader install

In the EFI system partition, create a directory for the Syslinux files. This directory will also contain the configuration files that will be created later.

root #mkdir -p /boot/efi/EFI/syslinux

Copy the syslinux.efi and ldlinux.e64 files along with the other desired .c32 files from /usr/share/syslinux/efi64/ to the new syslinux directory. For example:

If the system has not been booted in EFI mode, then the Syslinux files need to be copied to the /boot/efi/EFI/Boot directory instead and syslinux.efi needs to be renamed to bootx64.efi. If this is the case then skip the next section concerning the efibootmgr utility.

Making Syslinux known to EFI

Ensure that CONFIG_EFI_VARS is enabled in the kernel. If it was built as a module, ensure that it is loaded into memory. This action can be done using the modprobe utility. After the modules have been loaded create a new boot entry using efibootmgr:

root #modprobe efivars

root #efibootmgr -c -l '\EFI\syslinux\syslinux.efi' -L SYSLINUX -p 1

efibootmgr will automatically adjust the EFI boot order to put the most recently created entry at the top of the list. If that is undesired, change the boot order with the -o option.

NoteIn order for the efibootmgr command to work sys-boot/efibootmgr must be emerged. If needed, do so using the following command:

root #emerge --ask sys-boot/efibootmgr

Configuration

The configuration file for Syslinux is called syslinux.cfg. For compatibility with existing installs, the following legacy configuration file names are still supported:

EXTLINUX: extlinux.conf

ISOLINUX: isolinux.cfg

The configuration format, however, is the same. The configuration file must be present in the directory where Syslinux is installed.

Simple configuration

This will provide a simple "boot:" prompt, similar to the one in Gentoo's Minimal LiveCD:

FILEsyslinux.cfg

DEFAULT gentoo
LABEL gentoo
LINUX /boot/kernel-3.6.11-gentoo

Menu configuration

The following configuration provides a simple text menu example. This is done via the vesamenu module. In some cases where vesa is not compatible, the simpler menu module will work. Copy the VESA menu module into the boot filesystem or EFI system partition. BIOS systems should use the following example:

NoteAvoid using the KERNEL parameter for selecting the Linux kernel images, use the LINUX parameter instead. If the KERNEL parameter is used and the image filename ends with a .0 then extlinux will misinterpret it and try to PXE its ending with a screen full of graphical artifacts and nothing else. See the "KERNEL file" section on the SYSLINUX wiki for more information.

NoteIn the configuration file, absolute paths will be relative to the filesystem's root, non-absolute paths will be relative to the Syslinux installation directory.

Passing kernel parameters

Unless the kernel parameters are hard-coded and the initramfs is built-in into the kernel image, these may need to be passed on to the kernel through the boot loader. To do so, use APPEND and/or the INITRD parameter: