R-Pi NAS

Back to RPi Projects.

Raspberry Pi Network Attached Storage

This is very preliminary, do not try to follow these instructions.

=What does it do?=

This project configures your Raspberry Pi to share files with any other computer on the network. You can add a large hard disk to the RPi and use this to store your important files/photos/videos in a central location.

The files on your RPi can be easily accessed from any type of computer which is connected to your network, for example a Windows PC, a Linux PC, A Mac, a smartphone, etc.

Warning: Make sure that you store your important files in more than one location. If the hard disk connected to the RPi becomes faulty, you may not be able to access your files.

=What do you need?=


 * A Raspberry Pi, model B.
 * A boot SD card for the Raspberry Pi.
 * A large USB-connected hard drive.
 * An Ethernet cable to connect to the local network.

=What skill level is required?=

This project does not require and coding or compilation. Very basic Linux and networking knowledge would be useful, but not essential.

You need to...
 * Edit configuration files on the RPi
 * Enter basic Linux commands to configure users and passwords
 * Use standard tools (Windows/Linux/Mac) to add a network drive to your PC
 * Join computers together using ethernet cables

=How does it work?=

The RPi is configured as a Samba server and can expose its files to any Samba client. Samba was originally a Windows-only protocol named Server Message Block (SMB), but has become popular for other operating systems.

There are other methods possible (for example ftp) but Samba is very popular because it is built into Windows and Mac OS X, and is very easy to install in all versions of Linux.

The end effect is that the PC user will be able to read and write to a new drive which appears to be locally-attached but is actually attached to the RPi.

=Overview of this project=
 * 1) General Preparation
 * 2) Configuring the Samba server on the RPi
 * 3) Configuring the Samba client on a Windows PC
 * 4) Configuring the Samba client on a Linux PC

General Preparation
Not started yet, see "Useful text" below for ideas.

Configuring the Samba server on the RPi
Not started yet, see "Useful text" below for ideas.

Configuring the Samba client on a Windows PC
A Windows PC uses Samba automatically, no extra software is required.

In Windows, Network Attached Storage is known as a "network drive". Open up the Windows help and search for the term "network drive", you should see something like

If you follow the instructions, you will be asked to select a drive letter (Z: is default but you can select anything available) and the path to the network drive.

The path is in the format \\computer_name\directory. In this example, the computer name is "big_disk" and the user wishes to attach to the directory "john". Note that the computer name may be also be in IP address format, such as "192.168.0.2".

Configuring the Samba client on a Linux PC
Not started yet.

=Useful text=

'''This is probably the text which will be used as the basis of this project. It has not been tested yet, but it looks OK at first glance. '''

Copied from http://www.howtoforge.com/debian-squeeze-samba-standalone-server-with-tdbsam-backend

1 Preliminary Note I'm using a Debian Squeeze system here with the hostname server1.example.com and the IP address 192.168.0.100.

2 Installing Samba Connect to your server on the shell and install the Samba packages:

apt-get install libcups2 samba samba-common

You will see the following questions:

Workgroup/Domain Name: <-- WORKGROUP

Edit the smb.conf file:

nano /etc/samba/smb.conf

In the global section, remove the "#" at the beginning of the line security = user so it looks like this:

[...]   security = user [...] This enables Linux system users to log in to the Samba server.
 * 1) "security = user" is always a good idea. This will require a Unix account
 * 2) in this server for every user accessing the server. See
 * 3) /usr/share/doc/samba-doc/htmldocs/Samba3-HOWTO/ServerType.html
 * 4) in the samba-doc package for details.

Close the file and restart Samba:

/etc/init.d/samba restart

3 Adding Samba Shares

Now I will add a share that is accessible by all users. Create the directory for sharing the files and change the group to the users group:

mkdir -p /home/shares/allusers chown -R root:users /home/shares/allusers/ chmod -R ug+rwx,o+rx-w /home/shares/allusers/

At the end of the file /etc/samba/smb.conf add the following lines:

nano /etc/samba/smb.conf

[...] [allusers] comment = All Users path = /home/shares/allusers valid users = @users force group = users create mask = 0660 directory mask = 0771 writable = yes If you want all users to be able to read and write to their home directories via Samba, add the following lines to /etc/samba/smb.conf (make sure to comment out or delete the existing [homes] section!):

[...] [homes] comment = Home Directories browseable = no   valid users = %S writable = yes create mask = 0700 directory mask = 0700 Now we restart Samba:

/etc/init.d/samba restart

4 Adding And Managing Users

In this example, I will add a user named tom. You can add as many users as you need in the same way, just replace the username tom with the desired username in the commands.

useradd tom -m -G users

Set a password for tom in the Linux system user database. If the user tom should not be able to log in to the Linux system, skip this step.

passwd tom

-> Enter the password for the new user.

Now add the user to the Samba user database:

smbpasswd -a tom

-> Enter the password for the new user.

Now you should be able to log in from your Windows workstation with the file explorer (address is \\192.168.0.100 or \\192.168.0.100\tom for tom's home directory) using the username tom and the chosen password and store files on the Linux server either in tom's home directory or in the public shared directory.