4

I made a squashfs image from my system root, I want to put it on a USB drive among some Live ISOs, and make boot menu using GRUB2.

What kernel boot parameters should I use to specify that Squashfs image as root file-system?

I used this as grub configuration, but Dracut fails to find and mount root:

insmod gzio
insmod xzio
insmod part_msdos
insmod squash4
insmod iso9660
insmod ext2
insmod btrfs
insmod regexp
menuentry 'Fedora Workstation' {
    set imgfile=/images/fedora*.squashfs
    loopback loop0 /$imgfile
    linux16 (loop0)/boot/vmlinuz-4.1.8-200.fc22.x86_64 ro rd.fstab=0 root=$imgfile elevator=deadline enforcing=0 #rhgb quiet LANG=en_US.utf8
    initrd16 (loop0)/boot/initramfs-4.1.8-200.fc22.x86_64.img
}
Microsoft Linux TM
  • 1,596
  • 5
  • 16
  • 26

1 Answers1

2

In my opinion, you should still use an initramfs. Pretty much any will do, but you'll need the squashfs file-system kernel module (if its not already compiled into your kernel) in your initramfs image.

Most initramfs systems respect fstab - and definitely Dracut does. And so you can just configure two /etc/fstab files - one in your .sfs image and one in your initramfs image.

{   cd /tmp; cat >fstab
    mkdir -p sfs/sfs sfs/usb
    dracut  -i fstab /etc/fstab     \
            -i sfs sfs              \
            --add-drivers overlay   \
            --add-drivers squashfs  \
            initramfs.img 
}   <<"" #FSTAB
    UUID={USB-UUID}     /sfs/usb    $usbfs      defaults    0 0
    /sfs/usb/img.sfs    /sfs/sfs    squashfs    defaults    0 0

In all honesty I'm not perfectly familiar with the dracut initramfs build system, and so there may be something more necessary for that command to complete successfully. I'm working with a general familiarity of how most initramfs mounts are set up and the information I find in the man page for dracut here. Some further assembly may be necessary, but this should bring you along fairly well.

After you've installed a proper /etc/fstab to your initramfs, you should then be able to use the following root device related parameters to get an overlayfs rootfs:

root=overlay \
rootfstype=overlay \
rootflags=\
lowerdir=/sfs/sfs,\
upperdir=/sfs/usb/persist,\
workdir=/sfs/usb/tmp

This assumes you have a directory on your usb drive named /persist and another empty one named /tmp and that your squashfs image can be found at the root of your usb filesystem as /img.sfs.

mikeserv
  • 57,448
  • 9
  • 113
  • 229