I setup a loopback device
Unless you use a really ancient kernel, this is longer necessary - the normal mount process implicitly generates a loop device.
The device is OK, but only writable for root.
Permissions on the loop device do not influence permissions on the mounted filesystem. Nor does it influence who can actually mount a file.
Requiring root to create the device is not a problem, but it must be writable for normal users after mounted.
The filesystem permissions are derived from the actual data in what you mount. Some filesystems (e.g. FAT) have options where you can attach unix permissions. Other filesystem (e.g. ext) don't.
I want to write to the file system contained in the device
Then you are not going to solve this by using a loop device. (Also, please read up on XY questions. Your X is "All users should be able to read from the filesystem", your Y is "I think I need a loop device", unsurprisingly that does not work, and you only ask about Y, instead of starting out asking about X).
As written in the comments, you can chown/chmod
(as root) after mounting to let all users read it, changing the contents of the filesystem. That's the simplest solution.
There is no easy solution for "I want to mount an ext4 filesystem, but transparently overwrite permissions on everything on mount". At least none I know of.
From man mount
:
THE LOOP DEVICE
One further possible type is a mount via the loop device. [...] If no explicit loop device is mentioned (but just an option `-o loop' is given), then mount will try to find some unused loop device and use that [...]
The mount command automatically creates a loop device from a regular file if a filesystem type is not specified or the filesystem is known for libblkid, for example:
mount /tmp/disk.img /mnt
mount -t ext4 /tmp/disk.img /mnt
This type of mount knows about three options, namely loop
, offset
and sizelimit
, that are really options to losetup(8).
(These options can be used in addition to those specific to the filesystem type.)
chown
andchmod
. – Frédéric Loyer Nov 15 '21 at 09:49chown/chmod
/dev/loop*
Writable FS after mounting?
– Artem S. Tashkinov Nov 15 '21 at 09:58chown/chmod
/mnt/mountpoint
or usinguid/fmask/dmask
in case your FS is not "unix".