Sunday, May 26, 2013

Raspberry Pi NAS

I want to use my Raspberry Pi as Network Access Server in order to download file from torrent and share my hard disk with my home network. 

I have an hard disk with exfat file system. I don't use ntfs because there is an annoying bug that saturate the cpu loads (for info see this).

I download from site of Raspberry Pi the image of the Arch Linux ARM.

Install the image to the memory card

Assume that the memory card is /dev/sdc, and if mounted, umount the memory card.

In order to install the image to the SD I use the "dd" programm
$ sudo dd if=image_of_arch_linux of=/dev/sdc bs=4M

If your screen don't cover all the the TV size you can disable the overscan in the config.txt of the Raspberry
disable_overscan = 1
gpu_mem_512=128
gpu_mem_256=64
In the config.txt you can overclock the Raspberry Pi without affecting your warranty (see this)
#Turbo
arm_freq=1000
core_freq=500
sdram_freq=500
over_voltage=6
I expand with gparted the dimension of the root mount point.

Insert the SD into the Raspberry Pi, plug the ethernet cable and the HDMI cable, turn on the extern hard disk and after turn on the alimentation.

 

First installation

Login into the Rasp with the root user (user: root password: root).

One of the first things that I do is the update of the whole system and reboot
# pacman -Syyu
# reboot

For security reason change the password of the root user
# passwd root

I add new user in order to don't use the root user for my daily work
# pacman -S sudo
# EDITOR=nano visudo
Uncomment the "%wheel ALL=(ALL) ALL" line
Add a new user

# useradd -m -g users -G wheel -s /bin/bash my_user
# passwd my_user

I configure a little bit the ssh daemon
# nano /etc/ssh/ssh_config
set the protocol line to 2 (1 is considered somewhat insecure)
# nano /etc/ssh/sshd_config
change the PermitRootLogin to no
# reboot

Login with the my_user.

$ cd /etc/netctl/
$ sudo cp examples/ethernet-static ./eth0

Set the Static IP in order to redirect the port in my router to the same IP
$ sudo nano eth0
Description='A basic static ethernet connection'
Interface=eth0
Connection=ethernet
AutoWired=yes
IP=static
Address=('192.168.0.130/24')
Gateway='192.168.0.1'
DNS=('8.8.8.8')
$ sudo netctl enable eth0
$ sudo reboot

We can now unplug the HDMI cable and access to the Raspberry Pi through ssh
$ ssh my_user@192.168.0.130

In order to work with my hard disk I have to install the exfat utils.
$ sudo pacman -S exfat-utils fuse-exfat
$ sudo mkdir /media/hard_disk
$ sudo mount -t exfat-fuse -o umask=0 /dev/sda1 /media/hard_disk

$ sudo nano /etc/sysctl.conf 
vm.min_free_kbytes=16184
This last configuration is for a problem of page allocator but in my case does not work.

 

Install Transmission

$ sudo pacman -S transmission-cli
$ transmission-daemon

You can configure transmission as you wish, but if you want a light version of transmission you have to modify the cache size configuration and set to 2 Mb
$ nano .config/transmission-daemon/settings.json

$ sudo cp /usr/lib/systemd/system/transmission.service /etc/systemd/system/
$ sudo cp /usr/lib/tmpfiles.d/transmission.conf /etc/tmpfiles.d/
$ sudo gpasswd -a my_user transmission

To finish the initial configuration I modify the name of the user in this 2 files

$ sudo nano /etc/tmpfiles.d/transmission.conf d
/run/transmission - my_user transmission -
$ sudo nano /etc/systemd/system/transmission.service
User=my_user
$ sudo reboot

$ sudo systemctl start transmission

Samba

$ sudo pacman -S samba

In order to share my hard disk with the LAN
$ sudo cp /etc/samba/smb.conf.default /etc/samba/smb.conf
$ sudo nano /etc/samba/smb.conf

[hard_disk]
        path = /media/hard_disk
        public = yes
        writable = yes
$ sudo pdbedit -a -u my_user


After all this work I backup my configuration with "dd" programm
$ sudo dd if=/dev/sdc of=image_of_backup bs=4M

ddclient 

$ sudo pacman -S ddclient

$ sudo nano /etc/ddclient/ddclient.conf


protocol=dyndns2
use=web, web=checkip.dyndns.it web-skip='Current IP Address: '
server=dyndns.it
login=YOUR USERNAME
password='YOUR PASSWORD'
YOUR HOSTNAME

No comments:

Post a Comment