Partitioning using LVM

8:10 PM





In viewing the image from above you can see that you can join 1 or more physical volumes into 1 and utilize them all, you would just need to create the Volume Group (VG).
Once you create the VG using the 'vgcreate' command i.e. #vgcreate  [name of VG] [name of PV 1] [name of PV 2] and so on . In the below example the VG was created with #vgcreate vg_root /dev/sda3
[root@host ~]# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda3
  VG Name               vg_root
  PV Size               102.63 GB / not usable 9.10 MB
  Allocatable           yes (but full)
  PE Size (KByte)       32768
  Total PE              3284
  Free PE               0
  Allocated PE          3284
  PV UUID               ehSD7G-Qrr9-OFGv-QGuO-P0Cb-E6zz-gUcqdK

[root@host ~]#

Using the 'vgdisplay' you will see the details of the VG you created
[root@host ~]# vgdisplay
  --- Volume group ---
  VG Name               vg_root
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  7
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                4
  Open LV               4
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               102.62 GB
  PE Size               32.00 MB
  Total PE              3284
  Alloc PE / Size       3284 / 102.62 GB
  Free  PE / Size       0 / 0
  VG UUID               DrefQc-0x9P-zlBW-ZoeL-Kpmd-0EzG-dPuOxC

[root@host ~]#

Ok, so you have a VG set up now what???
Now, you can separate into however many Logical Volumes you want and whatever sizes you want them to be so long as its within the VG size.
The 'lvcreate' command will be used to create the Logical Volume (LV). i.e. 'lvcreate -n (new LV) [name of the VG] [name of the LV] -L (dictating size) size of the new LV
[root@host ~]#lvcreate -n /dev/vg_root/lv_u01 -L 20Gt
* 'lvcreate -l 100%FREE -n new LV' will create a volume with the remaining space
You can then see the new LV you created by using the 'lvdisplay' command:
[root@host ~]# lvdisplay
  --- Logical volume ---
  LV Name                /dev/vg_root/lv_root
  VG Name                vg_root
  LV UUID                7oCKvj-Pw3i-tlJA-CMyM-tkVm-elRm-Cf2pgg
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                30.00 GB
  Current LE             960
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

  --- Logical volume ---
  LV Name                /dev/vg_root/lv_swap
  VG Name                vg_root
  LV UUID                LNohp8-n18L-wUdc-iNNn-6bZw-dopK-83BBVz
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                16.00 GB
  Current LE             512
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1

  --- Logical volume ---
  LV Name                /dev/vg_root/lv_u01
  VG Name                vg_root
  LV UUID                enujuK-d98s-RwyZ-WUew-bkQU-4wkb-UQkcFj
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                20.00 GB
  Current LE             640
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:2
Once you create it you can then make it a filesyste with the mkfs command and then create the appropriate folder, mount the new filesystem and adjust the fstab file to reflect the new file system
[root@host ~]# mkfs.ext3 -m 1 /dev/vg_root/lv_u01   (use -m 1 to reduce the reserved-blocks-percentage from 5% to 1% for max space for application) 
[root@host ~]# mkdir /u01
[root@host ~]# mount /dev/vg_root/lv_u01 /u01
[root@host ~]# vi /etc/fstab
[root@host ~]# cat /etc/fstab
/dev/vg_root/lv_root    /                       ext3    defaults        1 1
LABEL=/boot             /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
/dev/vg_root/lv_u01     /u01                    ext3    defaults        0 0
/dev/vg_root/lv_u02     /u02                    ext3    defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/vg_root/lv_swap    swap                    swap    defaults        0 0
For more information on this subject, please refer to the following documentation:
Red_Hat_Enterprise_Linux-5-Logical_Volume_Manager_Administration-en-US.pdf

You Might Also Like

0 comments

Contact Form

Name

Email *

Message *

Translate

Wikipedia

Search results