top of page

Raspberry Pi NAS

  • Ankur Desa
  • Nov 6, 2015
  • 5 min read

So What is Raspberry Pi? Raspberry Pi is a credit card sized computer that plugs into your TV and a keyboard. It is a capable little computer which can be used in electronics projects, and for many of the things that your desktop PC does, like spreadsheets, word-processing, browsing the internet and games. It also plays high-definition video. More can be found at the raspberrypi.org Website. It cool how you can make use of the small credit-card size computer to do many things.

I wanted to build a NAS Server for my house. i am currently using a Asus RT-13U B2 with DDwrt and a 16 GB pen Drive to run my Asterisk, web server and other applications. i felt that the WiFi router was just not capable to do the things that i wanted to do and thus began researching on low powered NAS boxes that could be tucked away in one corner of my house and still do the things i wanted to like run asterisk, "Download Clients" stream movies to my smart TV on my network use the box as my backup device.

While there are huge HOW-TOs on the net to do just what i am going to tell you, i found the following article interesting and wanted to share it would to anyone who is interested.

Note: i have yet to install one for my house and thus the instructions are not mine at all. i have just facilitated and collated it in one place.

Required

  • Raspberry Pi

  • 4 GB SD Card (8 GB+ Recommended) or Micro SD Card if you’re using a Raspberry Pi 2 or B+

  • Ethernet Cord or Wifi dongle

  • External Hard drive

Optional

  • Raspberry Pi Case

  • USB Keyboard

  • USB Mouse

Note: The USB ports on the Raspberry Pi might not be enough to power an external drive so you might need to invest in a powered USB hub.

Setting up the Raspberry Pi NAS

In this tutorial I use the standard operating system for the Raspberry Pi. This is Raspbian, if you would like to install it then check out my guide on how to install Raspberry Pi NOOBS.

Mounting The Hard drives

The first thing before we setup the NAS is mount the external hard drives. This is important that we do this correctly the first time otherwise we could end up with issues later on. You want to be able to mount a drive so it will always be the same even if the Pi loses power or reboots.

1. Bring up the Raspberry Pi terminal either by SSH or on the Pi itself.

2. First let’s bring Raspbian up to date by entering the following commands:

sudo apt-get update

sudo apt-get upgrade

3. We will want to install ntfs support so let’s first install the package.

sudo apt-get install ntfs-3g

4. Next we want to find our external hard drive to do this enter the following command.

sudo fdisk -l

5. There should be two lots of drives that pop up unless you have more than 1 drive connected. The first would be the SD card that Rasbpain is currently running on (Should be something like /dev/mcbblkop1) ignore this one.There should also be another one that looks similar to /dev/sda1 this is the drive that we will use.

​6. Before we mount the drives we will need to create a directory to mount to. To do this enter the following command. (Remember to fix up the command with the correct drive name)

sudo mkdir /media/NASHDD1

7. Now before we continue we will need to create a user to login as. To do this enter the following. Note: Update the word pimylifeup to change the user name.

sudo useradd pimylifeup -m -G users

sudo passwd pimylifeup

8. You will be prompted to enter a password twice, be sure to remember this password as you may need it later on.

9. Next we need to get the gid and the uid, make sure you write these down as we will need them in the next step. Update pimylifeup with the user you created above.For the gid enter the following:

id -g pimylifeup

For the uid enter the following:

id -u pimylifeup

10. Now we need to edit the fstab file so our Pi will automatically mount the drive on boot up and set the correct permissions, to do this enter the following command:

sudo nano /etc/fstab

11. Add the following the line to the bottom of the file. Changing the /dev/sda1 to whatever your hard drive is and updating uid and gid as appropriate. (The code below is all one line)

/dev/sda1 /media/NASHDD1 auto uid=enter_uid_here,gid=enter_gid_here,noatime 0 0

12. Reboot the Raspberry Pi and the drives should automatically mount with the correct permissions.

Now that we have completed mounting the drives to the folders we can now move onto setting up the samba server. If you wish to make edits to the folder do the changes into the mounted folder. For example if we wanted to make a new directory we would enter the following.

sudo mkdir /media/NASHHD1/share

Setting up the Raspberry Pi Samba Server

In this part we will download and install the samba package so we can have a Raspberry Pi samba server up and going. If you want more information on the package and it’s documentation you can check out the Sambawebsite.

1. First we will need to install the samba package by entering the following command:

sudo apt-get install samba samba-common-bin

2. Just in case we make any mistakes along the way we should back up the samba config folder. To do this enter the following command:

sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.old

3. Now let’s edit the config file by entering the following:

sudo nano /etc/samba/smb.conf

4. There are several edits we will need to make to this file, first remove the # from the security = user line.

5. Next we will need to add our hard drive to the samba config file. Enter the following to add your hard drive as a share (Update the path if you have something different):

[NAS]

comment = NAS

Folder path = /media/NASHDD1

valid users = @users

force group = users

create mask = 0660

directory mask = 0771

read only = no

6. To quickly explain what each of the things mean above so you have a better understanding the Raspberry Pi Samba Server.

  • [NAS]: This is the name of the share (What you will see in file explorer)

  • Comment: This is a comment for the associated for share.

  • Path: Path to the folder you wish to share.

  • Valid User: A list of users that are allowed to login to this share.

  • Force Group: This specifies a UNIX group name that will be assigned for all users connecting to this share.

  • Directory Mask: This creates a permission mask for all directories created on the drive.

  • Read Only: This allows you to set the share to be read only.

7. Now restart the samba server by entering the following command:

sudo /etc/init.d/samba restart

8. Finally you will need to connect the user to samba do this by entering the following:

sudo smbpasswd -a <PASSWORD>

Testing the Raspberry Pi NAS

Windows

If you have a windows PC please do the following to access the Raspberry Pi NAS.

  1. On a windows PC open up file explorer.

  2. Click on network in the left hand column.

  3. In here open up Raspberry Pi.

  4. Double click on the folder.

  5. Enter the credentials.

  6. You should now be able to save, edit and delete files in this folder.

Mac

If you have a Mac please do the following to gain access to the NAS.

  1. Click on go in the top bar and navigate to connect to server.

  2. In here add the IP address of the Pi or browse to the Raspberry Pi. (You will need to specify the folder)

  3. Enter your credentials.

You should now be able to save, edit and delete files within this folder.

NOTE: This article does no belong to me it has been taken from http://pimylifeup.com/raspberry-pi-nas/

 
 
 

Comments


Featured Posts
Recent Posts
Archive
Search By Tags
Follow Us
  • Facebook Basic Square
  • Twitter Basic Square
  • Google+ Basic Square

© 2015  Ankur Desai  

bottom of page