[Novalug] LVM vs Partitions

Peter Larsen plarsen at famlarsen.homelinux.com
Mon Mar 15 19:51:38 EDT 2010


On Mon, 2010-03-15 at 18:17 -0400, Gopher wrote:

> Ok, I'll bite...
> 
> Please fill me in on the whole LVM vs Partitions a bit more. I'll admit, 
> I didn't read everything in the recent udev discussion (too much 
> screaming and noise for my taste), so please pardon as I ask for a re-cap.


No problem; Greg wanted a topic for the meeting two months from now.
There may be enough here for a recap (I did a presentation on LVM last
year at NovaLug). A quick recapture - LVM makes your physical device
into a logical device. It does that by hiding the physical device(s)
from you as you layout your volumes. Changes and additions can then be
made dynamically without having to physically move data around your
disk. 


> If all I have is a single drive and it's going to be used as /data is 
> LVM better or worse than ye olde simple primary partition on the drive?



Lots. Let's recapture some of the main features of LVM: Mirror,
Snapshot, volume extension (and reduction) .. and well many more.  So,
let's pretend that you run out of disk-space. Too many videos downloaded
and your /media mount point is close to being full. You rush out to
Microcenter and get yourself a new 2TB SATA drive, 10K RPMs and it's
just flying. Happily you install the drive, and now what? Well, without
LVM you'll have to 1) partition the drive, 2) format it, 3) COPY all the
old data from /media to the new drive, 4) verify the copy went well, 5)
delete the old data, 6) create a new mount-point for your new data disk
in /media.  With LVM you: 1) create PV on whole disk, 2) add the disk to
the current volume group (there by extending it), 3) Increase the size
of the volume and filesystem for /media. DONE - no copy needed of data.

Another example - your computer is running a live application that
involves a rather busy database and writes to files etc. You need to
back it up consistently., LVM to your rescue. Create a snapshot of your
volume(s), and backup the consistent snapshot. Your backup will be from
an exact point in time. When done, remove the snapshots.

Then you have issues of maintenance and upgrades. You want to segment
your /home out - maybe even encrypt it. Your single disk is in "pieces".
But what if you calculate the needed sizes wrong? Let's say you
allocated too little room for /usr and now you cannot install Blender.
You have plenty of room left in /home - so what do you do? Without LVM
that's a nightmare. With LVM you can do everything but reducing a
filesystem's size live. But since it's /home you need to reduce in size,
you can switch to runlevel 1 and do your job there. In other words, LVM
makes life easier. Always.


> I've got an mdadm raid 5 setup with LVM on top of it.  So far it meets 
> my needs if I want to reallocate space between LVM partitions.  Other 
> than this, I'm not sure why I would ever use LVM. As I understand it, 
> LVM is an extra layer of code that the kernel has to slog through to get 
> to the disk and to be able to retrieve data. 


There really isn't a new layer of overhead. LVM is DM (Device Mapper)
with a twist. You're already using DM using MD. And LVM is a lot simpler
when it comes to access than MD is.


> That's why I never even 
> consider putting swap on anything other than a raw partition on a disk: 
> when my swap space is needed I want it fast as possible and as I see it, 
> LVM just slows the whole thing down. [Theoretically swap should be on 
> it's own device and bus for max speed, but thankfully this isn't the 
> early 90's and hw and bus speeds are practically at light speed now, so 
> nobody cares if swap shares a disk with something else anymore.]


I'm beginning to fully remove swap from my virtual machines. No real
need for it. And unless you can get an dedicated io channel for your
swap, the little improvement you may get is negligent. You shouldn't
really have that much swap allocated and in active use. LVM does not
slow things down - it's just a way to tell the kernel which part of the
disk(s) to write on using the same channels the kernel already uses.


> Please enlighten me and clue me in on why should I use LVM outside of my 
> raid set up, oh gurus of the keyboard.



I hope the above appetizers help illustrate why noone should install a
Linux install today without LVM. There's really no reasons out there not
to. 

> 
> (P.S. I read up on udev today... that's just fscking awesome.)


:)

-- 

Best Regards
  Peter Larsen

Wise words of the day:
Being overloaded is the sign of a true Debian maintainer.
	-- JHM on #Debian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://calypso.tux.org/pipermail/novalug/attachments/20100315/7b709543/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
Url : http://calypso.tux.org/pipermail/novalug/attachments/20100315/7b709543/attachment.bin 


More information about the Novalug mailing list