Sunday, December 16, 2012

Setting Up Syslinux to Chainload other Linux Distros



I am starting this blog as a new install. 

You need to set up your partitions. We will be using a boot partition, a swap partition, an Arch Linux partition, and a Debian Linux partition. I am using a GPT partition table, so that converting to UEFI later on, will be easier.

#parted /dev/sda
mklabel gpt
mkpart 100MiB 200MiB
mkpart 200MiB 10GiB
mkpart 10GiB 60GiB
mkpart 60GiB 110GiB
set 1 boot_legacy on
quit

Make the first partition a fat partition. Turn swap on and enable EXT4 file system for Arch and Debian. 

mkfs.vfat -F32 /dev/sda1 
mkfs.ext4 /dev/sda3
mkfs.ext4 /dev/sda4
swapon /dev/sda2

After you have completed your installation you can set up you can set up your boot loader Syslinux. Ensure that your boot partition is not added to your fstab file.

After you have downloaded syslinux and installed it, we can set up the boot process.

#mkdir /mnt/boot
#mount /dev/sda1 /mnt/boot
#mkdir /mnt/boot/boot/syslinux
#syslinux -i /dev/sda1 -d /boot/syslinux

We need to copy the GPTMBR over to the boot sector. Syslinux installs a MBR by default.

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

There should only be ldlinux.ld file in /boot/syslinux. You can place syslinux in the base but I prefer the hierarchy structure. Simply use syslinux -i/dev/sda1.

Copy over the chain boot and menu files.

#cp /usr/lib/syslinux/chain.c32 /mnt/boot/boot/syslinux/
#cp /usr/lib/syslinux/menu.c32 /mnt/boot/boot/syslinux/

Now we need to make a syslinux.cfg file.

I suggest you copy over the partition uuids before creating it.


#lsblk /dev/sda -o NAME,PARTLABEL,PARTUUID > /mnt/boot/boot/syslinux/syslinux.cfg
NAME   PARTLABEL PARTUUID
sda              
├─sda1 boot      ccd52c34-e8af-4ee7-8c33-592ec83445db
├─sda2 swap      c8d1a535-d8c6-4499-81fa-a0ee58d67695
├─sda3 arch      0b0299aa-8d0f-4865-bfa8-ff43a74386f8
├─sda4 debian    f22cb873-9a1a-47c8-9bd8-d9f0c828e6b6


My syslinux.cfg looks like this. Ensure that if you use UUID that you use lsblk -0 PARTUUID not lsblk -o UUID.


DEFAULT menu.c32 
PROMPT 0

MENU TITLE Syslinux Boot
MENU AUTOBOOT arch
TIMEOUT 300
TOTALTIMEOUT 9000

LABEL arch
  MENU DEFAULT
  MENU LABEL Arch Linux
  SAY Booting to Arch Linux
  COM32 chain.c32
  APPEND guid=0b0299aa-8d0f-4865-bfa8-ff43a74386f8
  #APPEND label=arch /dev/sda3

LABEL debian
  MENU LABEL Debian Linux
  COM32 chain.c32
  APPEND guid=f22cb873-9a1a-47c8-9bd8-d9f0c828e6b6
  #APPEND label=debian

For each operating system you need a extlinux. Unmount the boot partition and set up extlinux.

#umount /dev/sda1

Install extlinux to the base of your system

#extlinux -i /dev/sda3 -d /boot/syslinux

Older extlinux require the path to be /boot/extlinux and require a /boot/extlinux.conf file. I prefer to standardize syslinux.

#vim /boot/syslinux/syslinux.cfg

default arch


label arch
  linux /boot/vmlinuz-linux
  initrd /boot/initramfs-linux.img
  append root=/dev/sda3 rw

You'll need to repeat this for your Debian distribution




No comments:

Post a Comment