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 mounted a FAT32 drive onto my Linux computer using the following terminal command:

> sudo mount /dev/sdb1 /media/exampleFolderName -o dmask=000, fmask=111

I did this so I could share / edit the files over a network connection. Unfortunately Linux doesn't support per file permissions in FAT32 format, so this sets the entire drive in the right permissions whilst it's connected.

If I understand mount correctly, I'll have to do this every time I plug the drive in, which I don't want to do. I've heard about:

/etc/fstab

So my question - how do I turn the above mount command into an fstab entry? If anyone could also explain what dmask and fmask mean, that would be appreciated.

share|improve this question
add comment

migrated from stackoverflow.com Apr 22 '12 at 18:08

This question came from our site for professional and enthusiast programmers.

2 Answers

up vote 1 down vote accepted

You probably want to add a line like

/dev/sdb1 /media/drive1 vfat dmask=000,fmask=0111,user 0 0

to /etc/fstab. The additional ,user in the options field allows any user to mount this filesystem, not just root.

share|improve this answer
    
I added this to my fstab: UUID=XXX-XXX /media/drive1 vfat dmask=000,fmask=0111,user 0 0. This mounts and I can create / delete files over Samba (using a Mac), however I can't rewrite files (i.e. simple text file). I've shared a folder on my Linux's ext3 partition over Samba - I can re-save files here, but not on the FAT32 drive. Any ideas what I'm missing? I'm logging in as 'Guest' as I could never get the username / password part working. However I don't this is the issue as I can write over files on the ext3 extension ok. Any tips would be appreciated - must be close now! Thanks, Lee. –  Lee Apr 22 '12 at 19:58
    
Right - I've figured it out. For anyone who gets the same problem, it might be program specific. For example, if I edit the text file using vi or gedit on my Mac, it's fine. Text Edit won't let me do it - so they must handle response codes (etc) differently. If I do a cp in the terminal, it copies ok, but I get the message fchmod failed: Permission denied - so Text Edit might be having a similar problem. Basically problem is all fixed for now though! Cheers guys –  Lee Apr 22 '12 at 20:24
    
This sounds like you have created a new file which has permissions for guest but the existing files do not. run sudo chmod -R o+w /path/to/file –  Russell Hart Apr 22 '12 at 20:25
add comment

dmask and fmask is the permissions for directories and files respectively. It is an octal number. And denotes read, write and execute permissions for Owner, Group and Other users.

fstab:

/dev/sdb1 /media/exampleFolderName vfat dmask=000,fmask=111 0 0

When you say plug the drive in, an external drive e.g USB should automount.

share|improve this answer
    
Hi - thanks for the answer that makes sense. Yes it's an external drive - I'm trying to make it automount with these permissions using the above entry in fstab as it currently automounts with the wrong permissions. Is fstab the wrong way to go about this? –  Lee Apr 22 '12 at 16:59
    
fstab should work fine for this, if it is just for this drive. I recommend getting the uuid and mounting with that instead of /dev/sdb1 because it may change. –  Russell Hart Apr 22 '12 at 17:13
    
Hey Russell - cool I've just been looking at that. I added a new folder: /media/drive1. I then added UDID=XXXX-XXXX /media/drive1 vfat dmask=000,fmask=111 0 0 to /etc/fstab, but on plugging the drive in, I get the error message "Cannot mount volume - you are not privileged to mount the volume 'volumeName'". Having a look on this thread "ubuntuforums.org/showthread.php?t=1927885";, but still getting the error. Is it the folder's permissions? –  Lee Apr 22 '12 at 17:21
    
are you a sudo user. Does sudo mount -a work correctly? if not then add the ,user option as suggested by Jonathan Callen. –  Russell Hart Apr 22 '12 at 18:00
    
I added the user part and that worked ok –  Lee Apr 22 '12 at 20:06
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.