Friday, July 11, 2014

Setting up a NAS

My Tonido Plug 1 crashed the other day and unfortunately, Tonido does not provide an updated image of Debian.  The stock image of Ubuntu they provide is horribly outdated and Ubuntu doesn't support ARM, so there is no way to get an updated version without spending a week compiling on the plug computer...

So, I decided to setup a virtual NAS server to run on my HTPC.  The applications I wanted to run are:
  • Tonido
  • Deluge
  • Logitech Media Server (for my Squeeze Box)

 

Setup virtual NAS on Oracle Virtual Box

Install Virtual Box from Oracle -- this is a free virtualization platform
Also install the Virtual Box extensions (also from Oracle and free)

 

Attaching a physical drive on Virtual Box

To attach a physical drive, you have to first create the vmdk
C:\Program Files\Oracle\VirtualBox>VBoxManage.exe internalcommands createrawvmdk
 -filename c:\Users\pc\Documents\vRangadevi\PhysicalDrive.vmdk -rawdisk \\.\Phys
icalDrive3
To get Virtual Box to actually use the disk follow these instructions (from here) if you are running a Windows Host (reproduced below)
  1. Close all open programs or documents on any partition on the disk to pass-through
  2. Run DISKPART (command line utility)
  3. Select hard drive carefully using SELECT DISK. disk numbering starts at zero. you can roughly verify your selection with LIST PARTITION if you know what your partitions should look like or LIST DISK to see disk sizes.
  4. Offline the disk using OFFLINE DISK. all volumes will disappear from windows explorer.
  5. ATTRIBUTES DISK CLEAR READONLY
  6. Verify with ATTRIBUTES DISK
You also need to start virtual box as "administrator"

use VBoxManage modifyhd --type=writethrough

Otherwise, if you use the snapshot feature, all future writes will go to the snapshot instead of the drive

Add the vmdk to the virtual NAS inside Virtual Box

 

Install Debian

I decided to create a second VMDK using Virtual Box to attach to my virtual NAS (and put it on my SSD -- not the physical disk that we just created in the previous step)

To install Debian,
  • Download Debian ISO from their site
  • Create a new Virtual Box instance w/ 512 mb ram, 5gb virtual HDD for the O/S partition (this was what my plug computer was setup with earlier). 
  • Boot off of the ISO and install w/ the following options
    • Select "File Server", "SSH server", and "Standard system utilities" options for packages to install
    • Reboot
su root
vi /etc/apt/sources.list (Comment out the reference to the debian cd)
apt-get update
Edit /etc/fstab to enable automount of physical disk

 

Install applications

apt-get install sudo samba deluged deluge-webui openvpn screen vim

wget http://prdownloads.sourceforge.net/webadmin/webmin_1.690_all.deb
dpkg -i webmin_1.690_all.deb
apt-get install -f -y
  • visudoers (to give your account ability to sudo)
  • vi /etc/samba/smb.conf
    • Change workgroup to your workgroup
    • allow hosts = 192.168.1.*
Add permissions for paths in Samba
[root]
    path = /media/disk2part1/
    browseable = yes
    read only = no
    guest ok = no
    force create mode = 0775
    force directory mode = 0775
    valid users =
Add any other users as needed

 

Setup Deluge

Setup deluge to work with a block-list

 

Install SqueezeBox Server

  • Install SqueezeBox server (Logitech media server)
  • Download from http://www.mysqueezebox.com/download
sudo dpkg -i

 

Install Tonido

wget http://www.tonido.com/download.php?TonidoSetup_i686.deb
sudo dpkg -i
sudo apt-get install -f -y

 

Configure OpenSSL

  • Create conf file with details of vpn provider (name it .conf)
  • Create password file & reference in conf file
  • Edit /etc/init.d/openvpn to add "NAME" variable which contains of conf file
  • To add to system boot list
update-rc.d deluge-daemon defaults
invoke-rc.d deluge-daemon start

 

Setup IP Tables

Setup IP tables as doing so will close unnecessary ports and secure the server To autoload at startup: https://wiki.debian.org/iptables

Install vboxadditions

To install vboxadditions, you need to install header files first...

sudo apt-get install linux-headers-3.2.0-4-486 
mount -t iso9660 -o ro /dev/sr0 /media/cdrom0
/media/cdrom0/VBoxLinuxAdditions.run

Force FSCK to check HDD after every reboot

edit /etc/rc.local and add 
touch /forcefsck
echo "-V -- -v" > /fsckoptions

Install Dante proxy

Dante will enable you to proxy internal network traffic through the vpn tunnel (tun0)

Common URLs/ports for reference

Deluge: http://:8112 
Webmin: https://:10000
Logitech Media Server: http://:9001 
Tonido: http://:10001


No comments: