22

This is a strange problem: I dual boot Win7 (sda2) and Ubuntu (sda3) and wanted to use the FAT32 partition to share files across two OS' with the following partition table

Device      Boot    Start       End      Blocks     Id  System
/dev/sda1   *           1          13      102400    7  HPFS/NTFS
  Partition 1 does not end on cylinder boundary.
/dev/sda2              13        5737    45978624    7  HPFS/NTFS
/dev/sda3            5738       10600    39062047+  83  Linux
/dev/sda4           10601       19457    71143852+   5  Extended
/dev/sda5           10601       11208     4883728+  82  Linux swap / Solaris
/dev/sda6           11209       15033    30720000    b  W95 FAT32
/dev/sda7           15033       19457    35537920    7  HPFS/NTFS
  1. I followed a tutorial, issuing:
    sudo mkdir /media/FAT32
    sudo chmod 777 /media/FAT32
    sudo mount /dev/sda6/ /media/FAT32
    
  2. After I mounted /dev/sda6, I can only read but am unable to write to it.
    • I checked the directory permissions, which are drwxr-xr-x, but after I unmounted it, it becomes drwxrwxrwx and I can read and write to it.

I don't know where I've went wrong.

0

11 Answers 11

24

Try mounting with rw and specify the type:

mount -t vfat /dev/sda6 /media/FAT32 -o rw,uid=xxx,gid=xxx

where uid and gid are that of your user account.

6
  • The umask has effect when creating new files.
    – geek
    Dec 7, 2009 at 17:05
  • user and auto are options for the fstab entry; they aren't very useful on the commandline. Dec 7, 2009 at 19:03
  • yeah i just translated one of my fstab entries to a command line. Left in some bits that aren't useful but they aren't exactly harmful either.
    – user1931
    Dec 8, 2009 at 0:02
  • 7
    sudo mount -t vfat /dev/sda6 /media/FAT32 -o rw,uid=$(id -u),gid=$(id -g)
    – chefarov
    Dec 18, 2017 at 8:57
  • 1
    The files are still mounted under root and the permissions/ownership cannot be changed
    – Alecz
    May 9, 2022 at 14:18
3

It's important to repair/check the disk in Windows before using it on Linux, as, by default, FAT/NTFS drivers disable write if they find errors on the disk:

  1. Windows:
    Chkdsk D: /f 
    
  2. Linux:
    sudo mount -t vfat /dev/sdc1 /media/FAT32 -o rw,uid=$(id -u),gid=$(id -g)
    
2

For FAT filesystems, read/write availability is governed by the mount options.

Consult the manpage for mount and read about uid and gid mount options for FAT.

2

Have you tried writing to the files with a sudo command? That should work with your current setup.

To get file writes for your normal user working, you need to use the uid and gid options to mount, to set the owner of files on the partition to your current userID. You probably also want either umask or dmask and fmask options.

Your mount command would look like this:

sudo mount -t vfat /dev/sda6 /media/FAT32 -o uid=1000,gid=1000,umask=022
# assuming your user's UID is 1000, GID is 1000
# umask=022 sets permission mode 755 for all files on the partition
2

If you simply forget about command line and mount with Nautilus, it should set it as you want.

From the terminal, the permissions of the folder before mounting doesn't matter. It's the mount options that count. Try:

mount -t vfat /dev/sda6 /media/FAT32 -o rw,uid=xxx,gid=xxx,umask=133,dmask=022

This will set files to rw-r--r-- and folders to rwxr-xr-x.

If you want other user/group and permissions, for instance to copy files from fat32 to the ext4 partition with the desired attributes, better consult the mount manpage. Roughly you put on umask the opposite of what you would put on chmod.

1

I had exactly the same problem and the only thing that actually worked is:

sudo mount -t vfat  /dev/sda6 /media/FAT32 -o rw,umask=0000

See also that answer

3
  • I did this, the usb key is still write protected
    – Heetola
    Jan 6, 2015 at 12:40
  • Did you try chmod 777 /media/FAT32 ?
    – lauhub
    Jan 6, 2015 at 14:31
  • 1
    for some reason removing ",umask=0000" worked
    – Heetola
    Jan 6, 2015 at 15:32
0

You have the wrong order on the commands you want:

sudo mkdir /media/FAT32
sudo mount /dev/sda6 /media/FAT32
sudo chmod 777 /media/FAT32

What is happening is that /media/FAT32 represents different directories before and after the mount. Before it's the directory you made, and which you chmod'ed 777. After, it's the root directory of the filesystem in /dev/sda6.

1
  • Won't change it. FAT32 does not understand linux permissions, and the permissions are set by the mount. chmod will not overwrite it. You need to handle it at mounting, via UID, GID, UMASK, etc.
    – cde
    Mar 4, 2020 at 5:03
0

Without manually mounting, a fstab line does the trick:

UUID=1DD9-0D44 /media/exthd/TERABYTE_G  vfat      rw,noatime,uid=1000,gid=1000,user   0 0
  • uid,gid are of your user; /media/exthd/TERABYTE_G must be pre-created
  • If mount -a isn't applying properly to the new fstab line, reboot to resolve
0

Another option:

sudo mkdir /media/FAT32
sudo mount /dev/sda6 /media/FAT32 -t vfat -o rw
2
  • 1
    Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Mar 6, 2023 at 20:07
  • To avoid the answer being deleted, please edit your question and give an explanation on the options used ans cite a reference on them. Mar 6, 2023 at 20:30
0

This worked for me.

  • Disks → Select the FAT32 Partition → Edit Mount Options
  • Add these two dmask=000 fmask=111
  • Check the image for reference:image link
1
  • Welcome, please ensure that the answer is valid without a link. Using pinterest for the image sucks. Please try another platform May 7, 2023 at 8:13
-1

Sometimes I lose the Windows disk from Linux and I solve using mount -o force:

sudo mount -t ntfs-3g /dev/sda1 /media/win -o force

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .