How to manage LVM | Ubuntu

Environment
  • Ubuntu

Content
It was for setting LVM to my laptop
#apt-get install lvm2

Volume Group (VG)
#vgcreate vgpool /dev/sda1

#vgextend vgpool /dev/sda6

#vgdisplay

Logical Volume (LV)
Create a LV:
#lvcreate -L 50G -n lv0010Store vgpool

#lvdisplay
--- Logical volume ---
LV Name /dev/vgpool/lv0010Store
VG Name vgpool
LV UUID PZkUmy-9ktE-5WYu-97y4-yah9-DEam-oPAX6R
LV Write Access read/write
LV Status available
# open 1
LV Size 50.00 GiB
Current LE 12800
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:0

--- Logical volume ---
LV Name /dev/vgpool/lv0020Data
VG Name vgpool
LV UUID
.
.
.
.
.


Extend the LV:
#umount /media/datastore

#lvextend -L+60G /dev/vgpool/lv0030Data
Extending logical volume lv0030Data to 160.00 GiB
Logical volume lv0030Data successfully resized

#e2fsck -f /dev/vgpool/lv0030Data
e2fsck 1.42 (29-Nov-2011)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/vgpool/lv0030Data: 23389/6553600 files (3.4% non-contiguous), 22134658/26214400 blocks

#resize2fs /dev/vgpool/lv0030Data
resize2fs 1.42 (29-Nov-2011)
Resizing the filesystem on /dev/vgpool/lv0030Data to 41943040 (4k) blocks.
The filesystem on /dev/vgpool/lv0030Data is now 41943040 blocks long.


Reduce the LV:
#umount /media/datastore
#resize2fs /dev/vgpool/lv0030Data
#lvreduce -L 10G /dev/vgpool/lv0030Data


Remove the LV:
#umount /media/datastore
#lvremove /dev/vgpool/lv0030Data



Reference