Nowadays there are lots of options if you want to give your hard drives some independency. Furthermore, for me it seems to be more of a necessity, since my server is built (like you may have previously read) around a Lenovo Thinkpad X61s, therefore I needed to have some kind of external hard drive enclosure.
Well, what’s out there? First of all, there are many enclosures that already contain RAID management. A typical example of such device is a DROBO by Data Robotics.They probably make sense in certain situations, however I was looking at enclosures without any management whatsoever, since the lack of it and the fact that it will require configuration didn’t really scare me much. One other point that should be noted is that I didn’t look for NAS (Network Attached Storage), since in my case I’m using it with a server that is on 24/7, therefore I don’t expect situations when I need the storage, but don’t need my server at the same time.
Technology wise everything is pretty much straightforward: server is running Ubuntu 10.10 (Maverick Meerkat), enclosure holds 4 1TB WD Green drives, which give me 3TB RAID 5 array. Finally, my choice of enclosure fell upon Mediasonic HF2-SU2S2 Pro.
Now, in my case, the actual array building was rather trivial with the exception of the fact that one of my 4 drives had the information that I wanted to keep, so I built the array with 3 drives, copied the info over to the newly created RAID and then added the 4th drive to the array.
Now a little bit of step by step command line code:
fdisk -l
This will give you your the devices that are present in the system, such as /dev/sda /dev/sdb /dev/sdc, etc.
Now, the following assumes that you have mdadm installed on your system, if not – just install it by running this:
sudo apt-get install mdadm
Once it’s installed, we can start with the actual exciting stuff:
mdadm --create /dev/md0 --level=5 --chunk=1024 --raid-devices=3 /dev/sda /dev/sdb /dev/sdc
That effectively tells mdadm to create a RAID 5 array with chunk size of 1024 KB (makes sense for large files), the newly created array will show up as /dev/md0 and it consists of 3 drives /dev/sda, dev/sdb and /dev/sdc accrodingly.
Once you want to add another drive to array you do something like:
mdadm --add /dev/md0 /dev/sdf
mdadm --grow /dev/md0 --raid-devices=4
The first line adds the device to the array, the second one triggers the actual growing process.
While the array is created or in the process of growing you can control the status by running
cat /proc/mdstat
It will show you the progress and estimated time if the array is created, rebuilt or growing. Once it’s in “stable” condition it will show you something like this:
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md0 : active raid5 sdb[0] sde[3] sdd[2] sdc[1]
2930285568 blocks level 5, 1024k chunk, algorithm 2 [4/4] [UUUU]
unused devices: <none>
The other way to see what’s going on is to use mdadm’s –detail key:
mdadm --detail /dev/md0
Here’s what the output looks like for me:
/dev/md0:
Version : 00.90
Creation Time : Sat Mar 5 22:14:58 2011
Raid Level : raid5
Array Size : 2930285568 (2794.54 GiB 3000.61 GB)
Used Dev Size : 976761856 (931.51 GiB 1000.20 GB)
Raid Devices : 4
Total Devices : 4
Preferred Minor : 0
Persistence : Superblock is persistent
Update Time : Tue Mar 8 22:52:24 2011
State : clean
Active Devices : 4
Working Devices : 4
Failed Devices : 0
Spare Devices : 0
Layout : left-symmetric
Chunk Size : 1024K
UUID : 4a187c84:ec54f616:e368bf24:bd0fce41
Events : 0.8877
Number Major Minor RaidDevice State
0 8 16 0 active sync /dev/sdb
1 8 32 1 active sync /dev/sdc
2 8 48 2 active sync /dev/sdd
3 8 64 3 active sync /dev/sde
Well, hopefully everything worked for you and your newly built RAID 5 array is up and running in no time!
p.s. a word of caution – initial build and growing or rebuild (pretty much everything that involves structural/integrity changes) are very time consuming, especially if you’re using USB 2.0, therefore it’s nice to have an option of using eSATA for those kinds of operations (that’s what I did, using my desktop machine – to build an original 3 disk array using eSATA took around 4 hours and to grow it to 4 drives took roughly 20 hours)
