Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm trying to adapt a tutorial into an easy to use script http://qt-project.org/wiki/RaspberryPi_Beginners_guide.

I'm trying to reduce the need for sudo/root as much as possible (preferably, only for the final dd step).

My questions are:

  1. Can I mount the ext4 file system without sudo/root privileges in any way?

  2. Can I mount it in a way so that users/groups on the FS are ignored in some way (so I can run make install without sudo)?

The Filesystem is currently mounted loopback from an offset of a file (i.e. -o loop,offset=62914560).

This file is the image that will be copied onto the SD card used to boot the Raspberry Pi.

share|improve this question
add comment

3 Answers

up vote 4 down vote accepted

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.

share|improve this answer
    
While this seems to be the best answer, I think it's a bit overkill for this script. E.g. you need to manually change permissions on files in /boot for it to work properly on Ubuntu thanks to this. I think using sudo to mount and install is going to be the easier, and safer way to go. –  Keyz182 Aug 28 '12 at 14:35
add comment

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.

share|improve this answer
    
Good advice, but unfortunately I don't think it's helpful in my case. I'm trying to adapt the tutorial into a distributable script for beginners to get an environment set up easily. I don't think I should be changing their fstab for that. Also, going to add more info to the question. –  Keyz182 Aug 27 '12 at 10:46
3  
maybe mountlo is interesting for your purpose!? mountlo can mount loopback devices from user space, at least this is mentioned in the description. You could add it to your distribution as a binary (or compile it on the fly), so your script can invoke it easily!? –  user1146332 Aug 27 '12 at 11:15
add comment

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.

share|improve this answer
    
+1 for fuseext.... –  totti Jan 1 at 9:38
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.