Using squashfs on /usr for a live cd

Alexander E. Patrakov patrakov at ums.usu.ru
Mon Feb 5 21:40:30 PST 2007


Kevin Annies wrote:
> Hi,

> I have a bootable cd which I am regularly updating but now space is a
> concern I would like to implement squashfs. I have implemented it on a
> static system and totally understand the theory of how it works. The part
> I can't work out is the following:

Disclaimer: I am not the author of the hint that you seem to have followed. 
The official LFS LiveCD works very differently.

> I am using an initial ram disk. As usual I have a file called linuxrc
> which gets executed,

initrd is obsolete, you should really switch to initramfs. It is just a 
"cpio -H newc" archive of arbitrary size that you load instead of the 
initrd. Linux will execute the /init script or binary, which should mount 
root to /mnt and do the following at the end (instead of pivot_root, and 
slightly oversimplified - doesn't reclaim RAM used by initramfs, because it 
is impossible to do from a shell script):

cd /mnt
mount --move . /
exec chroot . /sbin/init "$@"

(the "run-init" binary from the "klibc" package does the same three steps 
for you, without oversimplification).

However, you are using an old-style initrd, which is also good at this time. 
Let's continue this way.

> mount -n -o ro -t iso9660 $LFS_CDROM_DEVICE $TMP_MOUNT
> cd $TMP_MOUNT 
> pivot_root . mnt
> umount -n /mnt/proc >/dev/null 2>&1
> mount /usr.sqsh /usr -o loop
> exec chroot . sh -c 'umount -n /mnt >/dev/null 2>&1; exec -a
> init.new /sbin/init 3' dev/console 2>&1

> I have inserted the mount usr.sqsh command at this point because the
> following chroot command is executed from the just newly mounted /
> system.

This is wrong. You should include /dev/loop0 in your initrd (alternatively, 
include it on the CD, and call "losetup && mount /dev/loop0" instead of 
"mount -o loop"), and move mounting of usr.sqsh before the pivot_root.

> I have also had a reference to instead use initramfs but am reluctant to
> go this route until I understand it better, do you suggest any material
> to read?

This mail contains everything that one should know about initramfs.

BTW, the current LiveCD doesn't use squashfs, and its binary (because of 
historical reasons only, and I don't like this) initramfs is of absolutely 
no use for you.

-- 
Alexander E. Patrakov



More information about the livecd mailing list