Operating System - HP-UX
1833784 Members
5124 Online
110063 Solutions
New Discussion

A simple question about removing a vg

 
Bill Meng
New Member

A simple question about removing a vg

Hi,
I'm learning LVM.I found the following words in my studen workbook
"vgremove VG
* VG must have only 1 PV left in it and this must be unused"
What does it mean?
Time is a bird forever on the wing
7 REPLIES 7
S.K. Chan
Honored Contributor

Re: A simple question about removing a vg

Lets take an example .. say I have vg01 with 2 PVs in it.
# vgdisplay -v vg01
--- Volume groups ---
VG Name /dev/vg01
VG Write Access read/write
.....
Cur PV 2
Act PV 2
......
--- Physical volumes ---
PVName /dev/dsk/c2t10d0
...
PVName /dev/dsk/c2t12d0
..
Now assume all the logical volumes have been removed and you're left with 2 physical volumes (or physical disks). In order to vgremove vg01 you have to vgreduce the PVs from the VG until only 1 PV is left. In the above example ..
# vgreduce /dev/vg01 /dev/dsk/c2t12d0
Now you're left with only 1 PV (ie c2t10d0). At this point ..
# vgremove /dev/vg01
will be succesdful.
Brian M Rawlings
Honored Contributor

Re: A simple question about removing a vg

I think the confusing part is "...and this must be unused". All that means is that there can't be any logical volumes, and therefore no file systems (which sit on logical volumes), left in the VG.

You can see this by doing a 'vgdisplay' (look for 'CUR LV', for the current number of logical volumes in the volume group, should be zero), or a 'vgdisplay -v' will provide a verbose listing of the LVs in the VG (again, to use vgremove, there shouldn't be any entries).

So, the two requirements are, you must have used 'lvremove' to remove each of the LVs in the VG (file systems must be unmounted first, or the command will fail). Then, vgreduce must be run, specifying all but one of the physical volumes in the VG, so that only one PV is left in the VG. Once these tasks are complete, 'vgremove' will wipe the VG off your system.

An alternative to this is the 'vgexport' command, which preserves the VG information on the physical volumes, but which does remove the VG information from the /etc/lvmtab file, as well as deleting the /dev/vgxx directory and special device files.

Once you become comfortable with LVM, you may find that you often use 'vgexport', since it does it all with one command. The only issue is that the PVs still have a VGRA (VG info in a header "reserved area"), so to use the PV(s) for some other purpose, you have to wipe the existing VG metadata off the physical disk.

To do that, you use the 'force' switch on the 'pvcreate' command (pvcreate -f /dev/rdsk/c?t?d?), since pvcreate won't overwrite an existing VGRA without the 'force' option.

Regards, --bmr
We must indeed all hang together, or, most assuredly, we shall all hang separately. (Benjamin Franklin)
Ron Barnett
Occasional Advisor

Re: A simple question about removing a vg

Why not just use:
vgexport -v /dev/vg??

this will remove the volume
group
Rajeev  Shukla
Honored Contributor

Re: A simple question about removing a vg

Hi,

By saying that "VG must have only 1 PV left in it and this must be unused" the document wants to say that be cautious to remove the right LV from the right VG and after you have made the VG free with any LV (means no LV left on that VG) you should reduce the VG to just one PV and then the VG can be removed.
This is very clean procedure but if you are looking for short cut way and you are sure about the LV and VG just use vgexport command.

Cheers
Rajeev
V. V. Ravi Kumar_1
Respected Contributor

Re: A simple question about removing a vg

Hi,
vgexport: Only removes entry in the /etc/lvmtab and directory in /dev corresponding to VG. Do "strings /etc/lvmtab", u will find each VG and associated PV's with it. Even after vgexport, all LV's are intact in VG. but u can not display VG or LV's. u can get the VG back, by creating directory in /dev and group file with mknod and with vgimport . But u will loose all LV's names and u will get lvol1, lvol2 etc..

vgreduce: using this u can remove one or more PV's from VG.

vgremove: removes the VG, in order to do this the safest way is to remove LV's first, then remove PV's one by one until one PV left in VG and then VG. "must be unused" means no LVs are present in that PV.

Regards


Never Say No
Frank Slootweg
Honored Contributor

Re: A simple question about removing a vg

I am afraid that I and another HP person were cleaning this thread at the same time and now have removed *all* three copies of the triplicated response.

Sadly enough I did not save a copy and did not note who the poster was.

My/our apologies.

For what it is worth, the last few lines, said something like "Bill, ...", so perhaps that is meaningful for the original poster.

Brian M Rawlings
Honored Contributor

Re: A simple question about removing a vg

That's OK, Frank... all you have to do to make up for it is to come up with a really sweet answer that is complete and comprehensive, and which will therefore cover anything the dear departed post might have said. It's simple, really.

8^)

--bmr
We must indeed all hang together, or, most assuredly, we shall all hang separately. (Benjamin Franklin)