Raspberry Pi: How to make a home server

This post will explain how to turn your Raspberry Pi into a home server, the article i followed to do this can be found here, and is linked at the bottom of this post too.

You will need the latest Raspbian image which is available at the Raspberry Pi Foundations downloads page. You will need to configure a few more things once you have it flashed to an SD card and booted up :

  • Expand Root Filesystem : resizes the default 2GB OS image to fill the rest of the SD card, if you used NOOBS this will be done automatically.
  • Change Password : the default password is “raspberry”, but something more secure would be better.
  • Set your Locale and Timezone.
  • Memory Split : assign the minimum amount possible (16) to the GPU to leave as much room as possible for services.
  • SSH : enable the SSH server.
  • Boot Behaviour : turn off boot to desktop (again, to save memory).

Your Pi should then reboot and you should be greeted by the command line login screen, login with the details you created earlier. Now we need to do a few more things, first create a local user and add them to the sudo and users group :

$ sudo adduser YOURUSERIDHERE

$ sudo usermod -a -G users YOURUSERIDHERE

$ sudo usermod -a -G sudo YOURUSERIDHERE

Next we need to update the system to make sure the latest software is installed :

$ sudo apt-get update

$ sudo apt-get upgrade

Next you are ready to go headless (no monitor) :

$ sudo /sbin/shutdown -h now

Once the Pi is shutdown, remove the keyboard/mouse/monitor from the Pi and connect using SSH from another PC :

$ ssh YOURUSERIDHERE@192.168.0.4

Modify the above command to include the user you created earlier and your Pi’s IP address on your network, then input the password you made for the user when prompted, congratulations you should be connected to your Pi via SSH.

Use the dmesg command to find what your external drive is named, it will probably be /dev/sda. Next we will install automounter to help deal with mounting the external drive :

$ sudo apt-get install autofs

Next we need to edit a few files :

$ sudo nano -w /etc/auto.master

======/etc/auto.master======

/misc /etc/auto.misc

======/etc/auto.master======

And then another file to tell automounter about the external drive :

$ sudo nano -w /etc/auto.misc

======/etc/auto.misc======

storage   -fstype=ext4    :/dev/sda1

======/etc/auto.misc======

Modify the above to include the location of your external drive and the filesystem type used by it. Now we just run these 2 commands :

$ sudo /etc/init.d/autofs restart

$ ls -lat /misc/storage

Then we create a symlink to shorten the path to the drive a little :

$ ln -s /misc/storage /storage

Now we need to install samba and tell it to let your local user have access :

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

$ sudo smbpasswd -a YOURUSERIDHERE

Now we need a multimedia DLNA server so we can play content from the Pi on any client PC/screen in the house :

$ sudo apt-get install minidlna

$ sudo nano -w /etc/minidlna.conf

Here is a pastebin of my minidlna.conf file :

http://pastebin.com/ChQK7mbz

You will need to change the presentation url to the IP address of your Pi on your network. next restart minidlna to implement the changes :

$ sudo /etc/init.d/minidlna force-reload

Test to ensure that minidlna is up by going to http://192.168.0.4:8200/ with a browser, replacing the IP address with that of your Pi’s.

Now we edit a few samba configs to make sure that our file server works with non-DLNA servers :

$ sudo nano /etc/samba/smb.conf

[dlna]

path=/storage/dlna

read only=yes

browsable=yes

public=yes

Now we restart samba :

$ sudo /etc/init.d/samba restart

You should now be able to access the drive over the network from any PC/Laptop/Tablet/Phone/Pi in the house. For a more detailed guide (with details for a static IP and printer sharing/backup) follow the link at the top or bottom of this post. You can download the image of the SD card i made for this project from my sourceforge page  (along with a few other projects):

https://sourceforge.net/projects/pibox/?source=navbar

Enjoy !

Raspberry Pi: the Perfect Home Server | Linux Journal.

Advertisements

2 thoughts on “Raspberry Pi: How to make a home server

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s