Raspberry Pi 2 NAS Experiment HOWTO

But what about RAID?

Striping won’t help. No matter how many hard drives you stripe across, you are still limited by the same USB bandwidth as there is only one USB2.0 host interface on the Broadcom SOC, and by increasing the overhead by transferring to/from multiple drives, you will likely slow transfers down a bit.

Mirroring will slow you down, as you will have to perform every write twice, thus it would further limit write bandwidth to the NAS.

4) File Server Software

There are two major types of file servers:

  • SAMBA (SMB) normally used by Windows clients/servers
  • NFS normally used by Unix/Linux clients/servers

SAMBA is extremely convenient – all your Windows PC’s can browse network shares, and easily transfer files.

Unfortunately SAMBA is less efficient than NFS, and therefore is slower.

NFS is known to be faster – all your Unix/Linux computers support it.

Sadly, while NFS clients are available for Windows, it requires installing some software and more configuration – thus it is not used often in a Windows environment.

5) File system overhead

The most commonly used file systems on NAS drives are:

  • FAT32 normally PC external hard drives and memory cards are formatted with FAT32
  • NTFS internal hard drives and large external drives are often formatted with NTFS on PC’s
  • ext3/ext4 is normally used by Linux computers for internal and external drives

FAT32 is considered to be the slowest file system, with NTFS being faster and ext4fs being the fastest.

NTFS is significantly better than FAT32 for file servers due to its support for permissions.

ext3/ext4 are natively supported files systems for the Raspberry Pi, and should be used for your file server volumes as they use the permissions and file structures native to Linux.

Should you need to access ext3/ext4 volumes on a Windows PC, there are use installable file system drivers for Windows that will let you mount those volumes.

I strongly recommend that you use ext4fs for your NAS volumes – I use it exclusively for my file server volumes.

Configuring your Raspberry Pi SAMBA server

It is very easy to install and configure your Raspberry Pi SAMBA server:

Open a terminal, and issue the following commands:

sudo bash

apt-get update
apt-get upgrade
reboot

After rebooting, open a terminal once more and:

sudo bash
apt-get install samba samba-common-bin

Assuming your hard drive is on /dev/sda, use gdisk to partition it. I made two partitions, a 200GB “usbroot” partition, and used the rest of the device for data as a “usbdrive” partition.

sudo bash
mkdir /media/usbroot
mkdir /media/usbdrive

cd /media/usbdrive/
mkdir public files
chmod 777 public files
chown pi:pi files public

As you can see above, I made two shares – one public that is readable and writable by guest users and does not need a password, and a files share for users with accounts.

cp /etc/samba/smb.conf /etc/samba/smb.conf.old
joe /etc/samba/smb.conf
/etc/init.d/samba restart

You can use any other editor, but you have to be root to edit /etc/samba/smb.conf

I removed the leading ‘#’ from ‘#  security = user’ and added the two following two shares at the bottom of the file:

[public]
   comment = Public Files
   read only = no
   locking = no
   path = /media/usbdrive/public
   create mask = 0666
   directory mask = 0777
   guest ok = yes

[Files]
   comment = File Server Folder
   path = /media/usbdrive/files
   valid users = @users
   force group = users
   create mask = 0660
   directory mask = 0771
   read only = no

For the non-public share, the users will have to exist on your Pi server, and you will have to add smb passwords for them.

sudo bash
touch /etc/samba/smbpasswd
smbpasswd -a pi

The above assumes that /etc/samba/smbpasswd does not already exist, and that for now you only want the user ‘pi’. You will have to enter the password when prompted.

Tuning your Raspberry Pi SAMBA server

I tried a number of different SAMBA optimizations, including:

socket options = TCP_NODELAY SO_RCVBUF=32768 SO_SNDBUF=32768

and

socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65536 SO_SNDBUF=65536

Frankly, they did not make a significant difference (other than slowing down small file writes) however I was using a Linux client for the tuning tests.

(I welcome SAMBA tuning tips, but I think they won’t make a significant difference with the Raspberry Pi 2 due to the USB2.0 bottleneck)

Adding a gigabit Ethernet adapter did make a noticeable difference, but the USB2.0 host port drastically limited the potential for performance improvement.

How much?

You will see later in this article!

Test Equipment

  • Raspberry Pi 2 Model B
  • ADATA 16GB UHS-1 Class 10 SD card
  • 2015-02-16 Raspbian Wheezy
  • Vantec CB-ISATAU2 USB2.0 USB/SATA adapter
  • 3TB TOSHIBA SATA3 7200rpm, 64MB cache, HDKPC08

Article Index

Pages: 1 2 3

If you liked this article, please help us grow! "Like" us and let your friends know with the Twitter and Facebook buttons at the top left - We appreciate your support!