Background

I just recently had to replace an older external USB hard drive connected to my Raspberry Pi (Model 3 B) with a new one. Out of the box, the new 3 TB drive came formatted with the exFAT file system.

Setting it up was easy enough and I had my music server (CherryMusic) and my Plex media server pointed at and reading the drive in no time.

I configured SAMBA next. I need to be able to copy files onto the drive from across the network, from Windows PCs. I had this setup with my previous NTFS drive so I assumed it would just work for the new drive.

No. Of course not. So I struggled and struggled with this for a few hours, until my Aha! moment.

Solution

I finally figured out that my entry in the Rasbpian OS’ /etc/fstab file entry for the external drive needed to be adjusted.

This version of that entry would allow me to read the files via Samba from other PCs but not to write to it:

/dev/sda1 /media/DRIVE exfat rw,exec 0 0

I had to add the ‘umask=0’ magic word to the options there to make it work, like this:

/dev/sda1 /media/DRIVE exfat rw,exec,umask=0 0 0

Explanation

ExFAT, which is patented by MicroSoft is a good file system for external drives (USB sticks, SDD and HDD USB drives, etc…). It is supported on Windows, Macs and Linux and it supports very large files and very large partitions, so millions of files is no problem. That’s good for a multi-terabyte drive and it’s useful in a multi-OS household like mine.

BUT! It does not support user or group access control lists like NTFS does. So, in linux (Raspbian in my case), you can’t use chown to change the owner or chmod to change the file permissions. When you try, you’ll see “That operation is not supported”.

What happened then when I use my original fstab entry to mount the drive without the umask part, was that the ‘root’ user and ‘root’ group owned the drive and all of the files and folders on it. And as I said, because of the exFAT file system, that can’t be changed.

So, all of this just led to this conclusion in my head: if I can’t change who owns the drive’s top level folder in linux, and I can’t change the permissions after it’s mounted, then I need to set these things as it’s being mounted – which is where we get back to the fstab entry.

In the fstab specs, for some file systems, you are allowed to set the umask option, to indicate how user permissions should be set. In my example above, adding “umask=0” tells the OS that all users are allowed to read and write and execute anything on the drive. If you use any other number, you’re saying which operations are prohibited (as opposed to allowed).

This Wikipedia page is very helpful on this topic: https://en.wikipedia.org/wiki/Umask

So, now with umask=0 in my /etc/fstab file, I can read and write files on that drive from my Windows PC.

I hope this helps someone else down the line.

: )