search
top

Using the Raspberry Pi as a NAS

Here we have another great use for the Raspberry Pi as a NAS server for your LAN. In this post we’ll be using a Thermaltake BlacX USB SATA attached to the Pi with a 1 TB drive with ntfs shared to the Windows and MAC systems for access.
Install ntfs support

$ sudo apt-get install ntfs-3g

Create the mount directory and mount it

$ sudo mkdir /media/ext

Mount as ntfs as user id pi

$sudo mount -t auto /dev/sda1 /media/ext

Create a share directory

$ sudo mkdir /media/ext/share

Install Samba support

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

Edit Samba config and create the share drive

$ sudo nano /etc/samba/smb.conf

Remove the # symbol from the security = user line (by highlighting it with the cursor and pressing delete) to enable username/password verification for the Samba shares.

Next, we’re going to add an entirely new section to the configuration file. Scroll all the way down to the very bottom of the file and enter the following text:

[Backup]
 comment = Backup Folder
 path = /media/ext/share
 valid users = @users
 force group = users
 browsable = yes
 create mask = 0660
 directory mask = 0771
 read only = no

Press CTRL+X to exit, press Y when asked if you want to keep changes and overwrite the existing configuration file. When back at the command prompt enter the following command to restart the Samba daemons:

$ sudo /etc/init.d/samba restart

At this point we need to add in a user that can access the Pi’s samba shares. We’re going to make an account with the username backups and the password backups4ever. You can make your username and password whatever you wish. To do so type the following commands:

$ sudo useradd backups -m -G users
$ sudo passwd backups

You’ll be prompted to type in the password twice to confirm. After confirming the password, it’s time to add “backups” as a legitimate Samba user. Enter the following command:

$ sudo smbpasswd -a backups

Edit fstab and add the entry for the mount.

$ sudo nano /etc/fstab

This will open up the file systems table in nano so we can add a few quick entries. Within the nano editor add the following lines:

/dev/sda1 /media/ext auto noatime 0 0

This will install the auto usb mounting system.

$ sudo apt-get install autofs

However we need to set up a config file to allow the automounting of the usb disk.

 $ sudo vi /etc/auto.master

At the end of the file is the following
+auto.master
You need to add the following below the +auto.master entry

 +auto.master
 /media/ /etc/auto.ext-usb --timeout=10,defaults,user,exec,uid=1000

That’s all you need and can now access the share from any system in your LAN.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

top