0

I am compelled to add a new thread as a million people have some other variant of my problem but I cannot seem to find help in their threads. I have tried a dozen things and more, but nothing works.

My setup: Converted a very old T43 Thinkpad to a home server by installing Ubuntu 16.04 (it seemed to be the only version I could get with 32-bit support; if anyone knows how to get latest with 32-bit please shout).

I connected a 1 Terrabyte WD external hard drive and mounted it successfully under /media/WD-External. Formatted as FAT32. I want to explore the possibility of being able to read it from a networked Mac as well. I have also added it to the fstab file so that it mounts automatically at boot via the line: /dev/sdb2 /media/WD-External vfat defaults 0 2

My smb.conf file has this at the end:

[WD-External]
        comment = WD 1TB external HDD
        valid users = <my username here>
        path = /media/WD-External
        available = yes
        read only = no
        browsable = yes
        public = yes
        writable = yes
        write list = <my username here>

I can successfully connect to this drive from a networked Windows 10 computer. I can add it as a network location. I can add as a mapped drive with an assigned letter as well etc. I can browse its contents. I can copy FROM it and drag and drop on my Win10 desktop etc. For the life of me I CANNOT write to it.

When I type: ls -l /media/WD-External the permissions are only set for "root". I ran the chmod command: chmod -R 777 (or other variations here but always starting with a 7) /media/WD-External. The command finishes successfully (silently). However, the ls -l command still shows that root is the only user that can write.

I have also tried adding lines in the smb.conf file directly such as:

create mask = 770
directory mask = 770

but that didn't really work.

Now I have also started exploring the notation with FOUR numbers, not three, but when I do something like chmod 7775 or whatever (while being verbose with -v) I see that each action fails with "Operation not permitted failed to change mode ....etc"

What's going on here? Can anyone suggest a clean way to configure this so that Windows can also write on this drive? Is it the format that's the issue? NTFS perhaps better? Thanks in advance

2 Answers2

2

So makes me wonder if that was the issue all along, and this could have worked with Fat32 all along? Can anyone clarify?

The reason you could not write to the original fat32 based share was not about samba it was about how you mounted the partition.

By default this will mount with root as owner and writeable - everyone else will have read only access. chown and chmod will do nothing on a fat32 or ntfs partition and using create and directory masks in the share definition will not work either on those filesystems.

You needed to specify the permissions required in the fstab statement itself. The permissions on the partition must always be greater than or equal to the permissions required by samba so the fstab line for the partition could have looked like this - where everyone has r/w access then use the samba share definition as the gatekeeper ( valid users ):

/dev/sdb2 /media/WD-External vfat defaults,umask=000 0 2

OR, you could have replaced root as owner with yourself:

/dev/sdb2 /media/WD-External vfat defaults,uid=1000 0 2

OR, you could have done a hybrid making it accessible, readable and writeable only to you:

/dev/sdb2 /media/WD-External vfat defaults,uid=1000,umask=077 0 2

Side Note: In the future it would be better if you use the UUID number ( as in UUID=xxxx-yyyy ) of the partition rather than something like /dev/sdb2. You can find the uuid number by running this command: sudo blkid

Your Followup Questions

-- No, you don't have to add back the "defaults" option. I was just editing your original to show what could be added.

-- Yes, 0027 as a umask would work as well

-- there are 3 ways to specify a device:

/dev/sdxy = this is the way it used to be done but things have grown more complicated over the years and you run the rick that what may be /dev/sda1 on one boot could very well be /dev/sdb1 on another because the system will recognize the second hard drive first when it boots.

UUID number = unique to that partition so it's more reliable. And the pattern changes based on the filesystem. So a fat32 has a xxxx-xxxx pattern, an ntfs has a 16 character pattern, and an ext4 has a 36 character pattern.

LABEL = The Label on that partition - if it has a label.

Morbius1
  • 8,437
0

I've been having similar problems with giving write permissions to external exFAT drives via SMB for months now and I think I finally had a breakthrough, thanks to the answer from @Morbius1.

Solution that worked for me:

  1. Specify write list = root and writeable = yes in /etc/samba/smb.conf. It has to be the root user, as @Morbius1 stated, that one cannot chown the permissions on exFAT filesystems to another user other than root. As it was recommended to create a dedicated user for Samba, I first tried adding a new user pi which wouldn't work, as I couldn't chown the ownership of exFAT files.

  2. Make sure the mount-point has a different name than the Samba share name (e.g. if the mountpoint is /mnt/Media you cannot give the share the name [Media]).

  3. Give the root user a Samba password with smbpasswd -a root.

  4. Restart the Samba service service smbd restart.

  5. Reconnect to your smb and login as root with the password given in 3.

Hope it helps