Quantcast
Channel: Magnus K Karlsson
Viewing all articles
Browse latest Browse all 526

Managing LVM with RHEL 6

$
0
0

Introduction

LVM (Logical Volume Manager) is a flexible way to handle disk space, since you can increase and decrease file systems, that is not possible to the same extent as in MBR (Master Boot Record) partitioning format.

NOTE: "It is generally recommended that you create a single partition that covers the whole disk to label as an LVM physical volume" [https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Logical_Volume_Manager_Administration/LVM_components.html#multiple_partitions]

The LVM is build up on three cornerstone.

  1. Physical Volume, PV
  2. Logical Volume, LV
  3. Volume Group, VG

Prerequisite

Create a new partition with type 0x8E Linux LVM.

The Most Imported Commands

Create Physical Volume (PV), Volumme Group (VG) and Logical Volume (LV)

First lets create a new physical volume on the prerequisite partition.

Create volume group vg_test that span entire physical volume /dev/sda3

Create logical volumne with size 500 MB, named lv_test in volume group vg_test.

The lvcreate will now create a device block file in /dev/vgName/lvName that we now can create a filesystem on and mount.

Extends Logical Volume (LV)

Extend the logical volume lv_test with plus 500 MB.

Now you need to grow the file system.

Verify/test the new size of /data.

Reduce Logical Volume (LV)

When reducing a file system, you need to unmount it first.

# umount /data

Then reduce the actual filesystem.

After the actual file system is reduced, we can now shrink the logical volume.

Finally test/verify, by remounting and check disk space

Extends Volume Group (VG)

First create a new physical volume.

Now lets extends existing volume group 'vg_test' with our new physical volume.

And last test/verify.

Reduce Volume Group (VG)

Remove existing volume group 'vg_test' with physical volume /dev/sda4.

Test/verify

Reference

  • lvm(8): lvm - LVM2 tools
  • pvcreate(8): pvcreate - initialize a disk or partition for use by LVM
  • vgcreate(8): vgcreate - create a volume group
  • lvcreate(8): lvcreate - create a logical volume in an existing volume group
  • vgextend(8): vgextend - add physical volumes to a volume group
  • vgreduce(8): vgreduce - reduce a volume group
  • lvextend(8): lvextend - extend the size of a logical volume
  • lvreduce(8): lvreduce - reduce the size of a logical volume
  • resize2fs(8): resize2fs - ext2/ext3/ext4 file system resizer

Viewing all articles
Browse latest Browse all 526

Trending Articles