How To Resize LVM Software RAID1 Partitions (Shrink & Grow) - Page 4

Want to support HowtoForge? Become a subscriber!
 
Submitted by falko (Contact Author) (Forums) on Tue, 2009-01-06 17:58. ::

3.2 Growing A Degraded Array

Before 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
mdadm --manage /dev/md1 --remove /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
modprobe linear
modprobe multipath
modprobe raid0
modprobe raid1
modprobe raid5
modprobe raid6
modprobe raid10

Then activate your RAID arrays...

cp /etc/mdadm/mdadm.conf /etc/mdadm/mdadm.conf_orig
mdadm --examine --scan >> /etc/mdadm/mdadm.conf

mdadm -A --scan

...and start LVM:

/etc/init.d/lvm start

Now we can grow /dev/md1 as follows:

mdadm --grow /dev/md1 --size=max

--size=max means the largest possible value. You can as well specify a size in KiBytes (see previous chapter).

Then we grow the PV to the largest possible value...

pvresize /dev/md1

... and take a look at

vgdisplay

root@Knoppix:~# vgdisplay
  --- Volume group ---
  VG Name               server1
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  29
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               4.75 GB
  PE Size               4.00 MB
  Total PE              1217
  Alloc PE / Size       1023 / 4.00 GB
  Free  PE / Size       194 / 776.00 MB
  VG UUID               X3ZYTy-39yq-20k7-GCGk-vKVU-Xe0i-REdEu0

root@Knoppix:~#

We have 194 free PE that we can allocate to our /dev/server1/root LV:

lvextend -l +194 /dev/server1/root

Then we run a file system check...

e2fsck -f /dev/server1/root

..., resize the file system...

resize2fs /dev/server1/root

... and check the file system 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
mdadm -a /dev/md1 /dev/sda5

Take a look at

cat /proc/mdstat

and you should see that /dev/sdb5 and /dev/sda5 are now being synced.

 

4 Links


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by Anonymous (not registered) on Sat, 2009-01-10 16:55.
It should be "shrink and expand".  "Grow" means to increase by natural development i.e. a tree grows.  I usually ignore these errors but in this case your title doesn't make sense.  If taken literally we would be expected to fertilize and water the partition and it would expand on it's own.