How To Resize LVM Software RAID1 Partitions (Shrink & Grow) - Page 3
3 Degraded ArrayI will describe how to resize the degraded array /dev/md1, made up of /dev/sda5 and /dev/sdb5, where /dev/sda5 has failed: cat /proc/mdstat server1:~# cat /proc/mdstat df -h server1:~# df -h pvdisplay server1:~# pvdisplay vgdisplay server1:~# vgdisplay lvdisplay server1:~# lvdisplay
3.1 Shrinking A Degraded ArrayBefore we boot into the rescue system, we must make sure that /dev/sda5 is really removed from the array: mdadm --manage /dev/md1 --fail /dev/sda5 Then we overwrite the superblock on /dev/sda5 (this is very important - if you forget this, the system might now boot anymore after the resizal!): mdadm --zero-superblock /dev/sda5 Boot 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 ... and start LVM: /etc/init.d/lvm start Run e2fsck -f /dev/server1/root to check the file system. /dev/md1 has a size of 5GB; I want to shrink it to 4GB. First we have to shrink the file system on the logical volume /dev/server1/root with resize2fs; the file system is inside the logical volume /dev/server1/root, so the filesystem should be <= the logical volume (therefore I make the file system 2GB). The logical volumes (LV - we have two of them, /dev/server1/root and /dev/server1/swap_1) again are inside the physical volume (PV) /dev/md1 (therefore LV /dev/server1/root + LV /dev/server1/swap_1 <= PV; I make LV /dev/server1/root 2.5GB and delete /dev/server1/swap_1, see next paragraph) which is on the RAID array /dev/md1 that we want to shrink (so PV <= /dev/md1; I shrink the PV to 3GB). As /dev/server1/swap_1 is at the end of our hard drive, we can delete it, shrink the PV and then create /dev/server1/swap_1 again to make sure that /dev/server1/root fits into our PV. If the swap LV is not at the end of your hard drive in your case, there's no need to delete it - you must make sure that you shrink the last LV on the drive enough so that it fits into the PV. So I shrink /dev/server1/root's filesystem to 2GB (make sure you use a big enough value so that all your files and directories fit into it!): resize2fs /dev/server1/root 2G ... and the /dev/server1/root LV to 2.5GB: lvreduce -L2.5G /dev/server1/root Then I delete the /dev/server1/swap_1 LV (not necessary if swap is not at the end of your hard drive - in this case make sure you shrink the last LV on the drive so that it fits into the PV!)... lvremove /dev/server1/swap_1 ... and resize the PV to 3GB: pvresize --setphysicalvolumesize 3G /dev/md1 Now we shrink /dev/md1 to 4GB. The --size value must be in KiBytes (4 x 1024 x 1024 = 4194304); make sure it can be divided by 64: mdadm --grow /dev/md1 --size=4194304 Now I grow the PV to the largest possible value (if you don't specify a size, pvresize will use the largest possible value): pvresize /dev/md1 Now let's check the output of vgdisplay root@Knoppix:~# vgdisplay As you see, we have 383 free PE, so we can recreate the /dev/server1/swap_1 LV (which had 66 PE before we deleted it): lvcreate --name swap_1 -l 66 server1 mkswap /dev/server1/swap_1 Let's check vgdisplay again: root@Knoppix:~# vgdisplay We still have 317 free PE, so we can extend our /dev/server1/root LV: lvextend -l +317 /dev/server1/root Now we resize /dev/server1/root's filesystem to the largest possible value (if you don't specify a size, resize2fs will use the largest possible value)... resize2fs /dev/server1/root ... and run a file system check again: e2fsck -f /dev/server1/root Then boot into the normal system again and run the following two commands to add /dev/sda5 back to the array /dev/md1: mdadm --zero-superblock /dev/sda5 Take a look at cat /proc/mdstat and you should see that /dev/sdb5 and /dev/sda5 are now being synced.
|
Join the discussion.
www.seamlessenterprise.com
IP Convergence
Integrate your wireless and wireline networks.
Learn how from the experts at Sprint.
www.seamlessenterprise.com
Wireless & Wireline Integration
Thoughts, strategies and solutions: join the discussion
www.seamlessenterprise.com
Unified Communications 2009
Join the Discussion. Now.
www.seamlessenterprise.com
Red Hat Virtual Experience - a free virtual event. Dec. 9th





print: 
Recent comments
11 hours 18 min ago
17 hours 6 min ago
18 hours 57 min ago
20 hours 42 min ago
1 day 33 min ago
1 day 6 hours ago
1 day 6 hours ago
1 day 10 hours ago
1 day 16 hours ago
1 day 21 hours ago