loading

A NAS or network attached storage, is the best way to keep your data backed up and stream and access content from all the devices connected to the network. But a NAS is really a computer that is connected to the network and computers can draw a large amount of current, especially as it is powered on all the time.

So in today tutorial I'm going to show you how to convert your Raspberry Pi as a NAS, a raspberry pi is a low powered device and it would drag only a fraction of what power is used by an actual NAS and also to use a raspberry pi as a NAS it would reduce the cost to. But you would be loosing features like Fire and water proof and some performance when you use a raspberry pi, so unless you want to stream very large files and want to stack up your hard drives in a raid configuration, the Raspberry Pi should work just fine.

You can also check out the video tutorial on how to build this below.


Step 1: Tools and Components

Here is a list of the components and tools required, the list is simple and all you need is

  • A Raspberry Pi
  • A Serial to USB Cable
  • External Hard driver
  • Lan Cable
  • An SD Card 4Gb or above
  • A Computer to get the Pi running
  • An Active internet connection

Step 2: Getting Started

If you just got your PI or have any other OS running you will first need to install the Raspbian OS, the procedure to do this is really very simple.

Fist, you need to visit the Raspberry Pi official website an download a copy of Raspbian OS, after the download is complete you need to download a tool called the wind32 disk image maker, this is free software, an alternative to this would be Power ISO.

After you have installed the disk image maker it is now time to connect your SD card or micro SD card if you are using a raspberry pi 2/3, to your computer. Next open up the tool and locate the image file on the computer and select the drive to write to.

Once it is done writing plug it into the raspberry pi and you should now have your raspberry pi boot up raspbian OS.

Step 3: Serial Communication

To establish communication between the computer and the raspberry pi I'm using serial, you could also ssh your pi or attach physical keyboard, mouse and monitor to program it. To establish a serial communication I'm using a USB to serial cable I found on eBay you can also use an Arduino to establish this communication. The serial cable has four terminals which connect to the raspberry pi GPIO pins, and the other end to a computer.

Install the drivers for the serial module if you are using windows and find out which port the serial communication is established using device manager in windows.

Step 4: Updating the Raspberry Pi

After you have set up serial communication between the Pi and a PC, open up putty and select serial as the type of connection. Enter in the right com port and set the baud rate to 115200 and open a connection.

If everything went well you should now see a login page, the default username is 'pi' and password is "raspberry". Now lets update the Pi, now would a good time to plug in the lan cable for internet access if you not already have done it. Type in the command below to update your Raspberry Pi -

sudo apt-get update

If you are using a hard disk formatted to ntfs files system you need to install an additional package called ntfs-3g that can be done by typing the following command -

sudo apt-get install ntfs-3g

Step 5: Mounting the Hard Disk

After you have installed the ntfs package you should now see your drive show up when you type -

sudo fdisk -l

And now it is time to mount your drive to the raspberry pi, you can do this via the following command -

sudo mkdir /media/USBHDD1

If you have more than one drive you can mount that to now. And to mount your drive to the above directory you just created using this command -

sudo mount -t auto /dev/sda1 /media/USBHDD1

Next lets create a folder in the drive that you want to share, (the folder is called "shares") -

sudo mkdir /media/USBHDD1/shares

Step 6: Installing Samba

Now lets install Samba, Samba is the software that turns your raspberry pi as a NAS. You can install samba by typing the following command -

sudo apt-get install samba samba-common-bin

After installing samba lets configure it this can be done by typin the following commands -

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

sudo nano /etc/samba/smb.conf

Scroll down to the bottom of the file and enter these few lines to enable sharing of the folder -

[shared]
comment = shared folder
path = /media/USBHDD1/shares valid users = @users force group = users create mask = 0660 directory mask = 0771 read only = no

Step 7: Adding Users

Now it is time to add users who can access the files on the server -

sudo useradd admin -m -G users<br>sudo passwd admin

The user I created is called admin, you can name it anything you want. Now lets samba know about the new user -

sudo smbpasswd -a admin

The above commands will ask you for passwords to access the server, you will need to remember that to access the files.

Step 8: Testing

Now you have finished installing the NAS server, the server can be accessed by any client connected to the same network as that of the server. You can share user folders and protect them using a password. You can power the raspberry pi using a micro USB cable and a mobile charger, and mount it in an enclosure along with the hard drives.

To add additional users you can repeat the previous step.

<p>how do you actually connect to the nas?</p>
<p>As a bit of an upgrade... have you considered using a Banana PI as it has a SATA interface? You could also then connect it to a RAID card and have resilient mirror or stripe.</p>
<p>If you type Banana Pi NAS into google you will find what youre looking for. It would be silly to have an Instructable titled &quot;Raspberry Pi as a NAS&quot;, but use a banana pi, wouldnt it?</p>
<p>FYI: For security reasons never create a user named Admin, Administrator or give root a login. These are the users that hackers will attempt to use to hack into a server. That's just basic security. This way they'll have to guess a valid user as well as brute forcing a password. I'd add additional security features if I was creating a NAS on my home network.</p>
<p>it is a home network only tho. you shouldn't be using this as a DIY business solution. these things will go down all the time with 150 people accessing it at the same time. 5 people is a bit different. </p>
<p>also, you shouldn't be port forwarding this. that is pretty much the only way (without a plugbot) that this could get hacked</p>
<p>The main thing I need this for is to play back MP4 or WMC videos I record. Will this play those back smoothly and will these files show up simply in explorer or will I need to go through shenanigans to access them? Thanks.</p>
<p>I bought a Pi 3 and was setting it up as a Plex server so I could watch my media through my Roku devices, and I thought that it'd be nice to have access to my data on the USB drive so I could upload new media, backup files from my laptop, etc.</p><p>The setup on this was pretty easy, and worked nicely for me in being able to access my data with only a couple of slight modifications to the instructions.</p>
I've made this project but I'm facing a problem. I couldn't access the files from my pi to the network. How should I access that? Please someone explain with proper steps how I can see my files on my laptop which is connected on the same network
<p>why use serial for comunications instead of SSH?</p>
<p>why use serial for comunications instead of SSH?</p>
<p>Is the RPi running on some sort of backup power supply ? coz, if not then what will happen to HDD when RPi suddenly losses the power ? What is the plan to Eject the HDD safely, else we might run into data corruption on HDD due to sudden outage of power, don't you think ?</p>
My findings: 2.5&quot; external hdd is powered thru the usb cable, therefore the raspberry usb must be configured to increased power. Otherwise the external disk will not power up correctly and making clicking noise only. A strong power adapter 2000mA also needed. The external disk mounting must be configured permanent, to remount on power cycle. The raspberry boot must be delayed a little, otherwise the mounting fails, because the disk is not ready as fast as the raspberry start the mounting procedure. To get details about these tricks, see my video https://youtu.be/_VJhTtLvmV0 (it is in hungarian, my native language, but the commands in english of course :-)
<p>Your speed limit (NAS data transfers) would really be a question for me,<br> would the Cat5 attachment be limited by your router or switch's speed?<br><br>Or, would your NAS transfer speed be limited by your USB's speed limits (I only have USB 2, I want to add a USB card to my system for speedier data transfers.)</p>
<p>The Pi hardware uses USB for the built in ethernet port &amp; the USB storage, USB2 speeds are shared between both devices.</p><p>It means NAS solutions like this are limited by how quickly the Pi can route data over USB. I did tests for a similar setup with an earlier Rasbian OS &amp; got speeds around 2-4 MB per second via the network!</p><p>If you use Wifi instead it gets even slower. Most modern switches &amp; routers will run at up to around 60MB/s with gigabit ethernet speeds, the Pi's 'fast' ethernet (not Gigabit) can only manage 4-6MB/s at best.</p><p>I'm not sure anyone wants to transfer Terabytes of data via a link that runs at Megabytes per second, but it's OK for limited use.</p><p>There are examples of Gigabit USB adaptors on Pi, but I don't think you will get around the USB2 speed limits with the Pi's hardware&hellip;</p><p>http://www.jeffgeerling.com/blogs/jeff-geerling/getting-gigabit-networking</p>
It possible to connect to the rp 4 or 8 SATA drives and create a raid array?
<p>If you're gonna do this start with something like a cubbieboard ($60) with onboard sata, add an external drive enclosure ($100), the real issue is cost, $160 min. for this setup, Which doesn't make a lot of $$ sense when you can get a pretty decent nas for less..</p><p><a href="http://www.newegg.com/Product/Product.aspx?Item=N82E16822107183R" rel="nofollow">http://www.newegg.com/Product/Product.aspx?Item=N8...</a></p><p></p>
<p>If you power the hdd extarnaly because the pi cannot deliver engough power.</p><p>but the pi usb ports have not engough throuput for all the drives.</p><p>it can but it would be very very slow</p>
<p>If you power the hdd extarnaly because the pi cannot deliver engough power.</p><p>but the pi usb ports have not engough throughput for all the drives.</p><p>it can but it would be very very slow</p>
<p>Interesting!!</p>
<p>Wouldn't it be totally possible to get multiple DC powered extHDD, and THEN a USB splitter/hub? It would solve the power issues, and be capable of running up to 3TB HDD thru RAID.</p>

About This Instructable

67,723views

488favorites

License:

More by webgeeks:Beginners Guide to Getting Started with Arduino Cardboard Wireless Charger Program an Arduino Wireless over Bluetooth 
Add instructable to: