Linux – Boot partiotionless disk with syslinux

bootboot-loaderbtrfspartitionsyslinux

A file system can be configured to span a complete disk, omitting any partition table. Notice intentionally the command to do so does not use /dev/sda1 but the raw, unpartitioned device instead.

mkfs.btrfs /dev/sda

The Idea is mentioned in the Arch Linux Wiki article about btrfs.
I tried this in a virtual machine using a btrfs file system as only storage. It can even be booted from using grub, following the instruction in the wiki. ext3, ext4 and jfs also work that way. I only tested these, but most filesystem place the first block with an offset and thus leave enough space for a boot record.

Now I would like to use syslinux instead of grub. The aforementioned wiki already indicates that this makes a dedicated placement of the ldlinux.sys neccessary, but does not include instructions to solve this. I highly suspect that the usual mbr.bin file would also not be appropriate, because it is normally responsible to read the partition table and find an active bootable partition. Now, there is not partition to be found.

Does someone have any experience with using syslinux with a partitionless disk? Can a partitionless disk be booted using syslinux?

Best Answer

MBR / BIOS

The commands issued to install syslinux to a partitioned disk are normally two.

extlinux --install /boot/syslinux

The first line installs a volume boot record, to be placed fixed at the start of the partition. It is responsible for loading the files of the bootloader from the file system. They normally reside in /boot/syslinux.

dd bs=440 count=1 conv=notrunc if=/usr/lib/syslinux/bios/mbr.bin of=/dev/sda

The second line installs the master boot record, fixed at the start of the disk. Its task is to read the partition table and find the aforementioned volume boot record in a partition marked active.

In the case at hand, partition and disk are equal, so dd overwrites data extlinux has created. But a master boot record is not needed to start with. There is no partition table to read. So the magical solution is simply to leave out the dd line altogether.

Using a filesystem without a partition table thus not only saves space, but also a step in the boot process.


GPT / EFI

With EFI, this can only be used with legacy booting, which will read the MBR/VBR and boot accordingly. Doing so, most benefits of EFI are lost.

Using EFI boot with GPT, a FAT32 EFI system partition is always needed to read an executable from, which could be an EFI shell or the kernel to boot. So on a modern setup partitioning is inevitable and inherent. As EFI acts like a bootloader itself, there also is no step to be saved as with MBR.

Related Question