Gentoo Archives: gentoo-user

From: Alan McKinnon <alan.mckinnon@×××××.com>
To: gentoo-user@l.g.o
Cc: Dale <rdalek1967@×××××.com>
Subject: Re: [gentoo-user] LVM for data drives but not the OS
Date: Fri, 08 Apr 2011 14:01:50
Message-Id: 201104081559.44212.alan.mckinnon@gmail.com
In Reply to: Re: [gentoo-user] LVM for data drives but not the OS by Dale
1 On Friday 08 April 2011 15:40:18 Dale wrote:
2 > Neil Bothwick wrote:
3 > > On Fri, 08 Apr 2011 05:42:59 -0500, Dale wrote:
4 > >> Little light bulb here. physical volume is the same as a physical
5 > >> drive? If I understand it correctly, it is the whole thing
6 > >> unpartitioned.
7 > >
8 > > No. A physical volume is an area of disk. It can be the whole disk but it
9 > > more usually a partition.
10 >
11 > Ooooh. Still some progress tho. lol So, if I was going to use LVM, I
12 > create a partition first, either whole drive or part of it then use LVM
13 > on that? Then comes in the rest of the stuff that I am still trying to
14 > get a grip on.
15
16 Yes.
17
18 Here's the sequence:
19
20 1. Start with some sort of storage device (disk, partition, whatever - it must
21 just be a block device)
22
23 2. Run pvcreate on it. This is like making swapspace - it adds a signature to
24 the beginning of the block device so that LVM knows it can use the device
25
26 3. Add the pv to a volume group (vg). A vg is a collection of one or more
27 pv's, they are so that you can build big vgs and create volumes larger than
28 any one disk. On desktop with one drive or one RAID device, then vg often only
29 has 1 pv in it
30
31 4. Allocate space from the vg. This is a logical volume, it is a block device
32 just like any other and as far as the kernel and you are concerned you use it.
33 mkfs it and mount it just like any other block device.
34
35 ====
36
37 Each of these elements (pv, vg, lv) can be added to, created, extended,
38 reduced and the command systax is much the same for each. What that means
39 exactly depends on what the thing is:
40
41 PV: creating it starts it from scratch, the LVM data on it is gone. You only
42 extend/reduce a PV if you changed the size of the underlying partition so that
43 LVM know it's true size.
44
45 VG: You don't really create a VG as such (it's a collection of things, not a
46 single thing). Creating it means adding the first PV to the VG. Extending and
47 reducing a VG means adding and removing PVs from the collection. When you
48 reduce a VG, it's an excellent idea to have migrated all the data on the PV
49 away first :-)
50
51 LV: Make the LV larger or smaller. This is conceptually exactly the same as
52 modifying a regular partition with fdisk, and you must take the same
53 precautions:
54
55 Extend: Make the LV bigger then grow the fs on it to use all the space
56 Reduce: Shrink the fs on it then reduce the LV to the same size
57
58
59
60 It's all very simple and logical really. It you grok what create/extend/reduce
61 and so on means for each element then you won't go wrong. People get confused
62 by LVM because tutorials on it, Red Hat training materials[1] and GUI tools
63 try very hard to fudge the concept, hide the bits and present it like the
64 partition, PV, VG, LV and filesystem on it and somehow all the same thing.
65 Which is completely not true of course.
66
67 [1] Especially Red Hat training materials. These caused more confusion about
68 it than anything else I have ever seen. Including Gnome tools. And that's
69 saying something.
70
71
72
73
74
75 --
76 alan dot mckinnon at gmail dot com