How to create a bootable system with a squashfs root

Solution 1:

To get a working system with a squashfs filesystem:

sudo apt-get install live-boot live-boot-initramfs-tools extlinux
sudo update-initramfs -u

Create a squashfs file from a bootstrapped or running ubuntu filesystem with whatever packages you want available. https://help.ubuntu.com/community/LiveCDCustomizationFromScratch provides good instructions for creating a debootstrapped system to build on. Format the target drive with ext2/3/4 and enable the bootable flag. Create the folder layout on the target drive and install extlinux:

mkdir -p ${TARGET}/boot/extlinux ${TARGET}/live
extlinux -i ${TARGET}/boot/extlinux
dd if=/usr/lib/syslinux/mbr.bin of=/dev/sdX #X is the drive letter
cp /boot/vmlinuz-$(uname -r) ${TARGET}/boot/vmlinuz
cp /boot/initrd.img-$(uname -r) ${TARGET}/boot/initrd
cp filesystem.squashfs ${TARGET}/live

Create ${TARGET}/boot/extlinux/extlinux.conf with the following contents:

DEFAULT Live
LABEL Live
  KERNEL /boot/vmlinuz
  APPEND initrd=/boot/initrd boot=live toram=filesystem.squashfs
TIMEOUT 10
PROMPT 0

Now you should be able to boot from the target drive in to your squashed system.

Solution 2:

This question was solved by the OP:

Well I got it working. I used the live-boot & live-boot-initramfs-tools to generate an initrd and extlinux for the bootloader. Works like a charm.