The hard drive in my father’s computer finally died. It was a 74GB Raptor which was originally mine. He wanted to get his computer running as fast as possible, so I hopped on Newegg and ordered a 320GB drive for him.
For kicks, I decided to see if the drive was still under warranty. To my surprise it was! The drive was about 4 years old. I went through the RMA process and just got a replacement a few days ago.
I figured I would use the drive for my / (root), /home, and swap partitions.
However, on my 2x 750GB HDs I had three raid arrays. One for /boot, / (root), and /home. I wanted to make the /home raid array into /data, but I no longer needed /boot or / (root).
Therefore I need to remove the two unneeded raid arrays and expand the last one, /home.
My RAID 1 Setup looked like this: (2x750GB HD)
- md0 = /boot (250MB)
- md1=/ (root) (20GB)
- md2=/home (640GB)
Goal:
- md0 = /data (680GB)
In order to do this, we need to stop the other raids that we no longer need.
In this case, md0 and md1:
mdadm --stop /dev/md0 mdadm --stop /dev/md1
Look at /dev/md2:
Personalities : [raid1]
md2 : active raid1 sda3[1] sdb3[0]
732571904 blocks [2/2] [UU]
There are two partitions that make up md2: sda3 and sdb3
We need to fail and remove one of the drives in the array. Lets pick sdb3
mdadm -f /dev/md2 /dev/sdb3 mdadm -r /dev/md2 /dev/sdb3
The first command fails the drive and the second command removes the drive.
Once this is done repartition /dev/sdb with one partition (type FD; Linux RAID Autodetect) that uses the whole disk.
Device Boot Start End Blocks Id System /dev/sdb1 1 91201 732572001 fd Linux raid autodetect
Now we need to add the bigger partition back into the array.
mdadm --add /dev/md2 /dev/sdb1
This step will take a long time (2-10hrs; maybe longer) because the array has to resync
You can monitor the progress by running this command: watch cat /proc/mdstat
After the resync finishes, repeat the same steps, but for sda
mdadm -f /dev/md2 /dev/sda3 mdadm -r /dev/md2 /dev/sda3 fdisk /dev/sda mdadm --ad /dev/md2 /dev/sda1
Now we can grow the array by running:
mdadm --grow /dev/md2 --size=max
Lastly we have to expand the file system, but first we want to run a filesystem check to make sure there are no errors.
fsck /dev/md2
And now to resize the filesystem (for ext2, ext3, ext4)
resize2fs /dev/md2
All that is left to do now is modify system files such as /etc/mdadm.conf to get rid of the two unneeded arrays (md0 and md1). Also, I would recommended renaming /dev/md2 to /dev/md0
Leave a Reply