Linux software RAID
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[1] sdb1[0]
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






RSS Feed
[...] news by panoskrt Firefox 3 Hug Day (for Ubuntu) [...]
» Linux software RAID « : | : vortex of false deceit : | : » Free Software said this on September 16, 2009 at 11:48 pm
[...] Read the original post: Linux software RAID « : | : vortex of false deceit : | : [...]
Linux software RAID « : | : vortex of false deceit : | : said this on September 17, 2009 at 1:02 am
[...] original here: Linux software RAID « : | : vortex of false deceit : | : marketing View admin's Profile Subscribe via RSS [...]
Linux software RAID « : | : vortex of false deceit : | : | Information Technology said this on September 17, 2009 at 1:56 am
[...] See the rest here: Linux software RAID « : | : vortex of false deceit : | : [...]
Linux software RAID « : | : vortex of false deceit : | : said this on September 17, 2009 at 3:06 am
[...] rest is here: Linux software RAID « : | : vortex of false deceit : | : By admin | category: Software!!!? | tags: additional, backup-the-existing, constant-use, [...]
Linux software RAID « : | : vortex of false deceit : | : Software Rss said this on September 17, 2009 at 3:59 am
Nice writeup. Do you know if the two disks have to be identical for this to work?
agorf said this on September 17, 2009 at 7:33 am
Thanks agorf
I don’t think they have to be identical but I guess roughly the same size. Perhaps being identical ensures more smooth mirroring?
panoskrt said this on September 17, 2009 at 8:42 am
Ah OK. I think I once read (or heard) that for RAID, your drives have to be, not identical, but of equal capacity. Maybe that’s for hardware RAID…
agorf said this on September 17, 2009 at 8:55 am
This article has been added to the foss library
tsakf said this on October 22, 2009 at 8:13 am
Thanks tsakf!
panoskrt said this on October 23, 2009 at 12:05 am