LVM understanding




--------------------------------------------------------------------------------------------------------------
we use fdisk to format the raw hard disk 

fdisk /dev/sdb

/dev/sdb1               1          14      112423+  83  Linux
/dev/sdb2              15          28      112455   83  Linux
/dev/sdb3              29          42      112455   83  Linux
partprobe
-------------------------------------------------------------------------------------------------------------
now we create a physical volume
pvcreate /dev/sdb1 /dev/sdb2 /dev/sdb3 
pvdisplay
-------------------------------------------------------------------------------------------------------------

We create the volume group vg1

vgcreate vg1 /dev/sdb1 /dev/sdb2 
vgdisplay

------------------------------------------------

We now create the logical volume

lvcreate -L 200M vg1 -n lv1
lvdisplay 
mkfs.ext4 /dev/vg1/lv1
mount    /dev/vg1/lv1   /mnt/
-------------------------------------------------------------------------------------------------------------
to extend new hdd :
pvcreate  /dev/sdb1
vgextend vg1 /dev/sdb1
lvresize -L +100M /dev/vg1/lv1
resize2fs /dev/vg1/lv1
lvdisplay /dev/vg1/lv1

-------------------------------------------------------------------------------------------------------------
the following procedure, in this example we shrink a partition from 10G to 9G:
First, we unmount.
# umount /dev/vg_blah/lv_blah
Check the file system.
# e2fsck -f /dev/vg_blah/lv_blah
Resize the file system.
# resize2fs -p /dev/vg_blah/lv_blah 9G
Reduce the size of the logical volume.
# lvreduce -L -1G /dev/vg_blah/lv_blah
Shrink the volume group if desired.
# vgreduce vg_blah /dev/sdxy


No comments:

Other Articles

Enter your email address: