Allow a filesystem in Ubuntu to be mounted by users
November 8, 2008 8:29 AM   Subscribe

How do you create a user-mountable filesystem in Ubuntu Eee 8.04.1?

I have an Asus Eee PC 4G laptop running Ubuntu Eee 8.04.1 as its operating system, which is a customized distro of Ubuntu 8.04 made for the Eee PC. Since I bought a new MacBook recently, I'm currently setting up this computer to be used as a small home file (Samba), print (CUPS), and Web (Apache) server.

An SD card is in the computer's card slot and an external hard drive is connected via USB. Both have a VFAT filesystem. I want both those filesystems to be writable, mountable, and unmountable by all users in the computer (not just by root or the user who mounts them).

The filesystem on the SD card is labelled "SDCARD" and the one on the HDD is labelled "HARDDISK". I already created empty directories in /mnt, both with mode 777, and modified the /etc/fstab file to have the following:

LABEL=SDCARD /mnt/sdc auto users,auto,exec,rw,umask=111,dmask=000 0 0
LABEL=HARDDISK /mnt/hdd auto users,auto,exec,rw,umask=111,dmask=000 0 0

I tried both the "user" and "users" option in the fstab file, but every time I try to mount one of the filesystems mentioned above using a regular user, I get the following message:

mount: must be superuser to use mount

It works fine when I mount using the "sudo" command or the "root" account. Note that I can't simply use symlinks to point to the filesystems in /media, since I need to override the mount options to allow all users to write on the filesystems. I also think modifying udev options just for this may be overkill and time-consuming.

Besides, with the "user" or "users" in the fstab, why can't I still mount using a normal user? Can anyone help me with this?

Thanks in advance!
posted by remi to Computers & Internet (9 answers total) 1 user marked this as a favorite
I've never gotten the hang of fstab, really. The thing to do on a modern Linux seems to be to use pmount, which makes the device user-mountable by default. You'll need to be part of the plugdev group, but it's a lot simpler than mucking about in fstab. The man pages for this are pretty readable.
posted by spaceman_spiff at 8:34 AM on November 8, 2008

Oh, and while I was told it's "the thing to do on a modern Linux", I'm currently doing this on Ubuntu 8.04, so I'm not being quite as vague and randomly hopeful as the above comment may seem.
posted by spaceman_spiff at 8:35 AM on November 8, 2008

Not sure it this is exactly what you need, but maybe PySDM would help? There's a guide here.
posted by le morte de bea arthur at 8:36 AM on November 8, 2008

Best answer: There's a few extra complications due to mounting a vfat partition; the ownership needs to be forced at mount because vfat does not support linux user permissions. If they're going to be used exclusively on the ubuntu box, you may wish to use a native linux fs like ext3 or jfs.

Assuming you're sticking with vfat though, and want to use fstab instead of the built in removable media mounter in ubuntu ("pmount /dev/sdc1 sdc" will mount it in /media/sdc as a user), the following syntax should do the trick (assuming your labels are correct and all on one line)

LABEL=SDCARD /mnt/sdc vfat auto,user,sync,exec,uid=1000,gid=1000,dmask=007,fmask=117 0 0

The directories will have executable permissions and files with read write for user and group, with uid and gid being the user id and group id of the owner of the files at mount

Also, you may need to set the mount command with the suid flag; it should be already, but
sudo chmod +s /bin/mount
should do the trick.
posted by ArkhanJG at 9:41 AM on November 8, 2008

I assumed you wanted write permission to be governed by the group membership, btw - if you want to open permission to all accounts on the system regardless (a bit of a security risk, as that includes guest and server accounts too), use dmask=000,fmask=111
posted by ArkhanJG at 9:43 AM on November 8, 2008

Lastly, this is the definitive guide to fstab on ubuntu. Happy hunting!
posted by ArkhanJG at 9:47 AM on November 8, 2008

The users or owner options should be enough for what you want to do --- my vfat media mount happily with just these (though I'm not on Ubuntu). Some thoughts:

- You mentioned something about the /media directory, do you have any other entries in fstab for sd* devices? This may be screwing things up, depending on how you invoke mount.

- Who owns the devide files /dev/sd* ? Do you have rw access? You may need to add yourself
to the disk group or something like this.

- Why are you trying to mount the whole disk ? Shouldn't you be mounting partitions, i.e. /dev/sda1 and the like?

- Have you tried specifying the filesystem in fstab, i.e. vfat instead of auto?

Finally, I think ArkhanJG's pmount suggestion is probably the right way to go here, though I don't know the details: if your distribution supplies a way to do something, rolling your own will usually be suboptimal.
posted by ghost of a past number at 10:44 AM on November 8, 2008

Why not just add all users to the sudoers list and give them access to /sbin/mount and /sbin/umount?
posted by mad bomber what bombs at midnight at 12:30 PM on November 8, 2008

Response by poster: Thanks for the quick answers, everyone. I marked the comment that fixed my problem immediately as the best answer, but there are some options other mentioned I am considering.

The problem was gone, but I was starting to have problems with "insufficient permission" problems when I was moving files from Mac OS X 10.5.5 to the shared VFAT hard drive on my Ubuntu server. This is caused by resource fork files (files starting with "._", for example) as it was also happening when mounting directories from Ubuntu to Mac OS using MacFUSE and sshfs. For this reason, since I probably will not use the hard drive directly on other computers, I formatted it to ext3. This fixed the problem (except if there's a ._.DS_Store file).

I will take a look at PySDM. I already installed it and that looks like a great GUI program to manage your udev and fstab files.

Again, thanks a lot!
posted by remi at 10:37 AM on November 10, 2008

« Older Seeking Web-based system for managing course...   |   The best looking bag, if not body, at the gym. Newer »
This thread is closed to new comments.