Operating System - HP-UX
1834134 Members
2170 Online
110064 Solutions
New Discussion

Reducing Logical Volumes and Volume Groups - removing disks

 
SOLVED
Go to solution
Jeff Ohlhausen
Frequent Advisor

Reducing Logical Volumes and Volume Groups - removing disks

Hi,
I'm looking for a consensus on the best strategy to accomplish this goal:
1. I have two volume groups (vg_u1,vg_u2) that contain approximately 400GB and 300GB of disk respectively. However, the actually usage of all the filesystems is approximately 250 and 200GB respectively. I wanted to consolidate the disks being used so that we can remove the unused disks from the array - however, they have already been assigned to the volume group. We have Online JFS version 4 if necessary.

Please help.
Thanks
Jeff
Do or do not - there is no try.
12 REPLIES 12
James A. Donovan
Honored Contributor

Re: Reducing Logical Volumes and Volume Groups - removing disks

You can use the "pvdisplay -v" command on each disk you'd like to remove to see what logical volumes have extents on those disks.

But the exact method of how you go about doing the removal will depend on the configuration of your volume group (striping/mirroring/lvol sizing)....
Remember, wherever you go, there you are...
Helen French
Honored Contributor

Re: Reducing Logical Volumes and Volume Groups - removing disks

Even if 200GB or 250GB are used out of 400GB, there might be a chance that your data is spread across all disks. In that case, it will be little tough cuz you need to reduce the LVs and recreate and restore data. Now if you just want to remove disks, only if there are free (no data), then follow this step:

# vgdisplay -v /dev/vg_u1

Check the PVs on the volume group and do:

# pvdisplay -v /dev/dsk/cxtydz (repeat this for all PVs)

Find the one which are free, then remove it from VG:

# vgreduce /dev/vg_u1 /dev/dsk/cxtydz

repeat the same procedure for /dev/vg_u2.

I would suggest you to backup your data before you do any of these process.
Life is a promise, fulfill it!
John Poff
Honored Contributor
Solution

Re: Reducing Logical Volumes and Volume Groups - removing disks

Hi Jeff,

You have a couple of ways to do it. You can try to reduce the size of the existing logical volumes and then use pvmove to move the remaining extents off of the PVs that you want to reduce.

The other method is to backup everything safely, nuke the volume groups, recreate them with the smaller logical volumes, and then restore your data.

I'd highly recommend the second method. The first method relies on the lvreduce command which is very tricky. The nature of LVM is that the extents that get used are not always continuous. You'll have to use fsadm to try to defrag the filesystems to get all the used extents together, and I've never seen that work successfully. Plus, if the first method totally bombs, you'll wind up using the second method anyway to recover. Might as well cut to the chase and do it right the first time.

JP
Karthik S S
Honored Contributor

Re: Reducing Logical Volumes and Volume Groups - removing disks

Do a vgdisplay -v vgname to identify the PVs that are used in thes VGs, use "pvmove" command to move the data from one PV to the another by which you can free up PVs. And then you can remove the PVs from the VGs.

- Karthik S S

For a list of all the ways technology has failed to improve the quality of life, please press three. - Alice Kahn
Jeff Ohlhausen
Frequent Advisor

Re: Reducing Logical Volumes and Volume Groups - removing disks

Thanks very much for all the help. I believe I will go with the create a new vg and do the restore method.

Do or do not - there is no try.
Jeff Ohlhausen
Frequent Advisor

Re: Reducing Logical Volumes and Volume Groups - removing disks

Hi,
One more question. Each volume group has many logical volumes. What is the best way to go about removing and re-creating the logical volumes? Anyone have any scripting tricks?

Thanks again,
Jeff
Do or do not - there is no try.
Helen French
Honored Contributor

Re: Reducing Logical Volumes and Volume Groups - removing disks

If you are going to get rid of all your LVs, delete the VG instead. You can do this easily by 'vgexport' command:

# umount your_mounted_file_systems
# vgchange -a n vg_name
# vgexport vg_name

You can now start from scratch and recreate all your disks with:

# pvcreate -f pv_raw_name
Life is a promise, fulfill it!
Jeff Ohlhausen
Frequent Advisor

Re: Reducing Logical Volumes and Volume Groups - removing disks

Don't I have to re-size the logical volumes first?
Do or do not - there is no try.
Helen French
Honored Contributor

Re: Reducing Logical Volumes and Volume Groups - removing disks

From your previous post, I assume that you are going to remove the current LVs and recreate it with new defenitions. Is that right? If yes, then you don't need to re-size an existing LV. Just backup your data, remove your current configuration, design your new allocation and create new VGs and LVs.

If you want to keep your existing LVM defenitions, but just want to re-size your LVs, then you need to recreate your existing LVs without removing any. You can follow my original post for that.
Life is a promise, fulfill it!
Jeff Ohlhausen
Frequent Advisor

Re: Reducing Logical Volumes and Volume Groups - removing disks

Thanks for your help Shiju. Basically I want to preserve the mount points and the lvnames but I would like to change the lv size. Any suggestions on an efficient way to do this? I have many lvs and would like to avoid re-creating them all from scratch. I'd rather modify a txt file I've saved or something.

Thanks again,
Jeff
Do or do not - there is no try.
Helen French
Honored Contributor

Re: Reducing Logical Volumes and Volume Groups - removing disks

Well, you need to create your own script for that. First you need to find out what you want to do with each LVs - how much you want to reduce, increase etc. Then you need to make sure that you have enough space/resource available to do that. A loop will be helpful if you are going to allocate same amount of disk space to a group of LVs, but if you are going to allocate different size (and options) for LVs,, a script won't do much good.

For script, do something like this: Put your lv_names in a file, say 'lvnames':

lv=`cat lvnames`
for i in $lvnames
do
your_lvm_command $i options
other_commands_if_needed
done
Life is a promise, fulfill it!
Todd McDaniel_1
Honored Contributor

Re: Reducing Logical Volumes and Volume Groups - removing disks

If you choose to blow it all away and recreate... you will have to key every lvcreate command...

You can save your LV names from your bdf output

## bdf|grep '^\/' |awk '{ print $1 }'


Also, you dont need to remove the VGs only blow away the LVols only...

THEN:

lvremove LVOL
vgreduce /dev/dsk/ctd ## For each disk you want to remove

THEN recreate your LVOLS:

lvcreate -n LVOL /dev/vg01
lvextend -L LVOL disk1 disk2 disk3 etc...

newfs -F vxfs
mount

THEN make sure your mount options are loaded

mount -o remount,


Unix, the other white meat.