What is the difference between LVM and LUN

Both seem to be a virtualization layer on top of physical disks. I'm having a hard-time understanding each of them and the difference between them.


Solution 1:

Different layers of abstraction.

If you've got a large storage array, you probably don't want one server to use the whole thing, so you divide it into logical units (LUN is actually Logical Unit Number, but hey, it helps me remember). So you've got your storage sliced into usable chunks, and now you present it to the server. In a simple example, suppose it shows up as /dev/sdb. No partitions on it, it's just a disk, so far as the server cares.

Why throw LVM on top of it? For me, it's because of growth. If I fill up that disk, I want to be able to add more space to it. LVM makes it easier and (in my mind) less risky, because I can resize that LUN on the storage array (or even create another LUN and present that to the server) and using LVM, I can grow the "virtual" disk without rebooting.

I wrote an introduction to LVM here: http://www.standalone-sysadmin.com/blog/2008/09/introduction-to-lvm-in-linux/

Which I referenced when talking about resizing LUNs here: http://www.standalone-sysadmin.com/blog/2009/05/resizing-storage-luns-in-linux-on-the-fly/

Solution 2:

LVM is a piece of software used to "carve" up a disk, usually a locally attached disk, into smaller sections.

LVM is a method of allocating hard drive space into logical volumes that can be easily resized instead of partitions.

A LUN is a construct, usually on a storage array, with which you present a "slice" of a disk array/volume to a host, where it appears as a physically attached local disk via some connection, usually SAN (iSCSI/FC).

For example, if you presented a LUN to a host, you could then use LVM to further customize the layout of what the system thought was a local disk.

A LUN is a Logical Unit Number. It can be used to refer to an entire physical disk, or a subset of a larger physical disk or disk volume. The physical disk or disk volume could be an entire single disk drive, a partition (subset) of a single disk drive, or disk volume from a RAID controller comprising multiple disk drives aggregated together for larger capacity and redundancy. LUNs represent a logical abstraction or, if you prefer, virtualization layer between the physical disk device/volume and the applications.