- Boot into a rescue CD, like SystemRescueCd, /dev/mdX is not mounted. Use fsck, just to make sure everything is ok with filesystem before any actions.
- Make scrabbing of target partition and repairing if will be need.
A RAID array can suffer from sleeping bad blocks. i.e. blocks that you cannot read, but normally you never do (because they haven’t been allocated to a file yet). When a drive fails, and you are recovering the data onto a spare, hitting that sleeper can kill your array. For this reason it is good to regularly (daily, or weekly, maybe monthly) read through the entire array making sure everything is OK. In 2.6.16 (with complete functionality in 2.6.17) you will be able to trigger a background read-test of the whole array:1echo check > /sys/block/mdX/md/sync_actionIf you were to create an array with –assume-clean, then whenever you run this it will report lots of errors, though you can fix them with
1echo repair > /sys/block/mdX/md/sync_actionIf you are going to be doing that (and I would recommend it) then you may as well allow the initial sync, especially as you can quite happily ignore the fact that it is happening.
- Resize filesystem on the mdadm RAID:
1resize2fs /dev/md0 [size]
where size is a little larger than the currently used space on the drive in filesystem
- After resize2fs, you need to shrink your mdadm array. For example, shrink /dev/md2 to 30GB. The –size value must be in KiBytes (30 x 1024 x 1024 = 31457280); make sure it can be divided by 64:
1
2mdadm --grow /dev/md2 --size=31457280
(size FS <-> MD size <-> New partition size) - Remove one of the drives from the RAID:
1mdadm /dev/md0 --fail /dev/XXX1
- Resize the removed drive with parted. Add the new partition to the drive with parted
- Restore the drive to the RAID:
mdadm -a /dev/mdX /dev/XXX1 - Repeat steps for the other device
- Resize the RAID to use the full partition:
1mdadm --grow /dev/mdX -z max
- Next we grow the file system to the largest possible value (if you don’t specify a size, resize2fs will use the largest possible value) and check:
1
2resize2fs /dev/mdX
e2fsck -f /dev/mdX