Recently I got two Maxtor 80GB disks. Sometimes the existing external hard disk runs out of space but can be easily sorted by erasing unnecessary data. As this external hard disk has been on constant use for around 4 years I thought it might be a good idea to use the additional Maxtors to build a software RAID and backup the existing external disk that stores the data.
My setup is pretty simple as all of the disks are external and connected via USB with the main system. The two 80GB disks are on RAID-1 (mirroring) syncing (via rsync in a cron-job) all the required data from the existing external hard disk. To keep syncing simple, I’ve created two single partitions (/dev/sdb1 and /dev/sdc1) on each of the RAID disks and then created a RAID-1 /dev/md0
I tried two different ways configuring the RAID, one with raidtools2 and one with mdadm.
mdadm is straight forward and can be used directly from the command file as below:
mdadm --create --verbose /dev/md0 --level=raid1 --raid-devices=2 /dev/sdb1 /dev/sdc1 mdadm: chunk size defaults to 64K mdadm: /dev/sdb1 appears to contain an ext2fs file system size=78156192K mtime=Thu Jan 1 01:00:00 1970 mdadm: /dev/sdc1 appears to contain an ext2fs file system size=78156192K mtime=Thu Jan 1 01:00:00 1970 Continue creating array? (y/n) y mdadm: array /dev/md0 started.
There is no need to explain the mdadm parameters as it is pretty much obvious what is happening. A look at the man page reveals all the possible options and what they stand for.
You can also check in /proc/mdstat to see if the RAID is running:
# cat /proc/mdstat Personalities : [raid1] md0 : active raid1 sdc1 sdb1 167772160 blocks 64k rounding
The other way is to use raidtools and declare the raid setup in /etc/raidtab:
$ cat /etc/raidtab raiddev /dev/md0 raid-level 1 nr-raid-disks 2 nr-spare-disks 0 chunk-size 4 persistent-superblock 1 device /dev/sdc1 raid-disk 0 device /dev/sdd1 raid-disk 1
And then the raid can be created:
# mkraid /dev/md0 handling MD device /dev/md0 analyzing super-block disk 0: /dev/sdb1, 78156193kB, raid superblock at 78156096kB disk 1: /dev/sdc1, 78156193kB, raid superblock at 78156096kB
Either way, raidtools or mdadm, you can then create and format partitions on /dev/md0 the normal way, using fdisk and mkfs.ext*. Once done so, the partitions can be mounted as would any other partition and syncing between the external storage disk and the raid can start.
I think that I’ll stick with mdadm as it is easier and more flexible than raidtools.
Some useful links:
How to replace a failed disk on Linux software RAID-1
mdadm: A new tool for Linux software RAID management
The Software-RAID HOW-TO