The last couple of days I’ve been playing around trying different Samba share set-ups, to get the most throughput using the Raspberry Pi as a NAS. I thought I’d share what I’ve found to be the most effective.
It’s worth noting that all my results are with a Raspberry Pi Model B (512MB RAM, UK Model) over-clocked to 900MHz ARM, 250MHz core, 450MHz SDRAM, 2 overvolt using the built-in over-clocker and an USB 3TB external hard-drive with its own power supply. I’m also using Raspbian as the OS.
With my current settings I’ve been able to achieve the following results using the network port:
- Writes of around 10 MB/second
- Read of around 8 MB/second
This is plenty fast enough for steaming video, music and backing-up relatively large files form the computers in my flat.
Updating / Formatting
I was having some issues with transfer speed at first, until I opened
raspi-config and ran the updater. I recommend you do this before starting.
I did originally want to have the drive formatted as exFAT, so I could plug it directly plug it into my PC/Mac and copy over a large chuck of the files with USB three. But I ended up opting for Ext4, after running into problems with permissions when mounting the drive using fstab (I’ll explain how to do this later) and reading about it’s performance benefits with Raspbian. If you want to know how to format a drive via command line, you can follow the guide on the Ubuntu website.
Once you’ve formatted the drive you’ll want to mount it — I did this through fstab so I didn’t have to mount it manually every time I restart my Pi. To add the drive to fstab open terminal and type the following:
$ sudo vim /etc/fstab
Now fstab is open add the following line to the bottom of the file:
/dev/sda3 /media/storage ext4 defaults 0 0
There are two main things you’ll need to change here,
/dev/sda3 needs to be the name of your hard-drive and
/media/storage is the folder that you want it to mount to (this folder need to already exists). The rest can stay the same, save the file and exit.
To mount the drive you type:
$ sudo mount -a
Setting up Samba
Before installing Samba, updated the package list with:
$ sudo apt-get update
Then install Samba with:
$ sudo apt-get install samba
Now it’s installed, you need to configure your shares. To do this you need to open the smb.conf file in terminal with Vim:
$ sudo vim /etc/samba/smb.conf
Jump to the bottom of the file add the following lines then save the file and exit:
[Storage] comment = Pi File Server Share path = /media/storage browsable = yes guest ok = yes create mask = 0777 writeable = yes
Now you’ve added the share you’ll need to set the permissions on the folder, so guest users can read/write files. To do so type the following in terminal:
$ sudo chown -R nobody:root /media/storage
Once you’ve done that, restart the service to reload the configuration file you changed earlier:
$ sudo service samba restart
That’s all you need to do! The share should now be accessible over the network.
If you have any feedback please let me know via twitter: @samstefan