Red Hat Enterprise Linux




Chapters     |     Exercises     |     Workshop     |    

Storage - Logical Volume Management (LVM)



Creating Volumes

Steps

  1. Create n Physical Volumes
  2. Create Volume Group: add n Physical Volumes in a volume Group
  3. Create m Logical Volumes
  4. Make an Filesystem on Logical Volume
  5. Mount Filesystem

Physical Volume

Create a new physical volume
[root@redhat ~]# pvcreate special file

Example
[root@redhat ~]# pvcreate /dev/sdd
  Physical volume "/dev/sdd" successfully created


Displays physical volumes
[root@redhat ~]# pvs

Displays detailed information on physical volumes
[root@redhat ~]# pvdisplay

Volume Group

Creates a new volume group
[root@redhat ~]# vgcreate group_name physical_volume1 physical_volume2 …

Example
[root@redhat ~]# vgcreate MON-VOLUME /dev/sdd /dev/sde /dev/sdf
  Volume group "MON-VOLUME" successfully created


Example
[root@localhost ~]# vgcreate MON-VOLUME /dev/sdb1 /dev/sdb2 /dev/sdb3
  Volume group "MON-VOLUME" successfully created


Display volume groups
[root@redhat ~]# vgs

Display detailed information on volume groups
[root@redhat ~]# vgdisplay

[root@redhat ~]# vgremove volume_group_name Removes a volume group

[root@redhat user1]# vgremove STORE
  Volume group "STORE" successfully removed



Logical Volume

Creates a new logical volume

Syntax
[root@redhat ~]# lvcreate Options Volume-Group


Example
[root@redhat ~]# lvcreate -L 50G -p rw -n LOG-VOL MON-VOLUME
  Logical volume "LOG-VOL" created


Use 100% of free space on volume group
[root@redhat ~]# lvcreate -l 100%FREE -p rw -n lv_my_log_vol vg_my_vol_group

Displays logical volumes
[root@redhat ~]# lvs

Displays detailed information on logical volumes
[root@redhat ~]# lvdisplay

Removes a logical volume
[root@rhel8 user1]# lvremove Logical-Volume

[root@redhat user1]# lvremove /dev/mapper/STORE-SPACE
Do you really want to remove active logical volume STORE/SPACE? [y/n]: y
  Logical volume "SPACE" successfully removed




[root@rhel8 user1]# vgextend Extends an existing volume group
[root@rhel8 user1]# lvextend Extends a logical volume
[root@redhat ~]# pvresize /dev/sda1 Expand the PV on /dev/sda1 after enlarging the partition with fdisk

[root@rhel8 user1]# lvresize Resizes a logical volume
[root@rhel8 user1]# lvreduce Reduces a logical volume
[root@rhel8 user1]# lvrename Renames a logical volume
[root@rhel8 user1]# pvmove Moves/migrates data from one physical volume to another
[root@rhel8 user1]# vgreduce Reduces a volume group
[root@rhel8 user1]# pvremove Removes a physical volume




Eninam BAGNABANA     |         |     bagnadavid@outlook.fr     |