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.

4
  • What flags are you using for mksquashfs? The flags -all-root, -force-uid, -force-gid may solve your problem.
    – Kapil
    Commented Jun 10, 2021 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
    Commented Jun 10, 2021 at 10:44
  • I'm curious why not use tar to backup folders? Does squashfs give you something over tar?
    – Donn Lee
    Commented May 5, 2023 at 17:20
  • @DonnLee various compression formats, ability to mount as a loopback device etc
    – Mr. T
    Commented May 9, 2023 at 21:59

1 Answer 1

-1

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

2
  • This still results in permissions problems unfortunately
    – Mr. T
    Commented Dec 11, 2019 at 21:54
  • This answer has nothing to do with the question. File images are always mounted with by loop, and it doesn't affect permissions.
    – user10489
    Commented May 17 at 23:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .