LVM is a form of advanced partition management. The benefit to using LVM
is ease of management due to the way disks are set up.When you set up
your system for the first time, you have a certain number of physical
disks . These physical disks are the base of the LVM structure and
referred to as physical volumes. The next layer in the structure is
volume groups, where physical volumes are combined into a single pool
of storage. The final layer in the structure is logical volumes, which
are the actual partitions on the system.
There are many commands and management utilities for working with LVM. Here is an overview of them:
pvdisplay Displays detailed information on physical volumes
vgdisplay Displays detailed information on volume groups
lvdisplay Displays detailed information on logical volumes
pvcreate Creates a new physical volume
vgcreate Creates a new volume group
lvcreate Creates a new logical volume
vgextend Extends an existing volume group
lvextend Extends a logical volume
lvresize Resizes a logical volume
lvreduce Reduces a logical volume
Configuration steps
Step 1.
Install the required packages:
# yum install -y lvm*
Step 2.
To create physical partiion use the pvcreate command:
# pvcreate /dev/hdb4
# pvcreate /dev/hdb5
Step 3.
With the disk initialized, you can next create a volume group and add the physical disk to it.
To create the volume group, use the vgcreate command:
# vgcreate vg_name /dev/hdb4 /dev/hdb5
Step 4.
Now you can set up logical volumes that hold the partitions for the system. To create a logical volume,
Create a partition 3GB in size name as lvm_name
# lvcreate -L 3000 -n lvm_name vg_name
Step 5.
Verify that the logical volume was created successfully:
# lvdisplay vg_name
Step 6.
To extend or reduce a logical volume use the lvextend & lvreduce command.
Add 2GB more to the lvm_name logical volume:
# lvextend -L +2000 /dev/vg_name/lvm_name
# lvreduce -L -2000 /dev/vg_name/lvm_name
Verify the change with the following command:
# lvdisplay vg_name
Removing LVM
To remove a logical volume, firstly umount LVM partition if mounted then use the lvremove command:
# lvremove /dev/vg_name/lvm_name
Use the vgremove command to remove the volume group:
# vgremove vg_name
To Remove Physical Volume
#pvremove /dev/hdb4
Labels on physical volume “/dev/hdb4” successfully wiped
pvdisplay Displays detailed information on physical volumes
vgdisplay Displays detailed information on volume groups
lvdisplay Displays detailed information on logical volumes
pvcreate Creates a new physical volume
vgcreate Creates a new volume group
lvcreate Creates a new logical volume
vgextend Extends an existing volume group
lvextend Extends a logical volume
lvresize Resizes a logical volume
lvreduce Reduces a logical volume
Configuration steps
Step 1.
Install the required packages:
# yum install -y lvm*
Step 2.
To create physical partiion use the pvcreate command:
# pvcreate /dev/hdb4
# pvcreate /dev/hdb5
Step 3.
With the disk initialized, you can next create a volume group and add the physical disk to it.
To create the volume group, use the vgcreate command:
# vgcreate vg_name /dev/hdb4 /dev/hdb5
Step 4.
Now you can set up logical volumes that hold the partitions for the system. To create a logical volume,
Create a partition 3GB in size name as lvm_name
# lvcreate -L 3000 -n lvm_name vg_name
Step 5.
Verify that the logical volume was created successfully:
# lvdisplay vg_name
Step 6.
To extend or reduce a logical volume use the lvextend & lvreduce command.
Add 2GB more to the lvm_name logical volume:
# lvextend -L +2000 /dev/vg_name/lvm_name
# lvreduce -L -2000 /dev/vg_name/lvm_name
Verify the change with the following command:
# lvdisplay vg_name
Removing LVM
To remove a logical volume, firstly umount LVM partition if mounted then use the lvremove command:
# lvremove /dev/vg_name/lvm_name
Use the vgremove command to remove the volume group:
# vgremove vg_name
To Remove Physical Volume
#pvremove /dev/hdb4
Labels on physical volume “/dev/hdb4” successfully wiped
No comments:
Post a Comment