...

Monday, March 1, 2010

Debian 14

Logical Volume Management, or LVM, allows us to create abstractions of storage. Two different types of abstractions are volume sets and stripe sets. LVM allows consolidation of storage and presents a unified image of storage. It hides underlying storage technologies from file systems (You can combine IDE, SATA, SCSI, etc. as one storage unit).
Stripe sets improves performance by spreading data across multiple disks. LVM is also not recommended for doing RAID. The physical circuit on the motherboard is more suitable for this. After configuring RAID, you can overlay LVM on the RAID. LVM also allows resizing of partitions.

LVM is not installed by default. There are two packages required for LVM:
1) lvm-common
2) lvm2

There is an LVM storage hierarchy that comprises of Logical Volumes, Physical Volume Groups and Physical Volumes. The file system is configured at the Logical Volume level. The Logical Volume is similar to a partition in a non-LVM world. Volume groups represent one or more physical volumes (hard disks, partitions etc). Physical Volumes represent devices or partitions (e.g. /dev/sdb1). The physical volumes must be created as type 'lvm(8e)'.

The concept behind LVM is that physical volumes are first merged into one large volume group, then divided into many smaller logical volumes.

Here's a list of tools for use:
Physical Volumes - pv*
Volume Groups - vg*
Logical Groups - lg*

Replace * with create, display, extend, etc.

The 6 steps to create a LVM system are:
1) Create LVM partitions via fdisk
fdisk /dev/sdb
t
8e
w


t changes the type and 8e refers to Linux LVM.

2) Create LVM Physical Volume
pvcreate /dev/sdb1

Use pvdisplay to confirm that you've created the physical volume.

3) Create Volume Group
vgcreate volumegroup01 /dev/sdb1

Similarly, use vgdisplay to confirm that you've created the volume group.

4) Create Logical Volume
lvcreate -L 4GB volumegroup01
or
lvcreate -l 100%VG volumegroup01

At this point, you should have a 4GB device node at:
/dev/volumegroup01/lvol0

5) Overlay the file system on /dev/volumegroup01/lvol0
mke2fs -j /dev/volumegroup01/lvol0

We can remove logical volumes through:
lvremove /dev/volumegroup01/lvol0

We can rename logical volumes through:
lvrename volumegroup01 lvol0 sales

To resize a logical volume:
lvresize -L 3GB /dev/volumegroup01/sales

To add more members into a volume group:
vgextend /dev/sdb2

We can enable striping through:
lvremove /dev/volumegroup01/sales
lvcreate -i 2 -L 8GB -n sales volumegroup01

Where -i specifies the number of disks to stripe across.

After we're done, remember to overlay the file system and map mount point in /etc/fstab.

No comments :

Post a Comment

<