Setting personal Home server with Raspberry Pi 3(with updates)



Lately i decided that I don't want my laptop running at all times for trivial tasks, like downloading files, checking mail and so on. Also I had to constantly move files around from my laptop to desktop to mobile phone whenever I needed something. Having a NAS(Network Attached Storage) would solve that issue by keeping all my files in one place. So, I decided to make a home server using my Raspbery Pi 3 that would cater to my needs.

The process is pretty simple.
1. Install Raspbian. Lite will do.
2. Setup Raspbian with ssh and auto login enabled.
3. Setup Samba server.


Installing Raspbian on a Memory Card is pretty straightforward. First using a card reader to connect it with laptop USB. Check device name using df -h. It is usually mounted as /dev/sdb, or /dev/sdb1, /dev/sdb2, ... if you have multiple partitions. Unmount every one of them with umount /dev/sdb. Then I extract the downloaded file to obtain an .img image file.

Use of dd command as follows:

dd bs=4M if=/home/sndp/Downloads/2017-04-10-raspbian-jessie-lite.img of=/dev/sdb


After waiting for 2-3 minutes, terminal finally displays successful message, at which point I enter sync before exiting from the terminal. The card is ready.

On first setup, I had to use a screen(my HDMI monitor) and a keyboard. Login credentials are username:pi and password:raspberry. Now you enter the bash shell as follows:

pi@raspberrypi:$

After playing around with update and upgrade commands for a while, I entered the following in terminal

sudo raspi-config

This is a GUI config in terminal that lets you manage settings for the Pi. I searched for the Boot options and enabled auto login with default user and text-based console.

I checked if ssh was pre-installed in the system. It was. Now I had to setup my home router to give a static IP address to my Pi. I went to the router config page(192.168.0.1) and searched for DHCP reservation. I also noted the MAC address of my Pi and copied it to the clipboard. In my router config page, I set my Pi's MAC address to IP 192.168.0.105. After saving the settings, I was ready to access my Pi from the laptop using ssh. Enabling ssh was pretty straightforward with raspi-config. Finally my headless server was ready.

 I decided to install samba using my laptop, particularly because I wanted to make sure all devices accessed the server including Windows and smartphones. I installed Samba through ssh and rebooted the device, removed the display and keyboard. I connected the LAN cable(I was thinking of using hostapd to create a access point for my own devices, more on this later :D) and booted up the Pi.


Then I used the following command in my laptop

sudo ssh pi@192.168.0.105

As expected, it established a connection and asked for password, which I had changed beforehand from the default one(it used to be raspberry btw). It connected me to the device and returned a bash shell. And now I can control the device from my laptop.

To install samba-server, I followed some of the points from this guide by howtogeek. The article explains how to connect and use external hard drives and use them with RPi. Since I was not using hard disks, I only shared the file system of my memory card. I also made sure the file system was accessible to anyone with username and password for read and write, so I could easily manage files on my server from any of the devices I use.

Update 1 : A small cooling fan.
I have heat sinks installed into my Pi but I feared the board might still be overheating if switched 24 x7(like a regular server). So, I salvaged my old Pentium III CPU and removed the processor cooling fan. I stripped the wires(there were 3) and checked the positive and negative ends using a battery. Next, I cut out USB head from a old damaged Joystick and stripped the wire. I again checked the Vin and GND wires by plugging it in and connecting it to my fan. Then I connected them together and taped the whole thing. Now I have a USB cooling fan powered by one of the USB ports in Pi and sits on top of it cooling my server. 

Comments

Popular posts from this blog

Youtube not working in Vianet NetTV? Here's how you can fix it

Building a news app in react-native using Expo and Express on the Node.js server

Web scraping using BeautifulSoup in Python : EAN number vs price from a German e-commerce website