Configuring Samba on Raspberry Pi, to share USB drives

Today it is time to use Samba for USB Drives sharing.

Mounting USB Drive

1. Create new directory where your drive will be mounted

sudo mkdir /media/usbHDD
sudo chmod 744 /media/usbHDD

2. List your storage devices and save UUID of your drive

ls -l /dev/disk/by-uuid/

(Update) more readable command:

sudo lsblk -o UUID,NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL,MODEL
or
sudo blkid

3. Mount that drive to /media/usbHDD, use proper user and group (uid, guid), adjust drive path

sudo mount -o uid=pi,gid=pi /dev/sda1 /media/usb

4. Edit fstab

sudo nano /etc/fstab

and add line with UUID of your drive

UUID=18A9-9943 /media/usbHDD vfat auto,nofail,noatime,users,rw 0 0

5. Verify if drive is mounted

ls -l /media/usbHDD

restart and verify if drive is mounted after reboot

sudo reboot now
ls -l /media/usbHDD
Update:

If you have problems with auto mount you may need to install:

sudo apt-get install exfat-fuse 
or
sudo apt-get install ntfs-3g

You may also need to change partition type in command in fstab file from vfat to ntfs

Installing Samba

The process of installation is very simple

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install samba samba-common-bin

Czytaj więcej