Friday, 18 April 2014

HP Proliant Microserver - The Ubuntu Solution

Using a HP Proliant Microserver as an Ubuntu file server with RAID5 … for free


I originally wrote a forum post in 2011 on my efforts to create a RAID capable file server for my media centre set up. I’ve now written this blog post so it can more easily be referenced. The HP Microserver is a wonderful little machine, and often being sold with £100 cashback. 
In short my requirements were
  • A small but large capacity file server.
  • Remote admin access as the server would sit “headless” behind the TV.
  • RAID5 capability to give some fault tolerance to the file system.
  • Wanted it to be accessible to my home network where most machines run Windows
  • I didn’t need the server to have graphics/video capability as I would be using another device to run XBMC.
  • Fast and reliable streaming of files from the server to my XBMC media player – actually Openelec.
The HP Microserver fits the bill perfectly. What I was surprised about though were the number of people posting on forums that felt the need to run Windows Server, install more memory, or use expensive RAID cards. Surely something like Ubuntu would do everything I needed without having to spend more money on software and hardware. Well the answer was a resounding “yes”. Read on to see what I did. 
Firstly I’m no Linux expert so much of what I did was researched with a tiny bit of trial and error. 

My bill of materials was
  • x1 HP Microserver N36L with 1GB memory and a 250GB hard drive pre-installed. 
  • x1 HD bracket so I could mount the 250GB HD in the 5.25inch top bay.
  • X1 IDE to SATA power cable to convert the power so I could plug in the 250GB drive in the top bay.
  • x4 Seagate 2TB HDs

Basic hardware set up

It’s a simple process to move the 250GB drive from one of the caddies to the top bay using the brackets and the power cable. This meant I could then install each of the 2TB drives in the caddies.

Installing Ubuntu and Webmin 

1) Firstly, remove the x4 2TB hard drives to avoid confusing things whilst installing Ubuntu. At the time of writing these instructions I used Ubuntu Server x64 10.04.02 LTS (Long term support). Once you’ve downloaded the iso file you can use something like “Universal USB Installer” to create a USB stick. I chose the LTS version because I wanted stability and once up and running I didn’t want to mess around have to upgrade versions. 

2) Use the USB stick to boot the Microserver and install Ubuntu on the machine. It’s all very easy to set up the installation. But make sure you select Samba and OpenSSH packages on this screen.

These two packages will let you access the server files shares from Windows and to “telnet” in to a command prompt from another machine. This will mean you can run the server headless (ie, without needing a keyboard or monitor).

When it comes to installing the grub bootloader, make sure you specify the HD disk device (/dev/sdb) and not the USB stick (/dev/sda) otherwise it won't boot when you remove the USB stick.

3) On the next boot this should get you to a text based login prompt. But if you’ve installed OpenSSH you should be able to access the server from another machine on the network. I use putty from a windows machine to manage the server from a command line. 

4) Next thing I did was install webmin so I could administer the server through web pages. For me - as a newbie - this is a bit easier than using the command line all the time. Use the Debian package for Ubuntu. This page explains the process

Once webmin is installed you can then administer the server remotely from the following address

It will look like this. 

Have a look around. You can do most things from the web interface and there is little need to resort to the command line once the server is set up. Note how light weight Ubuntu server is. It will run comfortably in 1GB of ram.

Setting up the RAID array

You now need to set up your preferred file system software. After lots of googling it came down to using XFS or ZFS for me. I chose XFS in the end. There doesn't seem to be much in it. But it looked like ZFS had a higher memory footprint.

1) Firstly, install the RAID tools. This is the software that lets Ubuntu and most linux systems to run software based RAID. I wanted software RAID as it is widely supported on linux systems and I’m not locked in to some piece of hardware that could go end of life.

sudo apt-get install mdadm

2) Then install the SMART monitoring tools for HDs. Once installed you can “refresh modules" in webmin and you’ll see a new option under the “Hardware” menu that lets you review SMART status for each hard drive.

sudo apt-get install smartmontools

3) Install the file system tools. As I said above I chose to use XFS
sudo apt-get install xfsprogs

4) Then shutdown the server and plug in the x4 hard drives. Then restart and log back in.

5) At this point, do some backgroud reading on RAID arrays and the use of mdadm. I found this page particularly useful

6) Use webmin to create the array (/dev/md0) using the Linux RAID module (under the "Hardware" menu). You need to select "Redundant (RAID5)" from the drop down and then click the "Create RAID device of level:" button.

It takes a while to build the array. You can use this command to watch progress
sudo watch cat /proc/mdstat

7)  Then format that RAID array with the following command

sudo mkfs.xfs /dev/md0

Again, this takes a while and you can't mount the /dev/md0 until it's done.

8) Now you have a device called md0 which is the formatted RAID array. To make proper use of it, the devie needs to be mounted in to the file system. Use webmin again to mount the device as /media/md0. You can do this under "Disk and Network Filesystems".

9) Finally webmin again to use Samba to share the 5.5TB (!) array on the network. You can do this under "Samba Windows File Sharing".

Monitoring and Disk Failure

Before I filled the RAID array I tested what happens when a disk fails by simply pulling out one of the 4 drives while the server was running. The Linux RAID module in webmin displays in red when a disk has failed. You also get notified by Ubuntu during a boot if one of the disks has failed. But being RAID5 everything will still works as expected. When the disk was plugged in again (ie, replaced in the real world), then the disk is recovered automatically without having to type anything. The following command shows progress during recovery. Recovery of a 2TB disk does take a few hours though.

sudo watch cat /proc/mdstat

All very impressive. I was surprised that reinserting the same disk meant it was treated as a new disk (prompting it to be fully recovered), rather than the same one being replaced.


Essentially, that is it. I originally wrote this post in 2011 - it is now 2014 and the server has been running with no major issues. If you're using the file server with something like Openelec then you should create an NFS share for the array rather than just a Samba share as it's faster when sharing between linux machines.

In terms of performance if I plug a windows machine in to the (gigabit) LAN then I can transfer files at 90+MB/s to the md0 files share. The server barely breaks a sweat. You get some CPU usage when moving large files around as the CPU is calculating parity and striping files across the disk. But it's not CPU or memory bound at all given my usage with is basically streaming video and music around the house.

See below for other enhancements you can make.

Disabling each disks write cache

After reading lots of webpages on XFS, it seems that write barriers (used by XFS to periodically flush the write cache to minimise loss of data - should there be a power failure - don't work on RAID arrays. So the fall back is to disable each disks write cache. This should minimise and data loss problem if you have a power failure whilst writing files to the disk. To do this you need to

sudo nano /etc/hdparm.conf

and uncomment the write_cache = off line to read as follows

# -W Disable/enable the IDE drive's write-caching feature
write_cache = off

Then reboot and the write caches will be disabled. Further reading here

Email alerts

I wanted to run an IMAP server on the Proliant and have mdadm send (email) any alerts about the array. These email alerts would then be picked up by other client machines in the house (eg, using Outlook). To do this I needed to install postfix (the mail system) and dovecot (to support POP or IMAP mailboxes).
sudo aptitude install postfix
sudo apt-get install dovecot-imapd

Then run the following and use all the defaults to set the initial configuration. Further detail at

sudo dpkg-reconfigure postfix
sudo postconf -e 'home_mailbox = Maildir/'
Then go in to webmin and click the "Refresh Modules" link and Webmin will find that you've installed dovecot. Then under the "Servers" tab you'll find a link for dovecot, click on "Dovecot IMAP/POP3 Server" and then on the "Mail Files" icon. You need to change the "Mail File Location" setting to "Inbox and folders in ~/Maildir". Finally, you need to have mdadm send alert emails to the right address. So under the "Linux RAID" settings in webmin set alerts to go to "user@server". Where "user" is your normal login and server is the machine name. There is no .com or anything as this is a machine on you local network.

To have mdadm send a test message. Use the following

sudo mdadm --monitor --scan --test --oneshot

On you email client (I use Outlook), your IMAP settings need to be

username = user (as above)
email address = user@server
incoming mail server = "server" (as above)

You should then find the test message in your inbox.

1 comment:

  1. Great post, now linked to from a HotUKDeals thread on the N54L microserver!