Raspberry Pi – how to set up a samba shared drive

  bash, linux, raspberry-pi

 install samba

sudo apt-get install samba

# below, replace johnsmith with your user id that you want to connect to samba (i.e. not “pi”)

# create a new group called samba

sudo groupadd samba

# create a system user who should have samba access, set all default info, and a password

sudo adduser --no-create-home --disabled-password --disabled-login johnsmith

# add this user to the samba group

sudo usermod -a -G samba johnsmith

# add the user who can access samba shares

sudo smbpasswd -a johnsmith


(set up their password here)

# to change the user’s password in the future:

sudo smbpasswd johnsmith

# edit conf file, go to the bottom of the file and enter

sudo nano /etc/samba/smb.conf
# my drives
[mnt-mydrive]
comment = This is the /mnt/mydrive shared drive
path = /mnt/mydrive
browseable = yes
read only = no
guest ok = no
writable = yes
admin users = johnsmith
write list = johnsmith
create mask = 0775
directory mask = 0775
public = no

# also add:
[nobody]
browseable = no

# also comment out this section:

#[printers]
#   comment = All Printers
#   browseable = no
#   path = /var/tmp
#   printable = yes
#   guest ok = no
#   read only = yes
#   create mask = 0700


# and comment out this section:
#[print$]  
#   comment = Printer Drivers
#   path = /var/lib/samba/printers
#   browseable = yes   
#   read only = yes
#   guest ok = no

# restart samba

sudo service smbd restart

# from your Windows PC, access the shared drive by going to the Raspberry Pi’s IP:

\\192.168.0.xxx


# enter the user id and password that you set up above (ex: johnsmith / password)