Logical Volume Manager

Logical volume management :
In Computer Storage, logical volume management or LVM provides a method of allocating space on mass-storage devices that is more flexible than conventional partitioning schemes. In particular, a volume manager can concatenate, Stripe together or otherwise combine partitions into larger virtual ones that administrators can re-size or move, potentially without interrupting system use.

LVM is suitable for:
  • Managing large hard disk farms by letting you add disks, replace disks, copy and share contents from one disk to another without disrupting service (hot swapping).
  • On small systems (like a desktop at home), instead of having to estimate at installation time how big a partition might need to be in the future, LVM allows you to resize your disk partitions easily as needed.
  • Making backups by taking "snapshots."
  • Creating single logical volume of multiple physical volumes or entire hard disks (somewhat similar to RAID 0 but more similar to JBOD), allowing for dynamic volume resizing.

LVM Logical Volume Components
Figure : LVM Logical Volume Components

      
                                           Figure : LVM Partition for an oninternal organization

LVM configuration for LINUX :
 
[root@localhost ~]# fdisk -l

Disk /dev/hda: 80.0 GB, 80060424192 bytes
255 heads, 63 sectors/track, 9733 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1        2764    22201798+   7  HPFS/NTFS
/dev/hda2            2765        9733    55978492+   5  Extended
/dev/hda5            2765        6602    30828703+   7  HPFS/NTFS
/dev/hda6            6603        8514    15358108+  83  Linux
/dev/hda7            8515        8603      714861   82  Linux swap / Solaris
/dev/hda8            8604        8628      200781   83  Linux
/dev/hda9            8629        8690      497983+  fd  Linux raid autodetect
/dev/hda10           8691        8752      497983+  fd  Linux raid autodetect
/dev/hda11           8753        8814      497983+  fd  Linux raid autodetect

Disk /dev/md0: 1019 MB, 1019609088 bytes
2 heads, 4 sectors/track, 248928 cylinders
Units = cylinders of 8 * 512 = 4096 bytes

Disk /dev/md0 doesn't contain a valid partition table
[root@localhost ~]# fdisk /dev/hda

The number of cylinders for this disk is set to 9733.
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 (8815-9733, default 8815):
Using default value 8815
Last cylinder or +size or +sizeM or +sizeK (8815-9733, default 9733): +300M

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (8852-9733, default 8852):
Using default value 8852
Last cylinder or +size or +sizeM or +sizeK (8852-9733, default 9733): +300M     
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/hda
[root@localhost ~]# partprobe /dev/hda
[root@localhost ~]# partprobe /dev/hda
[root@localhost ~]# fdisk /dev/hda

The number of cylinders for this disk is set to 9733.
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): t
Partition number (1-13): 12
Hex code (type L to list codes): 8e
Changed system type of partition 12 to 8e (Linux LVM)

Command (m for help): t
Partition number (1-13): 13
Hex code (type L to list codes): 8e
Changed system type of partition 13 to 8e (Linux LVM)

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 ~]# pvcreate /dev/hda12 /dev/hda13
  Physical volume "/dev/hda12" successfully created
  Physical volume "/dev/hda13" successfully created
[root@localhost ~]# pvdisplay
  "/dev/hda12" is a new physical volume of "290.21 MB"
  --- NEW Physical volume ---
  PV Name               /dev/hda12
  VG Name
  PV Size               290.21 MB
  Allocatable           NO
  PE Size (KByte)       0
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               kAHCbI-9spz-nXzd-1AH5-5AL9-lhay-6rcRyu

  "/dev/hda13" is a new physical volume of "290.21 MB"
  --- NEW Physical volume ---
  PV Name               /dev/hda13
  VG Name
  PV Size               290.21 MB
  Allocatable           NO
  PE Size (KByte)       0
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               AQkIvw-mjH0-kpEo-yC18-0sBH-w9f3-lmVjvu
 
 [root@localhost ~]# pvs
  PV         VG   Fmt  Attr PSize   PFree
  /dev/hda12      lvm2 --   290.21M 290.21M
  /dev/hda13      lvm2 --   290.21M 290.21M
 [root@localhost ~]# pvdisplay /dev/hda12
  "/dev/hda12" is a new physical volume of "290.21 MB"
  --- NEW Physical volume ---
  PV Name               /dev/hda12
  VG Name
  PV Size               290.21 MB
  Allocatable           NO
  PE Size (KByte)       0
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               kAHCbI-9spz-nXzd-1AH5-5AL9-lhay-6rcRyu

[root@localhost ~]# pvdisplay /dev/hda13
  "/dev/hda13" is a new physical volume of "290.21 MB"
  --- NEW Physical volume ---
  PV Name               /dev/hda13
  VG Name
  PV Size               290.21 MB
  Allocatable           NO
  PE Size (KByte)       0
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               AQkIvw-mjH0-kpEo-yC18-0sBH-w9f3-lmVjvu
 
[root@localhost ~]# vgcreate vgnew /dev/hda12 /dev/hda13(Here vgnew is the volume group name)
 Volume group "vgnew" successfully created
[root@localhost ~]# vgs(For show active volume group information)
 VG    #PV #LV #SN Attr   VSize   VFree
 vgnew   2   0   0 wz--n- 576.00M 576.00M
[root@localhost ~]# vgdisplay(For show active volume group information)
  --- Volume group ---
  VG Name               vgnew
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  1
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               576.00 MB
  PE Size               4.00 MB
  Total PE              144
  Alloc PE / Size       0 / 0
  Free  PE / Size       144 / 576.00 MB
  VG UUID               8iLHW9-SYUk-s5wC-g6KW-91Ru-c8nR-PWouxX
 
[root@localhost ~]#lvcreate -L 200M -n newlvm vgnew(Here vgnew is the volume group name & newlvm is logical volume name )
[root@localhost ~]#lvdisplay(For show active logical volume information)
  --- Logical volume ---
  LV Name                /dev/vgnew/newlvm
  VG Name                vgnew
  LV UUID                DH72TL-KYuk-j0lF-qufz-kN6I-YaG4-hrlDOQ
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                200.00 MB
  Current LE             50
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

[root@localhost ~]# lvs(For show active logical volume information)
  LV     VG    Attr   LSize   Origin Snap%  Move Log Copy%  Convert
  newlvm vgnew -wi-a- 200.00M
 
[root@localhost ~]# mkfs.ext3 /dev/vgnew/newlvm
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
51200 inodes, 204800 blocks
10240 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67371008
25 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks:
        8193, 24577, 40961, 57345, 73729

Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 29 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@localhost ~]# mkdir /lvm_partition
[root@localhost ~]# mount /dev/vgnew/newlvm /lvm_partition/
[root@localhost ~]# vim /etc/fstab
/dev/vgnew/newlvm       /lvm_partition          ext3    defaults        0 0

[root@localhost ~]# mount -a
 
[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/hda6              15G  7.1G  6.5G  53% /
tmpfs                 124M     0  124M   0% /dev/shm
/dev/hda8             190M  1.6M  179M   1% /saifulpartion
/dev/md0              958M   18M  892M   2% /raid5
/dev/mapper/vgnew-newlvm
                      194M  5.6M  179M   4% /lvm_partition 
 
[root@localhost ~]# vgdisplay(For show active volume group information)
  --- Volume group ---
  VG Name               vgnew
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  2
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               576.00 MB
  PE Size               4.00 MB
  Total PE              144
  Alloc PE / Size       50 / 200.00 MB
  Free  PE / Size       94 / 376.00 MB
  VG UUID               8iLHW9-SYUk-s5wC-g6KW-91Ru-c8nR-PWouxX

[root@localhost ~]# lvextend -L +200M /dev/vgnew/newlvm(Here we add another 200MB from logical volume group vgnew is the volume group name & newlvm is logical volume name )
  Extending logical volume newlvm to 400.00 MB
  Logical volume newlvm successfully resized
[root@localhost ~]# resize2fs /dev/vgnew/newlvm(After the lvextend we need to use this command,The resize2fs program will resize ext2 or ext3 file systems)
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/vgnew/newlvm is mounted on /lvm_partition; on-line resizing required
Performing an on-line resize of /dev/vgnew/newlvm to 409600 (1k) blocks.
The filesystem on /dev/vgnew/newlvm is now 409600 blocks long.

[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/hda6              15G  7.1G  6.5G  53% /
tmpfs                 124M     0  124M   0% /dev/shm
/dev/hda8             190M  1.6M  179M   1% /saifulpartion
/dev/md0              958M   18M  892M   2% /raid5
/dev/mapper/vgnew-newlvm
                      388M  6.3M  362M   2% /lvm_partition
[root@localhost ~]# lvextend -L +176M /dev/vgnew/newlvm(Here we add another 176MB from logical volume group)
  Extending logical volume newlvm to 576.00 MB
  Logical volume newlvm successfully resized
[root@localhost ~]# resize2fs /dev/vgnew/newlvm
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/vgnew/newlvm is mounted on /lvm_partition; on-line resizing required
Performing an on-line resize of /dev/vgnew/newlvm to 589824 (1k) blocks.
The filesystem on /dev/vgnew/newlvm is now 589824 blocks long.

[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/hda6              15G  7.1G  6.5G  53% /
tmpfs                 124M     0  124M   0% /dev/shm
/dev/hda8             190M  1.6M  179M   1% /saifulpartion
/dev/md0              958M   18M  892M   2% /raid5
/dev/mapper/vgnew-newlvm
                      558M  6.3M  523M   2% /lvm_partition
[root@localhost ~]# vgdisplay
  --- Volume group ---
  VG Name               vgnew
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               576.00 MB
  PE Size               4.00 MB
  Total PE              144
  Alloc PE / Size       144 / 576.00 MB
  Free  PE / Size       0 / 0
  VG UUID               8iLHW9-SYUk-s5wC-g6KW-91Ru-c8nR-PWouxX 

If we wants to add another additional disk to this LVM then do the following :
 
[root@localhost ~]# fdisk /dev/hda

The number of cylinders for this disk is set to 9733.
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 (8889-9733, default 8889): +200
Value out of range.
First cylinder (8889-9733, default 8889):
[1]+  Stopped                 fdisk /dev/hda
[root@localhost ~]# fdisk /dev/hda

The number of cylinders for this disk is set to 9733.
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 (8889-9733, default 8889):
Using default value 8889
Last cylinder or +size or +sizeM or +sizeK (8889-9733, default 9733): +200M

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/hda
[root@localhost ~]# fdisk /dev/hda

The number of cylinders for this disk is set to 9733.
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): t
Partition number (1-14): 14
Hex code (type L to list codes): 8e
Changed system type of partition 14 to 8e (Linux LVM)

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 ~]# pvcreate /dev/hda14
Physical volume "/dev/hda14" successfully created
[root@localhost ~]# vgextend vgnew /dev/hda14
  Volume group "vgnew" successfully extended
[root@localhost ~]# vgdisplay
  --- Volume group ---
  VG Name               vgnew
  System ID
  Format                lvm2
  Metadata Areas        3
  Metadata Sequence No  5
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                3
  Act PV                3
  VG Size               768.00 MB
  PE Size               4.00 MB
  Total PE              192
  Alloc PE / Size       144 / 576.00 MB
  Free  PE / Size       48 / 192.00 MB
  VG UUID               8iLHW9-SYUk-s5wC-g6KW-91Ru-c8nR-PWouxX

[root@localhost ~]# vgs
  VG    #PV #LV #SN Attr   VSize   VFree
  vgnew   3   1   0 wz--n- 768.00M 192.00M
[root@localhost ~]# lvextend -L +192M /dev/vgnew/newlvm
  Extending logical volume newlvm to 768.00 MB
  Logical volume newlvm successfully resized
[root@localhost ~]# resize2fs /dev/vgnew/newlvm
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/vgnew/newlvm is mounted on /lvm_partition; on-line resizing required
Performing an on-line resize of /dev/vgnew/newlvm to 786432 (1k) blocks.
The filesystem on /dev/vgnew/newlvm is now 786432 blocks long.

[root@localhost ~]# vgdisplay
  --- Volume group ---
  VG Name               vgnew
  System ID
  Format                lvm2
  Metadata Areas        3
  Metadata Sequence No  6
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                3
  Act PV                3
  VG Size               768.00 MB
  PE Size               4.00 MB
  Total PE              192
  Alloc PE / Size       192 / 768.00 MB
  Free  PE / Size       0 / 0
  VG UUID               8iLHW9-SYUk-s5wC-g6KW-91Ru-c8nR-PWouxX

[root@localhost ~]# vgs
  VG    #PV #LV #SN Attr   VSize   VFree
  vgnew   3   1   0 wz--n- 768.00M    0
[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/hda6              15G  7.1G  6.5G  53% /
tmpfs                 124M     0  124M   0% /dev/shm
/dev/hda8             190M  1.6M  179M   1% /saifulpartion
/dev/md0              958M   18M  892M   2% /raid5
/dev/mapper/vgnew-newlvm
                      744M  6.6M  699M   1% /lvm_partition 
 
 
Creat Logical Volume Manager at practical life :
Mount Point = /boot
File System Type=ext3
Size(MB) = 400MB
Check force 
to be primary partition and Click OK 
 
Mount Point = /swap 
Size(MB) = 5012MB
Check force 
to be primary partition and Click OK
  

Click – New –Add Partition Window Opens


Click – New –Add Partition Window Opens then select Physical Volume(LVM)
File System Type=physical volume (LVM)
Size(MB) = 28000
Check force to be primary partition
Click OK




Click LVM – Make LVM Volume Group Window opens
Specify Volume Group Name =newvg
Click ok


Now our volume group is shown as bellow ( here volume group name is newvg )


Click Edit for creat logical volume from newly created volume group

 
Specify Volume Group Name =newvg
Click on Add – Make Logical Volume Window Opens
Mount Point = /
File System Type=ext3
Logical Volume Name=LV_root
Size (MB) =10000
Click OK





Specify Volume Group Name =newvg
Click on Add – Make Logical Volume Window Opens
Mount Point = /home
File System Type=ext3
Logical Volume Name=LV_home
Size (MB) =5000
Click OK


Specify Volume Group Name =newvg
Click on Add – Make Logical Volume Window Opens
Mount Point = /var
File System Type=ext3
Logical Volume Name=LV_var
Size (MB) =10000
Click OK


click ok


Now our logical volume shown as bellow

 
 
 

[root@localhost ~]# pvs
  PV                VG     Fmt   Attr   PSize  PFree
  /dev/sda2  newvg   lvm2   a-   27.31G 2.94G
[root@localhost ~]# vgs
  VG    #PV #LV #SN Attr   VSize  VFree
  newvg   1   3   0 wz--n- 27.31G 2.94G
[root@localhost ~]# lvs
  LV           VG    Attr   LSize Origin Snap%  Move Log Copy%  Convert
  LV_home newvg -wi-ao 4.88G
  LV_root   newvg -wi-ao 9.75G
  LV_var     newvg -wi-ao 9.75G
[root@localhost ~]# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               newvg
  PV Size               27.34 GB / not usable 28.09 MB
  Allocatable           yes
  PE Size (KByte)   32768
  Total PE               874
  Free PE                94
  Allocated PE        780
  PV UUID               tyDykM-KGef-wHyE-KRbv-Yyvi-JZyJ-R4bikf

[root@localhost ~]# vgdisplay
  --- Volume group ---
  VG Name               newvg
  System ID
  Format                   lvm2
  Metadata Areas        1
  Metadata Sequence No  4
  VG Access              read/write
  VG Status               resizable
  MAX LV                    0
  Cur LV                     3
  Open LV                  3
  Max PV                   0
  Cur PV                    1
  Act PV                    1
  VG Size                27.31 GB
  PE Size                32.00 MB
  Total PE               874
  Alloc PE / Size       780 / 24.38 GB
  Free  PE / Size       94 / 2.94 GB
  VG UUID               vUUHwc-uR3L-SYqJ-YHy0-XvXW-DQjW-8F7u2f

[root@localhost ~]# lvdisplay
  --- Logical volume ---
  LV Name                   /dev/newvg/LV_root
  VG Name                   newvg
  LV UUID                     hPeCS4-p4KO-Xz0Z-Iyin-RHge-3LPD-gpyaOM
  LV Write Access        read/write
  LV Status                  available
  # open                       1
  LV Size                      9.75 GB
  Current LE                312
  Segments                  1
  Allocation                   inherit
  Read ahead sectors   auto
  - currently set to       256
  Block device             253:0

  --- Logical volume ---
  LV Name                   /dev/newvg/LV_var
  VG Name                  newvg
  LV UUID                    9Tnn5k-mmIl-gNSz-uuJS-vD47-Do4K-PSVnE0
  LV Write Access       read/write
  LV Status                 available
  # open                      1
  LV Size                     9.75 GB
  Current LE               312
  Segments                 1
  Allocation                  inherit
  Read ahead sectors auto
  - currently set to      256
  Block device            253:1

  --- Logical volume ---
  LV Name                   /dev/newvg/LV_home
  VG Name                  newvg
  LV UUID                    FUcOmP-NRhS-YjE4-8Qwq-EFlZ-Gvob-rMhvcq
  LV Write Access        read/write
  LV Status                  available
  # open                       1
  LV Size                      4.88 GB
  Current LE                 156
  Segments                   1
  Allocation                   inherit
  Read ahead sectors   auto
  - currently set to        256
  Block device               253:2
[root@localhost ~]# fdisk -l

Disk /dev/sda: 33.5 GB, 33531363328 bytes
255 heads, 63 sectors/track, 4076 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          51      409626   83  Linux
/dev/sda2              52        3620    28667992+  8e  Linux LVM
/dev/sda3            3621        3685      522112+  82  Linux swap / Solaris

[root@localhost ~]# fdisk /dev/sda

The number of cylinders for this disk is set to 4076.
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
   e   extended
   p   primary partition (1-4)
p
Selected partition 4
First cylinder (3686-4076, default 3686):
Using default value 3686
Last cylinder or +size or +sizeM or +sizeK (3686-4076, default 4076): +500M

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
[root@localhost ~]# partprobe /dev/sda
[root@localhost ~]# partprobe /dev/sda

[root@localhost ~]# fdisk -l

Disk /dev/sda: 33.5 GB, 33531363328 bytes
255 heads, 63 sectors/track, 4076 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          51      409626   83  Linux
/dev/sda2              52        3620    28667992+  8e  Linux LVM
/dev/sda3            3621        3685      522112+  82  Linux swap / Solaris
/dev/sda4            3686        3747      498015   83  Linux
[root@localhost ~]# fdisk /dev/sda

The number of cylinders for this disk is set to 4076.
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): t
Partition number (1-4): 4
Hex code (type L to list codes): 8e
Changed system type of partition 4 to 8e (Linux LVM)

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
[root@localhost ~]# partprobe /dev/sda
[root@localhost ~]# partprobe /dev/sda
[root@localhost ~]# fdisk -l

Disk /dev/sda: 33.5 GB, 33531363328 bytes
255 heads, 63 sectors/track, 4076 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          51      409626   83  Linux
/dev/sda2              52        3620    28667992+  8e  Linux LVM
/dev/sda3            3621        3685      522112+  82  Linux swap / Solaris
/dev/sda4            3686        3747      498015   8e  Linux LVM
[root@localhost ~]# pvcreate /dev/sda4
  Physical volume "/dev/sda4" successfully created
[root@localhost ~]# pvs
  PV         VG    Fmt  Attr PSize   PFree
  /dev/sda2  newvg lvm2 a-    27.31G   2.94G
  /dev/sda4        lvm2 --   486.34M 486.34M
[root@localhost ~]# pvdisplay
  --- Physical volume ---
  PV Name                   /dev/sda2
  VG Name                   newvg
  PV Size                      27.34 GB / not usable 28.09 MB
  Allocatable                 yes
  PE Size (KByte)         32768
  Total PE                     874
  Free PE                      94
  Allocated PE              780
  PV UUID                     tyDykM-KGef-wHyE-KRbv-Yyvi-JZyJ-R4bikf

  "/dev/sda4" is a new physical volume of "486.34 MB"
  --- NEW Physical volume ---
  PV Name                /dev/sda4
  VG Name
  PV Size                 486.34 MB
  Allocatable              NO
  PE Size (KByte)       0
  Total PE                   0
  Free PE                    0
  Allocated PE            0
  PV UUID                   xH6Wcg-zm49-BVK6-B0Je-Cfk2-H5z8-0LYn5Q
[root@localhost ~]# vgextend newvg /dev/sda4
  /dev/cdrom: open failed: Read-only file system
  Attempt to close device '/dev/cdrom' which is not open.
  Volume group "newvg" successfully extended
[root@localhost ~]# vgdisplay
  --- Volume group ---
  VG Name                  newvg
  System ID
  Format                      lvm2
  Metadata Areas         2
  Metadata Sequence   No  5
  VG Access                read/write
  VG Status                 resizable
  MAX LV                      0
  Cur LV                        3
  Open LV                     3
  Max PV                      0
  Cur PV                       2
  Act PV                        2
  VG Size                    27.78 GB
  PE Size                    32.00 MB
  Total PE                   889
  Alloc PE / Size          780 / 24.38 GB
  Free  PE / Size         109 / 3.41 GB
  VG UUID                  vUUHwc-uR3L-SYqJ-YHy0-XvXW-DQjW-8F7u2f

[root@localhost ~]# vgs
  VG    #PV #LV #SN Attr   VSize  VFree
  newvg   2   3   0 wz--n- 27.78G 3.41G
[root@localhost ~]# lvextend -L +1024M /dev/newvg/LV_root
  Extending logical volume LV_root to 10.75 GB
  Logical volume LV_root successfully resized
[root@localhost ~]# lvdisplay
  --- Logical volume ---
  LV Name                   /dev/newvg/LV_root
  VG Name                   newvg
  LV UUID                     hPeCS4-p4KO-Xz0Z-Iyin-RHge-3LPD-gpyaOM
  LV Write Access        read/write
  LV Status                   available
  # open                          1
  LV Size                      10.75 GB
  Current LE                  344
  Segments                      2
  Allocation                    inherit
  Read ahead sectors     auto
  - currently set to          256
  Block device                253:0

  --- Logical volume ---
  LV Name                  /dev/newvg/LV_var
  VG Name                  newvg
  LV UUID                     9Tnn5k-mmIl-gNSz-uuJS-vD47-Do4K-PSVnE0
  LV Write Access        read/write
  LV Status                   available
  # open                          1
  LV Size                         9.75 GB
  Current LE                     312
  Segments                        1
  Allocation                      inherit
  Read ahead sectors      auto
  - currently set to             256
  Block device                   253:1

  --- Logical volume ---
  LV Name                    /dev/newvg/LV_home
  VG Name                     newvg
  LV UUID                      FUcOmP-NRhS-YjE4-8Qwq-EFlZ-Gvob-rMhvcq
  LV Write Access          read/write
  LV Status                     available
  # open                             1
  LV Size                         4.88 GB
  Current LE                    156
  Segments                       1
  Allocation                     inherit
  Read ahead sectors      auto
  - currently set to           256
  Block device                 253:2

[root@localhost ~]# lvs
  LV      VG    Attr   LSize  Origin Snap%  Move Log Copy%  Convert
  LV_home newvg -wi-ao  4.88G
  LV_root newvg -wi-ao    10.75G
  LV_var  newvg -wi-ao     9.75G
[root@localhost ~]# vgs
  VG    #PV #LV #SN Attr   VSize  VFree
  newvg   2   3   0 wz--n- 27.78G 2.41G
[root@localhost ~]# vgdisplay
  --- Volume group ---
  VG Name                newvg
  System ID
  Format                     lvm2
  Metadata Areas        2
  Metadata Sequence No  6
  VG Access                read/write
  VG Status                resizable
  MAX LV                     0
  Cur LV                     3
  Open LV                  3
  Max PV                   0
  Cur PV                    2
  Act PV                     2
  VG Size                27.78 GB
  PE Size                32.00 MB
  Total PE               889
  Alloc PE / Size       812 / 25.38 GB
  Free  PE / Size       77 / 2.41 GB
  VG UUID               vUUHwc-uR3L-SYqJ-YHy0-XvXW-DQjW-8F7u2f
[root@localhost ~]# lvextend -L +1400M /dev/newvg/LV_home
  Rounding up size to full physical extent 1.38 GB
  Extending logical volume LV_home to 6.25 GB
  Logical volume LV_home successfully resized
[root@localhost ~]# vgdisplay
  --- Volume group ---
  VG Name                  newvg
  System ID
  Format                       lvm2
  Metadata Areas            2
  Metadata Sequence   No  7
  VG Access                read/write
  VG Status                 resizable
  MAX LV                           0
  Cur LV                            3
  Open LV                         3
  Max PV                          0
  Cur PV                           2
  Act PV                            2
  VG Size                        27.78 GB
  PE Size                         32.00 MB
  Total PE                         889
  Alloc PE / Size              856 / 26.75 GB
  Free  PE / Size               33 / 1.03 GB
  VG UUID                    vUUHwc-uR3L-SYqJ-YHy0-XvXW-DQjW-8F7u2f

[root@localhost ~]# vgs
  VG    #PV #LV #SN Attr   VSize  VFree
  newvg   2   3   0 wz--n- 27.78G 1.03G
[root@localhost ~]# lvextend -L +1024M /dev/newvg/LV_var
  Extending logical volume LV_var to 10.75 GB
  Logical volume LV_var successfully resized
[root@localhost ~]# vgs
  VG    #PV #LV #SN Attr   VSize  VFree
  newvg   2   3   0 wz--n- 27.78G 32.00M
[root@localhost ~]# vgdisplay
  --- Volume group ---
  VG Name                  newvg
  System ID
  Format                       lvm2
  Metadata Areas           2
  Metadata Sequence No  8
  VG Access                 read/write
  VG Status                    resizable
  MAX LV                            0
  Cur LV                              3
  Open LV                           3
  Max PV                            0
  Cur PV                             2
  Act PV                              2
  VG Size                           27.78 GB
  PE Size                           32.00 MB
  Total PE                          889
  Alloc PE / Size                 888 / 27.75 GB
  Free  PE / Size                1 / 32.00 MB
  VG UUID                    vUUHwc-uR3L-SYqJ-YHy0-XvXW-DQjW-8F7u2f

[root@localhost ~]# lvdisplay
  --- Logical volume ---
  LV Name                   /dev/newvg/LV_root
  VG Name                      newvg
  LV UUID                        hPeCS4-p4KO-Xz0Z-Iyin-RHge-3LPD-gpyaOM
  LV Write Access           read/write
  LV Status                     available
  # open                             1
  LV Size                         10.75 GB
  Current LE                       344
  Segments                         2
  Allocation                       inherit
  Read ahead sectors       auto
  - currently set to            256
  Block device                   253:0

  --- Logical volume ---
  LV Name                  /dev/newvg/LV_var
  VG Name                  newvg
  LV UUID                    9Tnn5k-mmIl-gNSz-uuJS-vD47-Do4K-PSVnE0
  LV Write Access        read/write
  LV Status                  available
  # open                         1
  LV Size                    10.75 GB
  Current LE                 344
  Segments                     3
  Allocation                    inherit
  Read ahead sectors     auto
  - currently set to          256
  Block device                253:1

  --- Logical volume ---
  LV Name                        /dev/newvg/LV_home
  VG Name                         newvg
  LV UUID                      FUcOmP-NRhS-YjE4-8Qwq-EFlZ-Gvob-rMhvcq
  LV Write Access            read/write
  LV Status                      available
  # open                            1
  LV Size                        6.25 GB
  Current LE                    200
  Segments                       2
  Allocation                      inherit
  Read ahead sectors      auto
  - currently set to             256
  Block device                 253:2

[root@localhost ~]# resize2fs /dev/newvg/LV_root
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/newvg/LV_root is mounted on /; on-line resizing required
Performing an on-line resize of /dev/newvg/LV_root to 2818048 (4k) blocks.
The filesystem on /dev/newvg/LV_root is now 2818048 blocks long.

[root@localhost ~]# resize2fs /dev/newvg/LV_var
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/newvg/LV_var is mounted on /var; on-line resizing required
Performing an on-line resize of /dev/newvg/LV_var to 2818048 (4k) blocks.
The filesystem on /dev/newvg/LV_var is now 2818048 blocks long.

[root@localhost ~]# resize2fs /dev/newvg/LV_home
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/newvg/LV_home is mounted on /home; on-line resizing required
Performing an on-line resize of /dev/newvg/LV_home to 1638400 (4k) blocks.
The filesystem on /dev/newvg/LV_home is now 1638400 blocks long.