Linux, fat32 and etc/fstab

39,011

Solution 1

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.

Solution 2

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:
39,011

Related videos on Youtube

Lee
Author by

Lee

Updated on September 18, 2022

Comments

  • Lee
    Lee over 1 year

    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.

  • Reiner Rottmann
    Reiner Rottmann about 12 years
    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?
  • Reiner Rottmann
    Reiner Rottmann about 12 years
    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.
  • Reiner Rottmann
    Reiner Rottmann about 12 years
    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?
  • Reiner Rottmann
    Reiner Rottmann about 12 years
    are you a sudo user. Does sudo mount -a work correctly? if not then add the ,user option as suggested by Jonathan Callen.
  • Lee
    Lee about 12 years
    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
    Lee about 12 years
    I added the user part and that worked ok
  • Lee
    Lee about 12 years
    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
  • Russell Hart
    Russell Hart about 12 years
    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