OrangeJacketGuy
Posts: 2
Joined: Mon Jul 26, 2021 5:21 pm

Share removable media

Mon Jul 26, 2021 5:56 pm

Greetings,

I tried something a bit more ambitious in which a Zero W would automatically share via SMB any removable media I'd plug into the hub that it's using, and from there be able to add, remove, and edit files. I got as far as an unreadable share.
Following different forum postings and for similar projects I then tried with a fresh install to manually mount them in a directory that I configured in /etc/samba/smb.conf where I ran into all manner of permissions issues. Whenever I'd try to fix those via chmod and/or chown, there either wouldn't be a difference or the operation wouldn't be permitted. I got as far as being able to see all files, but no ability to delete or make new ones.
Can someone point me to a resource that can help me with this?

LTolledo
Posts: 5793
Joined: Sat Mar 17, 2018 7:29 am
Location: Anime Heartland

Re: Share removable media

Mon Jul 26, 2021 10:17 pm

can you show us how you are mounting those "removable media"

is it via /etc/fstab? (post the contents)
or via something else (post that method)

is it only one media, or as many as possible?
"Don't come to me with 'issues' for I don't know how to deal with those
Come to me with 'problems' and I'll help you find solutions"

Some people be like:
"Help me! Am drowning! But dont you dare touch me nor come near me!"

User avatar
thagrol
Posts: 5530
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Share removable media

Mon Jul 26, 2021 10:24 pm

Sounds like an issue with mount options and file systems.

Non linux file systems (FAT, NTFS, etc) do not support file ownership and permissions so they're set at mmount time and in the mount options.

Read up on linux ownership and permissions, then read the output from

Code: Select all

man mount
See also my guide to fstab in the beginner's section.
I'm a volunteer. Take me for granted or abuse my support and I will walk away

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

OrangeJacketGuy
Posts: 2
Joined: Mon Jul 26, 2021 5:21 pm

Re: Share removable media

Wed Jul 28, 2021 12:11 am

Ok, so since I started this topic I tried again with a fresh image. I installed samba, samba-common-bin, smbclient, and cifs-utils. The defaults worked fine.

I then plugged in a hard disk with FAT32 on it, then ran the following:

Code: Select all

sudo mount -t vfat /dev/sdb2 /home/pi/BTNshare/
I also restarted smbd via the following:

Code: Select all

sudo systemctl restart smbd
Via ssh I could touch, remove, rename, etc., but I couldn't do anything but view.
I added the following to the end of /etc/samba/smb.conf:

Code: Select all

[EXTERNAL]
comment = External media
browseable = yes
path = /home/pi/BTNshare
writeable = yes
create mask = 0777
directory mask = 0777
browseable = Yes
public = yes
Then I couldn't even view the "EXTERNAL" folder.

Obviously this is PEBKAC. Where did I go wrong, and what should I be doing better in the future?
Attachments
Screen Shot 2021-07-27 at 6.09.31 PM.png
Screen Shot 2021-07-27 at 6.09.31 PM.png (10.78 KiB) Viewed 251 times

User avatar
thagrol
Posts: 5530
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Share removable media

Wed Jul 28, 2021 12:22 pm

I'm guessing you didn't follow the advice I gave above.
OrangeJacketGuy wrote:
Wed Jul 28, 2021 12:11 am
Ok, so since I started this topic I tried again with a fresh image. I installed samba, samba-common-bin, smbclient, and cifs-utils. The defaults worked fine.

I then plugged in a hard disk with FAT32 on it, then ran the following:

Code: Select all

sudo mount -t vfat /dev/sdb2 /home/pi/BTNshare/
I also restarted smbd via the following:

Code: Select all

sudo systemctl restart smbd
Via ssh I could touch, remove, rename, etc., but I couldn't do anything but view.
That's a little confusing. Do you mean you tried touch etc as a normal user and were unable to make changes?

Given that mount command, I'd expect read only access to all non root users. FAT doesn't support permissions or ownership so they're set at mount time and immutable. The default is owner and group of root, rwx for owner, r-x for group and other.

Try this mount command instead:

Code: Select all

sudo mount -t vfat -oumask=000 /dev/sdb2 /home/pi/BTNshare
I added the following to the end of /etc/samba/smb.conf:

Code: Select all

[EXTERNAL]
comment = External media
browseable = yes
path = /home/pi/BTNshare
writeable = yes
create mask = 0777
directory mask = 0777
browseable = Yes
public = yes
Then I couldn't even view the "EXTERNAL" folder.
1. What, exactly, do you mean by "view"?
2. Did you restart smbd before or after adding that to your smb.conf?
I'm a volunteer. Take me for granted or abuse my support and I will walk away

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

Return to “Networking and servers”