RAID (part 2)
I've been meaning to write about my RAID setup for a while. In October I found a deal for $90 300 gig SATA drives so I decided to go ahead and create my RAID with just two disks using RAID 1 (mirrored). This allowed me to get started on the processes of ripping all of my CDs to flac.
I decided to use mdadm instead of raidtools since it's supposedly easier to use and will probably have more support than the older raidtools.
I first created the RAID volume as /dev/md0
Then I scanned the volume to see that it was actually there
Then I checked out /proc/mdstat to see what was going on. It was building the volume
Then I created a filesystem on that volume
So now it was there and working. I transfered a few gigabytes of data to the new filesystem and as it was copying I decided to test the failure case
So the RAID is now in a failure state. As you can see above, only one out of two disks is working properly. So I pretended to remove a disk and add a new one with these commands
I haven't yet figured out how to get this all to come together after a reboot so currently I have to run these commands after a reboot to bring everything back
I decided to use mdadm instead of raidtools since it's supposedly easier to use and will probably have more support than the older raidtools.
I first created the RAID volume as /dev/md0
% sudo /sbin/mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1
mdadm: size set to 293049600K
mdadm: array /dev/md0 started.
Then I scanned the volume to see that it was actually there
% sudo /sbin/mdadm --detail --scan
ARRAY /dev/md0 level=raid1 num-devices=2 UUID=dde6d2cc:f2446c0b:f408b868:d1440f9a
devices=/dev/sda1,/dev/sdb1
Then I checked out /proc/mdstat to see what was going on. It was building the volume
% cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdb1[1] sda1[0]
293049600 blocks [2/2] [UU]
[==>..................] resync = 14.8% (43617664/293049600) finish=65.3min speed=63584K/sec
Then I created a filesystem on that volume
% sudo /sbin/mkfs.ext3 /dev/md0
mke2fs 1.36 (05-Feb-2005)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
36634624 inodes, 73262400 blocks
3663120 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=75497472
2236 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616
Writing inode tables: 689/2236
So now it was there and working. I transfered a few gigabytes of data to the new filesystem and as it was copying I decided to test the failure case
% cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdb1[1] sda1[0]
293049600 blocks [2/2] [UU]
unused devices:
% sudo /sbin/mdadm --manage --set-faulty /dev/md0 /dev/sda1
mdadm: set /dev/sda1 faulty in /dev/md0
% cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdb1[1] sda1[2](F)
293049600 blocks [2/1] [_U]
unused devices:
So the RAID is now in a failure state. As you can see above, only one out of two disks is working properly. So I pretended to remove a disk and add a new one with these commands
% sudo /sbin/mdadm /dev/md0 --remove /dev/sda1
% sudo /sbin/mdadm /dev/md0 --add /dev/sda1
% cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sda1[2] sdb1[1]
293049600 blocks [2/1] [_U]
[>....................] recovery = 1.6% (4721792/293049600) finish=72.9min speed=65906K/sec
unused devices:
I haven't yet figured out how to get this all to come together after a reboot so currently I have to run these commands after a reboot to bring everything back
% sudo /sbin/mdadm --assemble /dev/md0
% sudo mount /dev/md0 /raid0