How To Resize RAID Partitions (Shrink & Grow) (Software RAID)
How To Resize RAID Partitions (Shrink & Grow) (Software RAID)Version 1.0 This article describes how you can shrink and grow existing software RAID partitions. I have tested this with non-LVM RAID1 partitions that use ext3 as the file system. I will describe this procedure for an intact RAID array and also a degraded RAID array. If you use LVM on your RAID partitions, the procedure will be different, so do not use this tutorial in this case! I do not issue any guarantee that this will work for you!
1 Preliminary NoteA few days ago I found out that one of my servers had a degraded RAID1 array (/dev/md2, made up of /dev/sda3 and /dev/sdb3; /dev/sda3 had failed, /dev/sdb3 was still active): server1:~# cat /proc/mdstat I tried to fix it (using this tutorial), but unfortunately at the end of the sync process (with 99.9% complete), the sync stopped and started over again. As I found out, this happened because there were some defect sectors at the end of the (working) partition /dev/sdb3 - this was in /var/log/kern.log: Nov 22 18:51:06 server1 kernel: sdb: Current: sense key: Aborted Command So this was the worst case that could happen - /dev/sda dead and /dev/sdb about to die. To fix this, I imagined I could shrink /dev/md2 so that it leaves out the broken sectors at the end of /dev/sdb3, then add the new /dev/sda3 (from the replaced hard drive) to /dev/md2, let the sync finish, remove /dev/sdb3 from the array and replace /dev/sdb with a new hard drive, add the new /dev/sdb3 to /dev/md2, and grow /dev/md2 again. This is one of the use cases for the following procedures (I will describe the process for an intact array and a degraded array). Please note that /dev/md2 is my system partition (mount point /), so I had to use a rescue system (e.g. Knoppix Live-CD) to resize the array. If the array you want to resize is not your system partition, you probably don't need to boot into a rescue system; but in either case, make sure that the array is unmounted!
2 Intact ArrayI will describe how to resize the array /dev/md2, made up of /dev/sda3 and /dev/sdb3.
2.1 Shrinking An Intact ArrayBoot into your rescue system and activate all needed modules: modprobe md Then activate your RAID arrays: cp /etc/mdadm/mdadm.conf /etc/mdadm/mdadm.conf_orig mdadm -A --scan Run e2fsck -f /dev/md2 to check the file system. /dev/md2 has a size of 40GB; I want to shrink it to 30GB. First we have to shrink the file system with resize2fs; to make sure that the file system fits into the 30GB, we make it a little bit smaller (25GB) so we have a little security margin, shrink /dev/md2 to 30GB, and the resize the file system (again with resize2fs) to the max. possible value: resize2fs /dev/md2 25G Now we 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: mdadm --grow /dev/md2 --size=31457280 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)... resize2fs /dev/md2 ... and run a file system check again: e2fsck -f /dev/md2 That's it - you can now boot into the normal system again.
2.2 Growing An Intact ArrayBoot into your rescue system and activate all needed modules: modprobe md Then activate your RAID arrays: cp /etc/mdadm/mdadm.conf /etc/mdadm/mdadm.conf_orig mdadm -A --scan Now we can grow /dev/md2 as follows: mdadm --grow /dev/md2 --size=max --size=max means the largest possible value. You can as well specify a size in KiBytes (see previous chapter). Then we run a file system check... e2fsck -f /dev/md2 ..., resize the file system... resize2fs /dev/md2 ... and check the file system again: e2fsck -f /dev/md2 Afterwards you can boot back into your normal system.
|
www.seamlessenterprise.com
One number. One voicemail. Seize the lead. Sprint Mobile Integration.
www.seamlessenterprise.com
One Number. One Voicemail.
Make it easier for clients to reach you. Turn your desk phone and mobile phone into one with Sprint Mobile Integration.
www.seamlessenterprise.com
One number. One voicemail. Sprint Mobile Integration.
www.seamlessenterprise.com
AT&T Synaptic Compute as a Service. Boost your power on demand.
Trial: IBM Cognos Express Reporting, Analysis & Planning




print: 

Recent comments
1 hour 3 min ago
1 hour 15 min ago
2 hours 22 min ago
6 hours 38 min ago
7 hours 8 min ago
21 hours 4 min ago
1 day 5 hours ago
1 day 12 hours ago
1 day 15 hours ago
1 day 17 hours ago