squashfs-tools icon indicating copy to clipboard operation
squashfs-tools copied to clipboard

Feature request: Allow unsquashfs to unpack over pre-mounted directories

Open klark973 opened this issue 11 months ago • 0 comments

Hi!

My comments in addition to PR #257...

MS Windows WIM/ESD archive is very similar to squashfs and how can it be used? Like to squashfs, but you can also choose one profile of the MS Windows to install: Home, Professional, Ultimate, etc. It's possible because deduplication is used. However in MS Windows the source WIN/ESD archive unpacked to only the one system drive, and we have no problems with hard links.

How we can replicate this in Linux installer that unpacks a ready-to-use filesystem into several different pre-mounted directories, like /var, /usr, /home, etc...? Currently this is only possible when using unsquashfs with the --force option, and the source archive must be created by mksquashfs with the -no-hardlinks option, otherwise we might run into this problem:

FATAL ERROR: create_inode: failed to create hardlink, because Invalid cross-device link

This is because in some cases rootfs can use hard links, for example between files in the /etc and /var/lib directories. When we create an archive, we do not know anything about how and where it will be unpacked, we create a single archive of a complete rootfs. Mksqushfs with the -no-hardlinks option solves this problem, but packaging with this option loses all the benefits of deduplication. So on Windows we can save space, but on Linux we can't.

Let's say the installer pre-creates mount points with different devices:

  • /mnt/destination
  • /mnt/destination/var/www
  • /mnt/destination/var/log

With the proposed patch, unpacking is possible without additional options, and to return the default behavior, you should use the -one-file-system option, by analogy with other utilities. At the same time, the archive could contain different server deployment profiles: minimal, web server, etc...

klark973 avatar Jul 05 '23 22:07 klark973