Bosse_B
Posts: 836
Joined: Thu Jan 30, 2014 9:53 am

fstab dilemma...

Wed May 29, 2019 12:40 pm

I am using an RPi2B as media center through OSMC/KODI.
This RPi has a 1TB USB disk connected as media storage and it was mounted whenever the RPi boots.
The drive was also shared on the network via a samba share.

After I did an OSMC update yesterday and got KODI 18 instead of 16 or 17 I had before the USB drive does not connect on boot anymore and the samba share seems to have disappeared. :(

So now I am working on restoring these two points but I am really confused about all I see on the net when I google so I seek advice here....

1. Automatic mount of the USB drive
I believe that the mount should be entered into /etc/fstab in order to happen on a reboot, right?
Here is the current fstab content:

Code: Select all

/dev/mmcblk0p1  /boot    vfat     defaults,noatime,noauto,x-systemd.automount    0   0
I have checked that the USDB drive is available using this command:

Code: Select all

sudo blkid
/dev/sda1: LABEL="MEDIADRIVE" UUID="EE78237678233D29" TYPE="ntfs" PARTUUID="81375152-01"
I have created a mount point "mediadrive" as follows:

Code: Select all

 ls -la /mnt/
total 12
drwxr-xr-x  3 root root 4096 May 29 01:46 .
drwxr-xr-x 23 root root 4096 Jun 16  2018 ..
drwxrwxrwx  1 root root 4096 Jun  2  2018 mediadrive
Using this command I am able to manually attach the drive:

Code: Select all

sudo mount /dev/sda1 /mnt/mediadrive
Now, in order to make this happen on boot I have googled a possible fstab command as follows:

Code: Select all

UUID=EE78237678233D29 /mnt/mediadrive ntfs defaults,auto,umask=000,users,rw,nofail 0 0
# or possibly instead of "users":
UUID=EE78237678233D29 /mnt/mediadrive ntfs defaults,auto,umask=000,uid=1000,gid=1000,rw,nofail 0 0
But the parameters for this line vary a lot when I google and it is also stated that if I make any errors here the RPi may not even boot.
So could you please verify if the line above is correct and also explain what the parameters mean:
umask: I have seen many different values used for this, what does it do?
users: Here I have instead seen uid=pi,gid=pi or uid=1000,gid=1000 What is the correct setting (user pi does not exist on OSMC; the default user is osmc)
0 0: The ending two zeros also confuse me, what purpose do they serve?

2. Automatic sharing of the USB drive via samba
Once the above is done I would like to restore my samba share of the mounted USB drive.
Samba service is installed and running, but it is not correctly configured as far as I can see.
What are the steps to take in order to share the /mnt/mediadrive as a share MEDIADRIVE with rw permissions for user osmc?
I now think that rather than configuring in /etc/samba/smb.conf one should use the linked files for customized setup, especially of the shares.
I.e. smb-local.conf and smb-shares.conf, which are linked to inside the main smb.conf file.
This is the current content of smb.conf:

Code: Select all

[global]

# If you require a fully custom smb.conf create smb-local.conf instead of editing smb.conf so your
# configuration will not be overwritten by samba upgrades. You can use smb.conf as a template by
# copying it to smb-local.conf then removing the config file line below in the new file. If you only
# need to add some additional shares see smb-shares.conf below for a simpler way to do this.

    config file = /etc/samba/smb-local.conf

    workgroup = WORKGROUP
    security=user
    follow symlinks = yes
    wide links = no
    unix extensions = no
    lock directory = /var/cache/samba
    load printers = no
    printing = bsd
    printcap name = /dev/null
    disable spoolss = yes
    log level = 1
    map to guest = bad user
#   usershare template share = automount template

# Automount template disabled to work around a samba bug causing crashes accessing external drives.

    read raw = Yes
    write raw = Yes
    strict locking = no
    min receivefile size = 16384
    use sendfile = true
    aio read size = 2048
    aio write size = 2048
    socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=131072 SO_SNDBUF=131072

[osmc]
    browsable = yes
    read only = no
    valid users = osmc
    path = /home/osmc
    comment = OSMC Home Directory

[automount template]
    browseable = yes
    -valid = no
    valid users = osmc
    path = %P
    hide files = /$RECYCLE.BIN/System Volume Information/desktop.ini/thumbs.db/

# Add custom shares in smb-shares.conf instead of editing smb.conf so they will not be
# overwritten by samba updates. You can only add new shares to smb-shares.conf, not change
# the default shares or global options. If you need full control see smb-local.conf above.

include = /etc/samba/smb-shares.conf
I think I need to change the workgroup name in order to match what I have on my laptop, but what else is there to do?
I will add this into a new file smb-shares.conf:

Code: Select all

[mediadrive]
    browseable = yes
    read only = no
    valid users = osmc
    path = /mnt/mediadrive
    comment = Media root Directory
Note that smb-shares.conf and smb-local.conf do not yet exist on the RPi.
Since the only thing I really need to change in the main conf file is the workgroup name I wonder how that would look in a smb-local.conf file?
Bo Berglund
Sweden

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

Re: fstab dilemma...

Wed May 29, 2019 2:13 pm

for starters, the ownership of the media drive should not be root

below is an example of a fstab entry that works on the RPiNAS drive

Code: Select all

UUID=01D4073FC6EE0A10 /mnt/USB1TB ntfs-3g permissions,noatime,rw,nofail 0 0
"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!"

Bosse_B
Posts: 836
Joined: Thu Jan 30, 2014 9:53 am

Re: fstab dilemma...

Sat Jun 01, 2019 7:52 pm

It seems like the ownership of the /mnt/mediadrive directory does not matter.
If the setting in fstab is rw and "readonly = no" in the smb.conf then read/write works.

In any case I am done now and it all works.
Bo Berglund
Sweden

Return to “General discussion”