Goal

The name of the game is getting a minimum maintenance RAID server up and running. The OS should be bootable from an USB stick and the RAID disks will be SATA disks.

Installation and setup

This section handles the initial installation and setup procedure. By keeping the OS small (and on USB) it will (hopefully) make backups and restores more easy,

USB stick First install Debian/Ubuntu on the USB stick. I created two partitions on the 512 MB sized stick: /boot and /.

Where /bootr is 100 MB, which is probably a bit large. Use ext2 (not a journaling filesystem! As this ages the flash stick too much). Next use debootstrap to install to OS. I’ve kept the install down to about 300 MB, by only installing the essentials and removing unneeded cruft.

I’ve followed this site to install Ubuntu on the stick.

Booting Luckily my system allows me to boot from USB so this all worked nicely; and I can login into my new (soon to be) fileserver system.

The only problem was that any SATA disks were detected before the USB flash disk. Depending on the number of disks, the USB disk would be /dev/sda (with 0 disks) or /dev/sdd (with 3 disks)

This would make it impossible to set the root device in grub and /etc/fstab. I solved this by using the device names from /dev/disk/by-id/, in this case:

/dev/disk/by-id/usb-_USB_FLASH_DRIVE_19661A000079-part2

This name can also be used in /etc/fstab. Linux will automaticly convert this into the correct /dev/sdX. This kind of stuff makes me happy.

SATA hardware I’ve bought two promise TX 2 SATA controllers, with 2 SATA ports. This gives me a total of 4 ports. I need 3 ports to start with. These work fine with Ubuntu.

The harddisks are mounted in a Chieftec SATA disk bracket. This allows me to easily remove faulty disks from the RAID array. And it has nice lights on the front. And a fan to keep the disks cool.

Remote logging To safe the flash drive it is advised to forward all logging to another host. This is really simple to setup, google for it.

Setup RAID

For setting up the RAID array I’ve looked at the following sites:

They sort-of helped, but looking at mdadm’s manpage gave me the info I needed. It boiled down to the following:

Fdisk the disks:

fdisk /dev/sd?

set the disk type to 0xfd. This is for autodetection (I’m not using this currently).

Then create the RAID-5 array:

mdadm --verbose --create /dev/md0  -c128 -lraid5 -pls -n3 /dev/sda1 /dev/sdb1 /dev/sdc1

Create a filesystem:

mkfs.xfs /dev/md0

And that is it – only an emergency procedure remains.

NFS, setup and mountpoint The raid array is mounted under /raid. This directory is suid with the group name ‘shared’.

This directory is exported using the kernel NFS server.

Tweaks

I’ve choosen not to install cron as this is not needed for such a simple machine. I did install:

  • munin, get statistics about the server
  • monit, monitor important processes, mdadm for instance.
  • ntp, time synchronisation
  • smartmontool, extra disk monitoring
  • postfix, email allerts, etc.

Also, with lots of effort I got munin to monitor my SATA disks with smartctl.