home NAS server 2013 part 2: Ubuntu

In my last installment, I discussed the hardware I was planning to buy for the build of my new home NAS server. Well, I got all the parts within a matter of days and threw the thing together, then spent my spare time over a couple of weekends setting the thing up. In this post, I’ll discuss the basic setup of the OS (Ubuntu server).

Installing Ubuntu Server 12.10

There are a lot of competent Linux distributions out there. I first got into Linux with Redhat in the late nineties, went through a Slackware phase, and finally found something I liked in Debian around 2001. Debian had an excellent package management system (apt), which made keeping all the software on your computer up-to-date. Fast forward a decade, and I’m still there, although with the Debian derivative Ubuntu. Ubuntu has the widest and deepest selection of pre-built software that I know of, and it is still a joy to work with.

Creating a bootable USB install disk

You may have noticed that my new server has no optical drive. So, I had to create a bootable USB stick with the Ubuntu installer. I did this by sticking a cheap 2GB flash drive I had lying around into my OS X 10.8 Mac Mini and then firing up Disk Utility. I formatted the disk FAT with an MBR boot record (GUID won’t allow boot), then added following incantation¬†from the terminal:

# sudo fdisk -e /dev/disk2
f 1

Which (I think) activates the first partition for boot.

Then, I used unetbootin to download and image the installer (ubuntu-12.10-server-amd64.iso) onto the disk. I popped it in the NAS and it booted right up!

Installing Ubuntu

I won’t hold your hand through the entire installation process. I did a no-frills install:

  • selected a hostname (“nasty,” heh),
  • whole-disk LVM on the SSD,
  • only installed OpenSSH server
  • installed grup on the root of the SSD
I rebooted and SSH’d into the fresh installation. I highly recommend using the terminal session management utility byobu, which is a pretty front-end for tmux. It lets you preserve your SSH session (actually, many sessions which you can switch between at will) and reconnect to them whenever you like from different clients. This is nice if you have to leave in the middle of a task, or want to launch a long-running task and detach from it and check back later. Byobu is installed by default in Ubuntu, you just type ‘byobu’ to launch it. I set it to run automatically when I log in with
I then freshened up all the packages with
sudo aptitude safe-upgrade
That's it! Ubuntu installed.

Setting up the RAID volume

There are a lot more options out there for Linux RAID and filesystems than there were a few years ago. The last time I set up a NAS, I tried out ZFS with its whizzy volume management and snapshotting and whatnot, but discovered it was slow, unstable, and RAM-hungry. Before that I’d tried JFS, Reiser, and others. I was always bitten by their immaturity, and a lack of disaster recovery tools. Meanwhile, good old ext has always been reliable if not the most feature-rich. And, perhaps most importantly, ext is always supported by every recovery tool. So I decided to stay simple and just use Linux’s built-in software raid with an ext4 filesystem for my big media volume.

Before setting up a Linux software RAID volume, you should probably do some reading. It’s actually very simple once you figure out what you want, but figuring that out can be a lengthy process. I’ll direct you to the canonical guide that I’ve used several times in the past. For me, it boiled down to a 4-disk RAID5 array (one ¬†disk worth of parity) with a 256KB chunk size (since I mostly have large media files):

mdadm --create --verbose /dev/md0 --level=5 --chunk=256 --raid-devices=4 /dev/sda /dev/sdb /dev/sdc /dev/sdd

And that’s it! Once the creation is started, you can start sticking stuff on the volume right away, so I went ahead and created a filesystem:

mkfs.ext4 -v -m .1 -b 4096 -E stride=64,stripe-width=192 /dev/md0

Here, the ‘-m .1’ reserves just 0.1% of the volume’s space for the root user (down from the default of 5%), and the block and stride arguments are tuned for the raid block size. See this section of the guide for info on how to compute them.

Leave a Reply

Your email address will not be published. Required fields are marked *