3

If we are using initrd for, say in live usb, why would we also need squashfs?

2 Answers2

2

Initrd is deprecated and replaced by Initramfs (and to some extent upstart).

What is the difference between initrd and initramfs?

The initramfs is more a part of the booting process and is a minimal file system used to bootstrap the kernel and initialize your hardware.

suqashfs is a compression tool and takes a large (5 Gb) file system and compresses it into a much smaller size, but it is ro.

squashfs is thus used for the entire file system, / and all the binaries and libs necessary to be Ubuntu live.

See also:

https://help.ubuntu.com/community/LiveCDCustomizationFromScratch

https://wiki.ubuntu.com/Initramfs

Initramfs is used as the first root filesystem that your machine has access to. It is used for mounting the real rootfs which has all your data. The initramfs carries the modules needed for mounting your rootfs.

Here is the initramfs I built http://blog.bodhizazen.com/linux/initramfs/

And

http://squashfs.sourceforge.net/

Squashfs is a compressed read-only filesystem for Linux. Squashfs is intended for general read-only filesystem use, for archival use (i.e. in cases where a .tar.gz file may be used), and in constrained block device/memory systems (e.g. embedded systems) where low overhead is needed.

Panther
  • 104,528
1

squashfs vs compressed initramfs

It is also interesting to note that initramfs can also be compressed: https://unix.stackexchange.com/questions/2221/can-the-initramfs-image-use-a-compression-format-other-than-gzip/429880#429880

I think that the advantage of squashfs is that you don't have to do a full decompression on every boot for a huge image, which would be slow.

This is what initramfs does, as it is just a zipped .cpio.

Instead, squashfs allows you to only decompresses files on the fly as you go, since it must separately compress individual files and disk data structures.