I wanted a media server for my place because my laptop hard drive is pretty small, and I have a bunch of movies and music scattered about on a bunch of external hard drives. I had a few requirements:
- Completely silent. No fans.
- Large storage (~ 3 Tb or more)
- Support backing up to cloud backup service (eg. Crashplan, Backblaze)
I looked at home NAS units but found that they wouldn’t support cloud storage. (Cloud backup guys refuse to back-up network storage, so the system has to contact the cloud server autonomously). This also ruled out the Apple Time Capsule.
The Mac Mini was ruled out for not having sufficient space, and being too expensive for this purpose, given that most of its shiny features would be wasted on a headless system.
Most off-the-shelf PCs featured large power supplies with fans, which was not what I wanted.
So I decided to build a cheap PC from parts.
Mainboard: ASUS AT4NM10T-I
I don’t know what all the gibberish characters mean, but it’s a pretty cheap mainboard with an Intel Atom D425 CPU. It draws very little power and it’s 64 bit and stuff. It has four SATA connectors for hard drives and USB2 or whatever. Curiously it also has a PS/2 mouse/keyboard port, a parallel port, and a COM port. Why? You’d think they’d save some money on components by ditching these features. Whatever.
I guess it also has sound outputs. Oh, and gigabit Ethernet. That’s important.
Hard disk: Seagate 2 Tb “Green” or something
It’s got 2 Tb of storage which is plenty big. It’s 5400 RPM, which is slower than average, but consumes less power and is quieter. That’s important.
I also have a Western Digital 1.5 Tb “Green” hard disk, which I think is a bit louder and power-hungry. That will be the second disk at some point.
Power supply: PicoPSU 160 XT
This is cool: the PicoPSU 160 XT is a tiny, fanless power supply that delivers 160 watts (peak 200 W). That’s quite a bit for a low-power system. I suspect I can get the mainboard and three 3.5” hard disks running from this thing.
The bulk of the power supply is external, like a laptop. I bought it as a kit with the power supply and an external power transformer (110-220 V AC to 12 V DC). The transformer is about the size of the one from the original XBox 360. If you’re not a nerd, that means too big. But it’s fine.
I got Linux from the Internet.
I used Ubuntu Server 10.04 LTS. Basically, Ubuntu is great and so easy to use some people claim it’s “not Linux”. I’d stay away from 11.04, though. From previous experience it’s pretty buggy, and you don’t need bleeding edge for a media server.
As I said, I wanted this to be a headless server, and beside my laptop, I don’t own a keyboard or screen. The challenge was to get a working OS onto the hard disk and then install it in the machine.
To begin, I installed VirtualBox on my mac and set up Ubuntu Server in a virtual machine. (Note: do not use LVM) I bound the virtual hard disk to 8 Gb even though I had a 2 Tb target disk. This is important.
Then, I converted the VirtualBox VDI (virtual disk image) to RAW format. The command is basically this:
VBoxManage internalcommands converthd hard_disk.vdi hard_disk.raw
That gives you an 8 Gb file.
Next, I connected my 2 Tb hard disk to a USB drive enclosure and plugged it in. OS X complained about the unformatted drive, but I told it to shut up. The disk appeared at /dev/disk1 (note: sometimes it was /dev/disk2. If you are doing the same thing as me, this right here is the first step that could hose your laptop if you do it wrong. Make sure you pick the right disk.)
Using the magical dd command, I dumped the raw disk file onto the physical hard disk.
dd if=hard_disk.raw of=/dev/disk1
This took a while.
(Astute readers might wonder why I didn’t direct VBoxManage directly onto the disk. That’s because VBoxManage is a jerk and refuses to write to an existing file.)
Problem: now we have a 2 Tb hard disk with an 8 Gb partition table. Oh, and Apple’s partition table is different from Linux so it’s dicey to go and change it there.
Solution: we need to mount the disk in Linux. It’s possible, albeit slightly insane, to mount a physical disk in a VirtualBox image. Here’s the magic command to do it:
VBoxManage internalcommands createrawvmdk -filename disk.vmdk -rawdisk /dev/disk1
Then I booted disk.vmdk into VirtualBox and got my Linux. Easy.
From there I was able to use fdisk and fiddle with the partition table. The most important tip here is to ensure the starting cylinder/byte of your root partition is unchanged. Swap and stuff can be fixed later.
# In your virtual terminal: sudo fdisk /dev/sda
After a reboot your partition is bigger but the filesystem is still at 8 Gb. Now you must tell the filesystem to fill the extra space. Linux has an insane feature that lets you resize a filesystem while it is running. No really. Crazy shit.
sudo resize2fs /dev/sda1
This took, like, four hours. Remember, we’re on a slow-ass USB disk here. You could do this after the disk is installed in the media server, actually. Probably would have been smarter.
Finally, I connected the hard disk to the mainboard. I needed an enclosure.
As previously mentioned, all the small enclosures on the market are too small for 3.5” disks, and those that are big enough come with noisy fan-filled PSU’s. I grabbed a shoebox and some duct tape (fact: most duct tape is non-conductive because it’s actually duck tape). I shoved all the pieces in there.
The last step was convincing the mainboard to boot. See, I didn’t have a power button. I looked in the manual and found the power button pins on the mainboard. Then I shorted those pins with a copper coin. The system started up.
(Fact: booting a PC by shorting pins on the mainboard is basically the most bad-ass nerdy thing you can do).
The system booted and didn’t appear on the network. Crap.
I disconnected the disk, reattached it via USB and booted in a virtual box again. By examining logs I found that Ubuntu got confused by the new network adapter and gave it a port of eth1, which was not configured. I modified /etc/network/interfaces and added these lines:
auto eth1 iface eth1 inet dhcp
This finally convinced the PC to connect to the network and I could ssh to it and finish the install.
It works! The thing lives!
I still need to configure Crashplan for offsite storage, and install the second hard disk, but basically the experiment was a wonderful success.