Thecus N5200 Ubuntu Install #3

Continuation of the installation and configuration guide for Ubuntu on the Thecus N5200 NAS. Initial post here
Original location where I first posted it in 2011 here:*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+

We have already set up our hardware and installed Ubuntu, next…

#===== RAID CONFIG =====#


Useful links:


I can’t overstate how useful the mdadm cheat sheet ( be when dealing with RAID stuff, so make sure and familiarise yourself with it. It will be invaluable when you inevitably have a disk failure in the future.

I like to start with a fresh RAID and restore a backup. Don’t panic though, details of restoring a Thecus RAID are further down.

>>>>> Install required packages <<<<<
apt-get install mdadm lvm2
You will be asked to config Postfix during this install. Just pick the defaults options.

>>>>> Find devices <<<<<
cd /dev
ls -l
– Your devices will be ‘sd*’. e.g. with 5 disks mine are sdb,sdc,sdd,sde,sdf. Just make sure you don’t use your DOM by mistake. You can query individual devices to confirm tehir details with ‘hdparm -I /dev/sd*’

>>>>> List mounted devices to check not already in use (just in case…) <<<<<
df -k
umount /dev/sd** – unmount devices if required

>>>>> Check md0 (RAID mount point) not in use and stop & remove if required (just in case…) <<<<<
cat /proc/mdstat
mdadm –stop /dev/md0
mdadm –remove /dev/md0

>>>>> Adjust partitions <<<<<
fdisk /dev/sd*
-> Useful commands
m = help
p = list partition table
n = create partition
t = change file system
fd = Linux RAID auto mount FS
w = write to disk and exit

For my disks I did:
delete the old partitions (d) – 2 per disk if coming from N5200,
created new partitions (n) – all default options,
changed filesystem (t) to Linux RAID auto mount FS (fd),
check partition table (p),
wrote to disk (w).

>>>>> Create RAID <<<<<
mdadm –create –verbose /dev/md0 –chunk=256 –level=5 –raid-devices=5 /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1 /dev/sdf1

>>>>> Check RAID started okay <<<<<
cat /proc/mdstat

Or you can watch live status of build with: watch -d cat /proc/mdstat
My build took about 10 hours with 5x750Gb disks.

>>>>> Format RAID <<<<<
I’m using the XFS file system since it is apparently slightly faster. Only draw back is that you can’t shrink it, but who would want to shrink a RAID?
mkfs.ext4 /dev/md0
Just change to mkfs.ext4 /dev/md0 for ext4 or stick in ext3 for that too. I also think the N5200 has a problem with ext4, I’m sure I read it somewhere but can’t recall where.

>>>>> Create mdadm.conf file so that Ubuntu remembers RAID details <<<<<
Let’s have a look at the details of the RAID then copy into conf file so that Ubuntu remembers on reboot
mdadm –detail –scan –verbose
mdadm –detail –scan –verbose > /etc/mdadm/mdadm.conf

Notice that examining the RAID (mdadm –examine –scan) gives you an error, so we need to edit the config file and change ‘metadata=00.90’ to ‘metadata=0.90’.
vi /etc/mdadm/mdadm.conf

The examine command should now run without error
mdadm –examine –scan

>>>>> Optional: Have a look at the RAID read speed (I got 268.66Mb/sec on Virtualbox, 104Mb/sec on my N5200) <<<<<
hdparm -t /dev/md0

>>>>> Mount RAID array <<<<<
mkdir /mnt/raid

Configure the fstab file to mount RAID on startup
vi /etc/fstab
/dev/md0 /mnt/raid ext4 defaults 1 2

Now we can mount anything in fstab not already mounted & list mounted devices to confirm that it has been mounted correctly
mount -a 

>>>>> Optional: add symlink for easy access if you want to access RAID via a different path <<<<<
cd /
ln -s /mnt/raid /raid

>>>>> Reboot and see if raid is there <<<<<

If it’s not there you did something wrong! Read some of the links at the top of this section and try to sort it out. Chances are the RAID has been created ok it just hasn’t been configured in mdadm.conf or fstab properly.


This is a fairly generic guide to remounting an existing RAID which should take you through the basic steps. I have used this to recover RAID arrays and it should work fine for the N5200. A working knowledge of mdadm is useful and you can find out all about it using the links in the section above. A very detailed N5200 specific guide is at:

apt-get install mdadm lvm2

>>>>> Find existing RAIDS and assemble <<<<<
mdadm –examine –scan
mdadm –assemble –scan –verbose

cat /proc/mdstat

This might create two arrays, one degraded array with 4/5 disks and a one disk array with the last disk. If that happens stop the one disk array and add the disk to fix the correct array:
mdadm –stop /dev/md_d0
mdadm /dev/md0 –add /dev/sdc1
cat /proc/mdstat (or: watch cat /proc/mdstat)

mdadm –detail –scan –verbose > /etc/mdadm/mdadm.conf

mkdir /mnt/raid

Configure fstab to mount raid on startup. Note that you will need the correct files system noted in here (xfs in this instance). To get your RAID filesystem try ‘sbin/fdisk –l’ or ‘df-h’.
vi /etc/fstab
/dev/md0 /mnt/raid xfs defaults 1 2

-> mount anything in fstab not already mounted & list mounted devices
mount -a 


Useful links:

Hopefully this won’t happen but the point of a RAID array is to allow this without any data loss. You can test a failure before you have any data on your drives by simulating a failure using an mdadm command:
mdadm /dev/md0 –fail /dev/sdXX (see:
mdadm /dev/md0 –fail /dev/sdXX
mdadm /dev/md0 –remove /dev/sdXX
mdadm /dev/md0 –add /dev/sdXX

Onwards to configuring your new server…

Leave a Reply

(email optional)

Warning: Undefined array key "rerror" in /home/public/blog/wp-content/plugins/wp-recaptcha/recaptcha.php on line 291