You're either talking about a FUSE
filesystem (filesystem in userspace - Linus calls them toys) or a custom compiled kernel OR squashfs. Squash
is not exactly as you describe - you cannot simply mount a tarball for instance - not with the kernel supported VFS, anyway - but you can certainly mksquash
any number of files or directories and mount the resulting archive read-only. You have the choice of xz, lzma, or gz
compression. Squash
is used all of the time - if you've ever used a live linux image chances are very good it was squashed.
I'll tell you one trick I use with squashfs.
I like to create a btrfs
image file and use btrfstune -S 1
to make it a seed
volume. I then put that image in a squashfs
archive. From there I can mount -o loop
the image.sfs
and from within that mount -o loop
the btrfs
image.
The btrfs seed
volume will initially mount as read-only
- which is to be expected considering that it's contained within a squashed
loop mount. But if I then do:
GB_tmp_loop=$(
fallocate -l $((1024*1024*1024)) /tmp/1GB_tmp.img &&
losetup -f --show $_
)
btrfs device add "$GB_tmp_loop" "${btrfs_seed=/path/to/btrfs_image_mount}"
umount "$btrfs_seed"
mount -o compress-force=lzo,autodefrag,rw "$GB_tmp_loop" "$btrfs_seed"
Suddenly I'm taking advantage of btrfs
s copy-on-write
functionality and automatic write compression AND squashfs
s superior compression all in RAM AND in-kernel.