My 120€ Mini ITX Ubuntu Linux 12.04 Home server

I've several computers at home, a non-ethernet printer, a router, some spare hard disks, I think it is a pretty common situation nowdays, but I didn't have a NAS, a print server or a Media Center HTPC. So this is an overview about what can do and how to configure a low-power Linux Server available 24h/24h.

Fanless 10w CPU mini-itx Intel D425KT mobo + sata-esata cable for the external esata hard disk. The case is Morex T-3500 60w.

Hardware

Your home server could be an unused notebook or desktop, but I chose to buy a new fanless 10 Watt mini-itx system. Others important features are sata/esata support (or another high speed connection USB 3.0 or Thunderbolt) in the mainboard and Hard Disks and Wake-on-LAN support in the ethernet card to wake up the server on demand (It's pretty common nowdays).

Which Linux distro for an home server?

I choose Ubuntu 12.04 alpha 2, because it has LTS (Long Time Support) and because I needed the recent netatalk 2.2 to backup a Macbook Air with Mac OS X 10.7 Lion.
If your computer has less than 2gb RAM or an old CPU I suggest the Lubuntu variant, It support the same softwares of Ubuntu but the plain desktop (lxde) is much more essential and responsive.

Which partition format for the operative system and the data?

The OS can be ext4 or btrfs if you like the experiments, but for the data like photo, movies, music, I suggest NTFS. Sadly the Linux filesystems are boycotted by modern TVs and other embedded gadgets which only support FAT32 and NTFS (even if mostly of them are Linux based).
If don't care or you can't plug your data directly to a different USB port, forget it, and choose a Linux filesystem also the data. Another tecnique is streaming the data via protocols like DLNA/uPnP and xbmc.

Now let's analyze some cool server tasks you can do with a computer like that.

Remote Administration Access

SSH & Avahi

After the first setup probably this PC will never see a physical keyboard an monitor again, because the main aim is to control it remotely from other computers. So let's install SSH which is the most used way to control a server.

sudo apt-get install openssh-server

For the other pc you trust, you can also access to the Home Server without a password but only with an ssh key. Ubuntu enable by default also Avahi (Bonjour on osx), which simplify the discovery of the other hosts inside the LAN. So if you don't want to type the ip address and set it fixed in a DHCP server you can alwais type:

ssh my-home-server-hostname.local

An alternative to the classic ssh which requires a public open port, is ajaxterm which is a terminal console over web HTTP.

Enable the default VNC Server

Ubuntu by default provides a VNC server for a graphical access (vino-server). X isn't very needed for a classic server because you can also use Web GUIs for specific tasks, but if your server is quite powerful I recommend it.

Keep in mind it need an autologin user to be enabled after a system restart and by default it isn't a secure encrypted connection. To secure VNC over a ssh tunnel you can set to run vino-server only via a local port and forward the traffic to a public and secure port.

To lock the X session after the autologin you can run the command below after logging in.

gnome-screensaver-command --lock

Anti segfault crash application script

You know, the apps sometime crash. In a desktop environment you see it and rerun the app, but in server?
A very simple way to ensure that an application will keep running is to wrap it an infinite loop

while true; do amule; done

Where "amule" is an app you want to keep alive.

Energy Saving

If nobody is using the server it doesn't have to be active. Energy saving is an important topic because you can switch on the server remotely only when you need it. 

Wake on LAN and standy

To enable WoL on your ethernet card you have to type a couple of commands (Persistent way).

sudo apt-get install ethtool
sudo ethtool -s eth0 wol g
sudo ethtool eth0|grep Wake-on: 

Last command should output "g" if Wake on LAN is enabled, then you need a software live gWakeOnLan or WakeOnlan (mac) to send the magic wake up packet. 
Via the power managment GUI is possible to set the inactivity time before the system standby or you can force the status with:

sudo pm-suspend

Hard Disk standby with hdparm

This is a very risky setting because the suggestion is to stop the hd from spinning only for long time of inactivity. You can test the many hdparm options after reading "man hdparm" or some real world examples and then tune the config file.

#/etc/hdparm.conf
/dev/sda {
spindown_time = 50
}

The current drive status is availaible via

sudo hdparm -C /dev/sda

File Sharing and backup

Samba

It is the most common way to share files in LAN over Linux, Mac or Windows PCs. You can edit the configuration file manually to share the folders in a persistent way (VNC/X indipendent) or You can set up the folders via the active VNC user.
The default user management tool doesn't allow advanced user configuration, so to run "sudo users-admin" another package is required

sudo apt-get install gnome-system-tools

Backup via Unison or DropBox -like

Unison is a smarter Rsync (see the comparison) because it recornize the files moved and it is available on Linux, Mac and Windows without much effort. If you like a more dropbox approch you can host a copy of Sparkleshare.

Time Machine support

If you want to do a full backup of a Mac OS X system, you can easly set up the server to behave like a Time Capsule

sudo apt-get install netatalk

It's the network protocol used by Apple (I suggest netatalk >= 2.2.1 for compatibility with osx Lion 10.7), then you define the folder used as Time Machine disk.

# /etc/netatalk/AppleVolumes.default
--cut--
/my-backup-dir/of-timemachine/ "Time Machine on Server" cnidscheme:dbd options:tm

Then

sudo service netatalk restart

A Time Machine drive should be visible in the Time Machine settings

Conclusion

These are just a few ideas how an home server could be useful in your LAN. There are also a lot of Web GUIs that I didn't covered or Dynamic DNS (like no-ip, dyndns). Emule/Amule, uTorrent, Transmission, Ajaxplorer (a web File Manager) are all interesting services which could be available in your Home Server and over the web.

Happy Freedom box!

commenti

(S)funzionamento del blog

Ciao Luigi, ti seguo da un po e spesso ho dei problemi con i post. In pratica capita che accedendo con sistemi operativi diversi o con browser diversi mi ritrovo come ultimi post dei post vecchi oppure il numero di commenti segnalato è differente dal numero reale.
Ad esempio ora sono su ubuntu con firefox e l'ultimo post è questo inoltre in fondo all'articolo c'è scritto 3 commenti anche se in realtà ne vedo 6. 1 ora fa ero con windows e l'ultimo post è giustamente quello in cui mostravi il netbook da mediaworld con e senza windows.
A volte mi capita il contrario su windows vedo dei post vecchi e su ubuntu quello giusto. Ho provato anche con chromium e mi si verifica lo stesso problema.
Non so se è un problema mio, anche se una volta avevo provato a cancellare la cache e il problema c'era lo stesso, o c'è qualche impostazione sbagliata nel tuo blog.
Scusami se ho fatto qui questa segnalazione ma l'ho fatto anche per chiedere agli altri utenti se hanno lo stesso problema.
Ciao

Segnalazione

Ciao Luigi
Grazie per la segnalazione, il problema potrebbe essere dovuto al caching del sito lato server o lato client
Per vedere la home page aggiornata puoi provare con:
- premere sul pulsante aggiorna (banale)
- richiamare il sito con http://grigio.org/?pippo o un'altra sequenza di lettere

Se con quest'ultima tecnica non risolvi ancora, fammelo sapere che investigherò meglio.

Grazie a te! Si

Grazie a te!
Si effettivamente prima utilizzavo proprio F5 per risolvere il problema. Giusto per completezza ho provato anche il secondo metodo è funziona!
Ho modificato quindi il segnalibro in modo tale da non dover premere sempre F5.
Ciao

Case

Ma quel case l'ho trovato su amazon ad un prezzo di 120$.
Dove lo poso trovare allo stesso prezzo che lo hai pagato?

Case Morex t3500

Ho provato a cercarlo sul sito web del negozio dove l'ho comprato, ma non c'é.
A me è venuto a costare quella cifra perché me l'hanno dato come sostituzione di un altro case, comunque dovrebbe costare tra i 60 e 90€.

Su amazon è a 89$
http://www.amazon.com/Morex-T3500-Mini-ITX-DC-DC-Adapter/dp/B005PIDBDU

Quanto consuma la macchina a

Quanto consuma la macchina a pieno regime? Cmq complimenti per il lavoro

Con un video 720p in play e

Con un video 720p in play e diversi servizi attivi fa 20w (hd escluso), 16w a carico normale e meno di 2w in standby.
Quindi consuma più o meno come un netbook, ma ha la connessione esata (che era il requisito che cercavo principalmente).
Grazie per i complimenti, ciao!

Interessante!

Interessantissimo post!
Dove hai comprato l'hardware? Qualche link?

Grazie!

Ho comprato i pezzi in un

Ho comprato i pezzi in un negozio che fa pc assemblati nella mia città. Qui c'é qualche negozio su internet http://bit.ly/ylLO4Y . Comunque non credo sia particolarmente difficile trovare la mobo e il case perché entrambi sono standard Mini-ITX.