Setting up a Raspberry Pi 2 Samba server (in early January 2016)
The following is how I configured a Raspberry Pi 2 as a samba server, using a Seagate Backup Plus Slim, 1TB, drive.
For ease I purchased the CanaKit Raspberry Pi 2 Complete Starter Kit. It runs about $70 and includes enough to get up and running with the Raspberry Pi 2, with the Pi itself, a nice case, power supply, HDMI cable, WiFi adapter, and SD card with NOOBS/Raspbian installer.
For the hard drive I opted to purchase a Seagate Backup Plus Slim 1TB Portable External Hard Drive, since I've had good enough luck with Seagate in the past, and reviews are generally favorable. This ran me $60. I confirmed that it worked fine on my Windows 10 machine, and was already formatted to NTFS.
Unfortunately, once I received the Pi and drive I found that the power supply/Pi wasn't putting off enough power to keep the drive running. After looking at the options, including tweaking the Pi to pass through more power through the USB connector, I opted to pick up a powered USB hub instead (especially since I was considering setting up a camera at some point in the future).
For this I went with the AmazonBasics 4 Port USB 3.0 Hub with 5V/2.5A power adapter for about $17. Reviews are quite favorable, and I didn't see any indication that it wouldn't work. Once I received the included manual does note that Windows 2000 through 8 are required, or Mac OS X. However, as you'll see there were no issues.
Before powering my Raspberry Pi 2 up I went ahead and plugged the USB Hub into the Pi, and the Seagate Backup Plus into the HUB. I powered up the HUB first, and then powered up the Pi.
While it was a couple years old, How to Turn a Raspberry Pi into a Low-Power Network Storage Device worked fairly well for the setup steps.
Unless otherwise noted, all commands were run on the Raspberry Pi 2 itself, at the command line, outside of Raspbian.
While the guide suggests installing ntfs-3g, this was already installed on my Pi.
sudo apt-get install ntfs-3g
Getting a listing of the disks,
sudo fdisk -l, returned /dev/sda1 for the name of the Seagate drive. So, despite a moment of worry, the Amazon USB Hub worked perfectly fine.
The next step was to setup the drive. I opted for all lowercase when doing so.
sudo mkdir /media/usbhdd1
Next was the mounting of the drive.
sudo mount -t auto /dev/sda1 /media/usbhdd1
Within the directory I setup a new shares directory.
sudo mkdir /media/usbhdd1/shares
When I first tried to install Samba I received a number of errors. A quick update resolved the issues.
sudo apt-get update
Then I was able to install Samba.
sudo apt-get install samba samba-common-bin
Backup the Samba configuration, just in case, and then open the config in nano.
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.old sudo nano /etc/samba/smb.conf
My Windows 10 machine was already on the WORKGROUP workgroup, so I didn't have to touch this, but verify workgroup is set as needed.
Contrary to the guide I was unable to find a security line in the Authenication section, so I skipped that for now, and promised to try to get in without authenticating before I went too far.
At the bottom of the config I added the following:
[Backup1] comment = Backup Folder path = /media/usbhdd1/shares valid users = @users force group = users create mask = 0660 directory mask = 0771 read only = no
CTRL+X will exit, and allow you to save. Press
Enter to just overwrite the existing file.
Restart the Samba service:
sudo /etc/init.d/samba restart
sudo useradd backups -m -G users sudo passwd backups sudo smbpasswd -a backups
For ease I then determined the ip of the Raspberry Pi.
And then I just browsed to that directly in Windows explorer (
\\192.168.x.x). Thankfully I was prompted for credentials when I tried to access the Backup1 directory. Entering the credentials I had created above worked great.
The next step was to put some data in the directory. Over my wireless network speeds weren't fantastic, but it worked fine.
I verified the files had been copied over:
cd /media/usbhdd1/shares ls
Next was a step I almost forgot, which was to have the Raspberry Pi automatically mount the drive after rebooting. The config first needed to be opened in nano,
sudo nano /etc/fstab, and then I had to add the following, which I did so at the end of the file.
/dev/sda1 /media/usbhdd1 auto noatime 0 0
Ctrl + x as usual to exit, save, and overwrite the existing file.
Finally, restart the Raspberry Pi itself to verify that I could still get to the share after it came back up.
Support This Site
If my blog was helpful to you, then please consider visiting my Amazon Wishlist.