Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

https://www.tecmint.

com/manage-and-create-lvm-parition-using-vgcreate-lvcreate-and-
lvextend/

Creating Physical Volumes, Volume Groups, and Logical Volumes

1. First create physical volumes on top of the disks /dev/sdb, /dev/sdc do:

# pvcreate /dev/sdb /dev/sdc /dev/sdd


You can list the newly created PVs with:
# pvs
and get detailed information about each PV with:
# pvdisplay /dev/sdX

2. Create Volume Group


vgcreate vg00 /dev/sdb /dev/sdc
# vgdisplay vg00
vgs

3. Create Logical Volumns from the VG created above:


lvcreate -n vol_projects -L 10G vg00 ===> Fixed size LV
# lvcreate -n vol_backups -l 100%FREE vg00 ===> Percentage from the
free space

lvs
lvdisplay

4. format the file system:


# mkfs.ext4 /dev/vg00/vol_projects
# mkfs.ext4 /dev/vg00/vol_backups

5. mount the LV
mount /dev/vg00/vol_projects /projects
mount /dev/vg00/vol_backups /backups

-------
resizge LV
# lvreduce -L -2.5G -r /dev/vg00/vol_projects ====> this will unmount the LV
# lvextend -L +2G -r /dev/vg00/vol_backups ====> this is online
# lvextend -l +100%FREE -r /dev/vg00/vol_backups

It is important to include the minus (-) or plus (+) signs while resizing a logical
volume. Otherwise, you’re setting a fixed size for the LV instead of resizing it.

-----
extend VG by adding additional disks (Physical volumns)

vgextend vg00 /dev/sdd

-----
Mounting Logical Volumes on Boot and on Demand

# blkid /dev/vg00/vol_projects
# blkid /dev/vg00/vol_backups
add to /etc/fstab
UUID=b85df913-580f-461c-844f-546d8cde4646 /home/projects ext4 defaults 0 0
UUID=e1929239-5087-44b1-9396-53e09db6eb9e /home/backups ext4 defaults 0 0
# mount -a

=====
crate LV snapshot
lvcreate -L 10GB -s -n vol_projects_snap /dev/vg00/vol_projects

this will create a snapshot for the LV (it is very very fast, instaniouns)

You might also like