Introduction
This page provides the bare minimum information needed to get a Windows Samba server up and running on your Raspberry Pi.
Once the Samba server is running you will be able to play videos stored on the Samba server using clients such as iPad, Tablet, mobile phones and Windows PCs etc.
Installation
sudo apt update
sudo apt upgrade
sudo apt-get install samba samba-common-bin
sudo mkdir -p /home/shares/publicsudo chmod 777 -R /home/shares/public
sudo nano /etc/samba/smb.conf
sudo nano /etc/samba.conf (/etc/samba/smb.conf in XFCE)
At the end of the file add the following:
[Public] comment = Raspberry Pi 4GB Samba Storage path = /home/shares/public browseable = yes only guest = no create mask = 0777 directory mask = 0777 public = yes guest ok = yes
sudo smbpasswd -a pi ( sudo smbpasswd -a ubuntu in XFCE for user ubuntu )
The above creates a new samba user and sets the password.
To simply change the samba password to a new password use:
sudo smbpasswd pi
Adjust the following mount command to reflect the /dev/location of the files being shared (e.g. /dev/sda2).
sudo mount -t auto /dev/sda2 /home/shares/public
sudo /etc/init.d/smbd restart
Samba Client
To access Samba shares on your Raspberry Pi and other computers you will need to begin by installing :
sudo apt-get install smb4k smbclient
More to follow....
ext4 Partition Label
It may help you to arrange your partitions if they have meaningful names.
To change the name of an existing ext4 partition use e2label :
sudo e2label /dev/sda2 Files
Specifying Exact Drive / Partition to use as Samba Drive
blkidExam the output of blkid to find the UUID (unique identifier) of your chosen drive for Samba.
Here the chosen drive is /dev/sdb
/dev/sdb: LABEL="Samba4TB" UUID="979610b6-2a3f-432e-bc11-5465bcb5253c" TYPE="ext4"
UUID=979610b6-2a3f-432e-bc11-5465bcb5253c
Now make sure your chosen drive is mounted.
Then run to find the mounting information for it in red.
cat /proc/mounts
/dev/sdb /media/ubuntu/Samba4TB ext4 rw,nosuid,nodev,relatime 0 0
Change (if necessary the desired location of the mount point to be consistent with Samba configuration file, e.g.
/dev/sdb /home/shares/public ext4 rw,nosuid,nodev,relatime 0 0
sudo nano /etc/fstab
Add from the previous two commands the following to the bottom of the /etc/fstab file:
# Storage
UUID=979610b6-2a3f-432e-bc11-5465bcb5253c /home/shares/public ext4 rw,nosuid,nodev,relatime 0 0
Now umount your the Samba drive, e.g.
umount /dev/sdb
Then to reread the edited /etc/fstab and to update /etc/mtab or /proc/mounts that shows mounted drives run:
sudo mount -a
Using a USB drive as a share requires that the user mounting the drive be specified so that all guest and other Samba users requests go through that user.
Without
force user = pi
it simply isn't possible to access files via Samba on an external USB drive.
The share can be setup under Linux (not primarily Samba) so that nobody can Write but everyone can Access / View, so essentially everyone has read and execute permissions only.
[Samba-4TB-Hard-Drive]
comment = Samba 4TB USB WD Hard Drive
path = /media/pi/Samba4TB
Public = yes
read only = yes
browseable = yes
only guest = no
create mask = 0700
directory mask = 0700
Guest ok = yes
force user = pi
The Linux user group in this example was also pi
For more details Google for force user and external USB drive.
There is an AskUbuntu post 'Cannot sharing my second harddrive with Samba'
and
Sharing External Drive using Samba in Ubuntu 18.04
/dev/sdb /media/ubuntu/Samba4TB ext4 rw,nosuid,nodev,relatime 0 0
Change (if necessary the desired location of the mount point to be consistent with Samba configuration file, e.g.
/dev/sdb /home/shares/public ext4 rw,nosuid,nodev,relatime 0 0
Add from the previous two commands the following to the bottom of the /etc/fstab file:
# Storage
UUID=979610b6-2a3f-432e-bc11-5465bcb5253c /home/shares/public ext4 rw,nosuid,nodev,relatime 0 0
Now umount your the Samba drive, e.g.
umount /dev/sdb
Then to reread the edited /etc/fstab and to update /etc/mtab or /proc/mounts that shows mounted drives run:
sudo mount -a
Example External USB Share
Without
force user = pi
it simply isn't possible to access files via Samba on an external USB drive.
The share can be setup under Linux (not primarily Samba) so that nobody can Write but everyone can Access / View, so essentially everyone has read and execute permissions only.
[Samba-4TB-Hard-Drive]
comment = Samba 4TB USB WD Hard Drive
path = /media/pi/Samba4TB
Public = yes
read only = yes
browseable = yes
only guest = no
create mask = 0700
directory mask = 0700
Guest ok = yes
force user = pi
The Linux user group in this example was also pi
For more details Google for force user and external USB drive.
There is an AskUbuntu post 'Cannot sharing my second harddrive with Samba'
and
Sharing External Drive using Samba in Ubuntu 18.04
No comments:
Post a Comment