From Wiki-UX.info

Wiki-UX / Logical Volume Manager / How to quickly relayout a logical volume
Jump to: navigation, search

How to quickly relayout a logical volume

Abstract

This article presents a way to quickly relayout a volume group. It's particulary useful when the volume group has a large number of physical volumes and you don't want to manually issue the pvcreate and vgextend commands for all the involved physical volumes.

LVM volume disk relayout may be required on LVM 1.0 volume groups where incorrect PE size or Max PE per PV settings was used at creation time and and new settings will be needed. This article does not cover how to backup the file system or raw devices before the LVM relayout.

Contents


Procedure

1. Check the current volume group file HEX number.

# ll /dev/<vgname>/group

2. Create a list of volume group current physical links. Verify the list.

# strings /etc/lvmconf/<vgname>.conf | grep dev > /pvlist
# cat /pvlist

3. Export the volume group out of the system.

# vgexport -m /<vgname>.map <vgname>

4. Use the following loop to overwrite the LVM metadata on every physical path that belonged to the volume group.

for pv in $(cat /pvlist)
do
   pvcreate -f $pv
done

5. Create the volume group with the new LVM settings. Use the first physical volume on the list as the first disk.

# mkdir /dev/<vgname>
# mknod /dev/<vgname>/group c 64 0x##0000
# vgcreate [-f] [-A autobackup] [-x extensibility] [-e max_pe]
           [-l max_lv] [-p max_pv] [-s pe_size] [-g pvg_name] vg_name
           pv_path

For example:

# vgcreate -s 32 -p 32 -e 5000 /dev/vgdata $(head -n 1 /pvlist | sed 's/\/r/\//')

6. Use the following loop to extend the volume group to the rest of physical volumes.

for pv in $(tail -n $(expr $(wc -l /pvlist | cut -d " " -f 1) - 1) /pvlist | sed 's/\/r/\//')
do
   vgextend <vgname> $pv
done

7. Recreate the volume group logical volumes.

# lvcreate -l | -L <size> <vgname>

8. Recreate the filesystems as required.

# newfs -F vxfs [-o largefiles] /dev/<vgname>/<lvol_name>

Reference

Authors

This page was last modified on 3 August 2011, at 19:41. This page has been accessed 1,600 times.