Booting Linux or XEN with EXTLINUX

tested on Devuan/ascii, Ubuntu/artful and Slackware/14.2

Preliminary Note

If using MBR, make sure the needed partition has the bootable flag, for the mbr.bin bootcode to work,

fdisk -l /dev/sda

Also assuming you do NOT have a separate partition for /boot. I have / only as ext4, which EXTLINUX is able to read. Very recent versions of EXTLINUX are also capable to read XFS partitions – see the Building latest EXTLINUX section.

If you have XFS instead of EXT4 on Slackware Linux, see the From Scratch section below, as XFS support is only available since v5.01. Ubuntu has v6.03 but slackware has v4.07.

Install // Packages

Ubuntu artful,

apt install syslinux-utils extlinux

Avoiding Slackware 14.2’s obsolete v4.07,

#slackpkg install syslinux

Install // From Scratch

Fetch the latest stable or testing or current SYSLINUX,

#wget https://cdn.kernel.org/pub/linux/utils/boot/syslinux/syslinux-6.03.tar.gz
#tar xzf syslinux-6.03.tar.gz 
#cd syslinux-6.03

#wget https://cdn.kernel.org/pub/linux/utils/boot/syslinux/Testing/6.04/syslinux-6.04-pre1.tar.gz
#tar xzf syslinux-6.04-pre1.tar.gz 
#cd syslinux-6.04-pre1

git clone --recursive git://repo.or.cz/syslinux.git
cd syslinux

which nasm
#sbopkg -i ucl
slackpkg install ucl
#sbopkg -i upx
slackpkg install upx
ls -lhF /usr/include/uuid/uuid.h
time make -j24 > make.log && echo done
removepkg syslinux
make install

which extlinux
date
ls -lhF `which extlinux`
extlinux -v

Write the bootcode

fdisk -l /dev/sda | grep ^Disklabel

In case you are using mbr.bin, you will have to MAKE THE PARTITION BOOTABLE,

cfdisk /dev/sda

Ubuntu GPT,

dd if=/usr/lib/SYSLINUX/gptmbr.bin of=/dev/sda

Ubuntu MBR,

dd if=/usr/lib/SYSLINUX/mbr.bin of=/dev/sda

Debian GPT,

dd if=/usr/lib/EXTLINUX/gptmbr.bin of=/dev/sda

Debian MBR,

dd if=/usr/lib/EXTLINUX/mbr.bin of=/dev/sda

From source GPT,

dd if=/usr/share/syslinux/gptmbr.bin of=/dev/sda

From source MBR,

date
ls -lF /usr/share/syslinux/mbr.bin
dd if=/usr/share/syslinux/mbr.bin of=/dev/sda
#cat /usr/share/syslinux/mbr.bin > /dev/sda

Configure EXTLINUX

extlinux -i /

when the mount command does not show the tru device patch, force it e.g.,

#extlinux -i / --device /dev/sda1

ls -lhF /ldlinux.c32
ls -lhF /ldlinux.sys

#with multiboot/xen
cp -f /usr/share/syslinux/libcom32.c32 /
cp -f /usr/share/syslinux/mboot.c32 /
#debian
#cp /usr/lib/syslinux/modules/bios/libcom32.c32 /
#cp /usr/lib/syslinux/modules/bios/mboot.c32 /

#with menu
cp -f /usr/share/syslinux/libutil.c32 /
cp -f /usr/share/syslinux/menu.c32 /
#debian
#cp /usr/lib/syslinux/modules/bios/libutil.c32 /
#cp /usr/lib/syslinux/modules/bios/menu.c32 /

vi /extlinux.conf

default XEN
prompt 1
timeout 30

#default menu.c32
#prompt 0
#menu title EXTLINUX

label Linux
    linux vmlinuz
    append root=/dev/sda1 ro ipv6.disable=1
#initrd=initrd.img

label XEN
    kernel mboot.c32
    append xen.gz loglvl=info noreboot=true pv-linear-pt=true --- vmlinuz console=tty0 root=/dev/sda1 ro ipv6.disable=1
#--- initrd.img
#loglvl=all
#dom0_mem=4096M,max:4096M
#https://xenbits.xen.org/docs/4.11-testing/misc/xen-command-line.html
#8192M 10240M 12288M
#netcfg/do_not_use_netplan=true
#crashkernel=128M
#crashkernel=128M@16M
#crashkernel=auto
#crashkernel=X@Y
#crashkernel=0M-2G:128M,2G-6G:256M,6G-8G:512M,8G-:768M

ls -lhF /*.{conf,sys,c32}
ls -lhF /xen.gz /vmlinuz

Ready to check

sync
shutdown -r now

Clean-up

On Ubuntu artful,

apt purge lilo
dpkg -l | grep grub
apt purge ...grub...

On Slackware 14.2,

#no need to remove lilo, nothing is automated anyways
#and there is no grub

Improved Layout

#ubuntu
cp /slackware/usr/share/syslinux/menu.c32 /

ui menu.c32
prompt 0
menu title SYS
timeout 100
default XEN

References