On Friday 08 April 2011 15:40:18 Dale wrote:
> Neil Bothwick wrote:
> > On Fri, 08 Apr 2011 05:42:59 -0500, Dale wrote:
> >> Little light bulb here.  physical volume is the same as a physical
> >> drive?  If I understand it correctly, it is the whole thing
> >> unpartitioned.
> > 
> > No. A physical volume is an area of disk. It can be the whole disk but it
> > more usually a partition.
> 
> Ooooh.  Still some progress tho.  lol  So, if I was going to use LVM, I
> create a partition first, either whole drive or part of it then use LVM
> on that?  Then comes in the rest of the stuff that I am still trying to
> get a grip on.

Yes.

Here's the sequence:

1. Start with some sort of storage device (disk, partition, whatever - it must 
just be a block device)

2. Run pvcreate on it. This is like making swapspace - it adds a signature to 
the beginning of the block device so that LVM knows it can use the device

3. Add the pv to a volume group (vg). A vg is a collection of one or more 
pv's, they are so that you can build big vgs and create volumes larger than 
any one disk. On desktop with one drive or one RAID device, then vg often only 
has 1 pv in it

4. Allocate space from the vg. This is a logical volume, it is a block device 
just like any other and as far as the kernel and you are concerned you use it. 
mkfs it and mount it just like any other block device.

====

Each of these elements (pv, vg, lv) can be added to, created, extended, 
reduced and the command systax is much the same for each. What that means 
exactly depends on what the thing is:

PV: creating it starts it from scratch, the LVM data on it is gone. You only 
extend/reduce a PV if you changed the size of the underlying partition so that 
LVM know it's true size.

VG: You don't really create a VG as such (it's a collection of things, not a 
single thing). Creating it means adding the first PV to the VG. Extending and 
reducing a VG means adding and removing PVs from the collection. When you 
reduce a VG, it's an excellent idea to have migrated all the data on the PV 
away first :-)

LV: Make the LV larger or smaller. This is conceptually exactly the same as 
modifying a regular partition with fdisk, and you must take the same 
precautions:

  Extend: Make the LV bigger then grow the fs on it to use all the space
  Reduce: Shrink the fs on it then reduce the LV to the same size



It's all very simple and logical really. It you grok what create/extend/reduce 
and so on means for each element then you won't go wrong. People get confused 
by LVM because tutorials on it, Red Hat training materials[1] and GUI tools 
try very hard to fudge the concept, hide the bits and present it like the 
partition, PV, VG, LV and filesystem on it and somehow all the same thing. 
Which is completely not true of course.

[1] Especially Red Hat training materials. These caused more confusion about 
it than anything else I have ever seen. Including Gnome tools. And that's 
saying something.





-- 
alan dot mckinnon at gmail dot com

Reply via email to