Mounting and modifying a loopback file without sudo/root, is it possible?

You want libguestfs. You can use it via guestfish or guestmount, or use the library directly through its C interface or any of the many language bindings, like Python.


Concerning this one the following comes into my mind.

You can add a line to your /etc/fstab for the device you want to mount as a user with normal privileges.

An example line would look like

/dev/mydevice    /mnt/directory    auto    rw,user    0    0

With this line a normal user can mount mydevice to /mnt/directory and additionally can read from- and write to the device. You only have to invoke

mount mydevice

or

mount /mnt/directory

For an excellent explanation of the syntax of/etc/fstab you should look at

www.tuxfiles.org/linuxhelp/fstab.html


Since the raspberry is an usb device you can achieve this more elegantly with udev by adding a specific udev-rule (auto-mounting etc.). In this case let me now if you want to have a further explanation.


You need superuser privileges to be able to mount. But those could be given to you by setuid helper commands like sudo, mount or fusermount. In /etc/fstab, and admin can grant some mere users to mount specific FS. Some users can be allowed to mount filesystems via fuse (for instance, if the FS is ext, you may be able to use fuseext.

Or maybe you can do without mounting, by using applications that can write inside a filesystem. For instance, debugfs can write to a ext fs image (create dirs, files, change ownership...), debugfs can be scripted easily You can also use qemu to run a Linux kernel and associated commands to write to that FS.