5

I frequently use mksquashfs to make backups of folders on various systems. Sometimes this results in files which cannot be read by any users upon mounting. If I do a sudo mount file.squashfs /to/mountpoint and then try to ls the directory as root or with sudo I get a "permission denied" error. Viewing the properties of the mountpoint in Thunar results in it showing the owner as nobody. Applying a chmod also doesn't work as squashfs is a read-only filesystem.

How can I force mount to mount squashfs in a permissions-agnostic way or with the correct permissions? I don't actually need permissions for this use case, it may as well be world-readable.

Edit: I never found a full solution for opening "unreadable by root due to permissions" squashfs files, but I did find a way to prevent it from happening again. This works cross-system and cross-platform. Adding -all-root makes all files in the archive owned by root. Since permissions aren't important for these backups it is a clunky but effective fix. Still curious to see if somebody has a better one.

Mr. T
  • 109
  • 2
  • 10
  • What flags are you using for `mksquashfs`? The flags `-all-root`, `-force-uid`, `-force-gid` may solve your problem. – Kapil Jun 10 '21 at 10:36
  • 1
    Also note that the newer tools `squashfs-tools-ng` contain a program called `sqfs2tar` that will convert the filesystem into a `tar` archive and that may help. – Kapil Jun 10 '21 at 10:44
  • I'm curious why not use `tar` to backup folders? Does squashfs give you something over `tar`? – Donn Lee May 05 '23 at 17:20
  • @DonnLee various compression formats, ability to mount as a loopback device etc – Mr. T May 09 '23 at 21:59

1 Answers1

0

just append it with -o loop mount /tmp/file.sqsh /mnt/test -t squashfs -o loop

Just to be sage I use -t but you can skip if you choose.

Why you need loop device?

mounting file system is expected on blockdevice.

like when you attach disk or usb key. it will create a node . all operations are done on this node.

but when you try using a file instead of device. you need to use loop device.

which will use pseudo-device tie with the file.

Note while mounting iso as well we need to use -o loop

Devidas
  • 497
  • 2
  • 7