HOW TO GIVE LIMITED LVM(LOGICAL VOLUME) IN VG (VOLUME GROUP)

 

In this article we are going to learn how to give limited logical volume in volume group .

Follow these steps:

  • Create partitions.
[root@localhost ~]# fdisk /dev/sda
The number of cylinders for this disk is set to 6147.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (5482-6147, default 5482):
Using default value 5482
Last cylinder or +size or +sizeM or +sizeK (5482-6147, default 6147): +500M

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (5544-6147, default 5544):
Using default value 5544
Last cylinder or +size or +sizeM or +sizeK (5544-6147, default 6147): +500M

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (5606-6147, default 5606):
Using default value 5606
Last cylinder or +size or +sizeM or +sizeK (5606-6147, default 6147): +500M

Command (m for help): p
Disk /dev/sda: 50.5 GB, 50562793472 bytes
255 heads, 63 sectors/track, 6147 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        5099    40957686   83  Linux
/dev/sda2            5100        5481     3068415   82  Linux swap / Solaris
/dev/sda4            5482        6147     5349645    5  Extended
/dev/sda5            5482        5543      497983+  83  Linux
/dev/sda6            5544        5605      497983+  83  Linux
/dev/sda7            5606        5667      497983+  83  Linux

Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
[root@localhost ~]# partprobe /dev/sda
  • Create pv (physical volume) including these patitions sda5, sda6, sda7
[root@localhost ~]# pvcreate /dev/sda5 /dev/sda6 /dev/sda7
  Physical volume "/dev/sda5" successfully created
  Physical volume "/dev/sda6" successfully created
  Physical volume "/dev/sda7" successfully created
  • Now create vg(volume group ) over these pv(physical volumes)
[root@localhost ~]# vgcreate vg00 /dev/sda5 /dev/sda6 /dev/sda7
  Volume group "vg00" successfully created
  • Create lvm(logical volume)  over vg(volume group)
root@localhost ~]# lvcreate -L +600M -n lv1 vg00
  Logical volume "lv1" created
[root@localhost ~]# lvcreate -L +300M -n lv2 vg00
  Logical volume "lv2" created
  • Now when we check about volume group ,its showing max lv 0. This means unlimited lvm (logical volume ) can be created.
[root@localhost ~]# vgdisplay
  --- Volume group ---
  VG Name               vg00
  System ID
  Format                lvm2
  Metadata Areas        3
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               0
  Max PV                0
  Cur PV                3
  Act PV                3
  VG Size               1.42 GB
  PE Size               4.00 MB
  Total PE              363
  Alloc PE / Size       225 / 900.00 MB
  Free  PE / Size       138 / 552.00 MB
  VG UUID               djDIiH-88Sp-jUX0-6YCi-sd47-2G0x-0x0iID
  • Lets give volume group permission to create only 10(max) lvm(logical volume) .You can give as much you want.
[root@localhost ~]# vgchange -l 10 /dev/vg00
  Volume group "vg00" successfully changed
  • After above command you can see  max lv is 10 for this volume group .
[root@localhost ~]# vgdisplay
  --- Volume group ---
  VG Name               vg00
  System ID
  Format                lvm2
  Metadata Areas        3
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                10
  Cur LV                2
  Open LV               0
  Max PV                0
  Cur PV                3
  Act PV                3
  VG Size               1.42 GB
  PE Size               4.00 MB
  Total PE              363
  Alloc PE / Size       225 / 900.00 MB
  Free  PE / Size       138 / 552.00 MB
  VG UUID               djDIiH-88Sp-jUX0-6YCi-sd47-2G0x-0x0iID

So this is how you can give  limited logical volume in volume group.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s