Partition extension using LMV(Logical Volume Manager)

I have using CentOS 5.0 on vmware. I created 5GB initial file size that size is becoming insufficient.I tried to partition extension LVM.

1.Virtual Disk is newly added by VMWare

2.A partition is created.
A partition is created first.
New partition was sdb, the partition of Linux LVM form will be created using fdisk.

[root@c1 ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.

The number of cylinders for this disk is set to 1044.
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)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4):
Value out of range.
Partition number (1-4): 1
First cylinder (1-1044, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1044, default 1044):
Using default value 1044

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): L

0 Empty 1e Hidden W95 FAT1 80 Old Minix be Solaris boot
1 FAT12 24 NEC DOS 81 Minix / old Lin bf Solaris
2 XENIX root 39 Plan 9 82 Linux swap / So c1 DRDOS/sec (FAT-
3 XENIX usr 3c PartitionMagic 83 Linux c4 DRDOS/sec (FAT-
4 FAT16 <32M 40 Venix 80286 84 OS/2 hidden C: c6 DRDOS/sec (FAT-
5 Extended 41 PPC PReP Boot 85 Linux extended c7 Syrinx
6 FAT16 42 SFS 86 NTFS volume set da Non-FS data
7 HPFS/NTFS 4d QNX4.x 87 NTFS volume set db CP/M / CTOS / .
8 AIX 4e QNX4.x 2nd part 88 Linux plaintext de Dell Utility
9 AIX bootable 4f QNX4.x 3rd part 8e Linux LVM df BootIt
a OS/2 Boot Manag 50 OnTrack DM 93 Amoeba e1 DOS access
b W95 FAT32 51 OnTrack DM6 Aux 94 Amoeba BBT e3 DOS R/O
c W95 FAT32 (LBA) 52 CP/M 9f BSD/OS e4 SpeedStor
e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a0 IBM Thinkpad hi eb BeOS fs
f W95 Ext'd (LBA) 54 OnTrackDM6 a5 FreeBSD ee EFI GPT
10 OPUS 55 EZ-Drive a6 OpenBSD ef EFI (FAT-12/16/
11 Hidden FAT12 56 Golden Bow a7 NeXTSTEP f0 Linux/PA-RISC b
12 Compaq diagnost 5c Priam Edisk a8 Darwin UFS f1 SpeedStor
14 Hidden FAT16 <3 61 SpeedStor a9 NetBSD f4 SpeedStor
16 Hidden FAT16 63 GNU HURD or Sys ab Darwin boot f2 DOS secondary
17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fd Linux raid auto
18 AST SmartSleep 65 Novell Netware b8 BSDI swap fe LANstep
1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid ff BBT
1c Hidden W95 FAT3 75 PC/IX
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@c1 ~]#
3.physical volume initialize.

[root@c1 ~]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created

?For a volume group physical volume add.
Before adding to a volume group, a volume group is checked in advance.

[root@c1 ~]# vgdisplay -v
Finding all volume groups
Finding volume group "VolGroup00"
--- Volume group ---
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 5.88 GB
PE Size 32.00 MB
Total PE 188
Alloc PE / Size 188 / 5.88 GB
Free PE / Size 0 / 0
VG UUID JbYi1a-uXuN-H9gb-tHka-4nqW-JKnf-tcQ0o5

--- Logical volume ---
LV Name /dev/VolGroup00/LogVol00
VG Name VolGroup00
LV UUID 4Ob3hN-VeSd-tIuO-AeDN-FRCa-JHH9-rlQiK2
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 0
Block device 253:0

--- Logical volume ---
LV Name /dev/VolGroup00/LogVol01
VG Name VolGroup00
LV UUID L0pn6g-R44S-ildG-rjts-7L3j-5dkn-NLSu0O
LV Write Access read/write
LV Status available
# open 1
LV Size 1.00 GB
Current LE 32
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 253:1

--- Physical volumes ---
PV Name /dev/sda2
PV UUID DFwi4T-xS3b-Q70Q-OofC-IbKq-Y0ga-h2kVOS
PV Status allocatable
Total PE / Free PE 188 / 0

[root@c1 ~]#
"VolGroup00" becomes a volume group.
/dev/sdb1 is added to a volume group.

[root@c1 ~]# vgextend VolGroup00 /dev/sdb1
Volume group "VolGroup00" successfully extended
[root@c1 ~]#

Check volume group.

[root@c1 ~]# vgdisplay -v
Finding all volume groups
Finding volume group "VolGroup00"
--- Volume group ---
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 2
Act PV 2
VG Size 13.84 GB
PE Size 32.00 MB
Total PE 443
Alloc PE / Size 188 / 5.88 GB
Free PE / Size 255 / 7.97 GB
VG UUID JbYi1a-uXuN-H9gb-tHka-4nqW-JKnf-tcQ0o5

--- Logical volume ---
LV Name /dev/VolGroup00/LogVol00
VG Name VolGroup00
LV UUID 4Ob3hN-VeSd-tIuO-AeDN-FRCa-JHH9-rlQiK2
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 0
Block device 253:0

--- Logical volume ---
LV Name /dev/VolGroup00/LogVol01
VG Name VolGroup00
LV UUID L0pn6g-R44S-ildG-rjts-7L3j-5dkn-NLSu0O
LV Write Access read/write
LV Status available
# open 1
LV Size 1.00 GB
Current LE 32
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 253:1

--- Physical volumes ---
PV Name /dev/sda2
PV UUID DFwi4T-xS3b-Q70Q-OofC-IbKq-Y0ga-h2kVOS
PV Status allocatable
Total PE / Free PE 188 / 0

PV Name /dev/sdb1
PV UUID H2UESi-01ZR-uecI-W9j0-Db5i-zFy1-3a1Yeq
PV Status allocatable
Total PE / Free PE 255 / 255

[root@c1 ~]#
It turns out that it is added to the end.

?Logic volume extende.
It refers to the following information displayed by "vgdisplay-v."
By having added, "Free PE" is 255 and "Total PE" is changing to 443.

Before added
Total PE 188
Alloc PE / Size 188 / 5.88 GB
Free PE / Size 0 / 0

After added
Total PE 443
Alloc PE / Size 188 / 5.88 GB
Free PE / Size 255 / 7.97 GB

All the empty spaces will be assigned to logic volume this time.
In order to measure extended size, Total PE is specified and lvextend is performed.
(Although this hit should have the method of the right calculation, it has done by trial and error.)

[root@c1 ~]# lvextend -l 443 /dev/VolGroup00/LogVol00
Extending logical volume LogVol00 to 13.84 GB
Insufficient free space: 188 extents needed, but only 156 available

Since it is what is being done for 32extents shortage, 411 is specified and performed again.

[root@c1 ~]# lvextend -l 411 /dev/VolGroup00/LogVol00
Extending logical volume LogVol00 to 12.84 GB
Logical volume LogVol00 successfully resized

It check.

[root@c1 ~]# vgdisplay -v
Finding all volume groups
Finding volume group "VolGroup00"
--- Volume group ---
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 8
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 2
Act PV 2
VG Size 13.84 GB
PE Size 32.00 MB
Total PE 443
Alloc PE / Size 443 / 13.84 GB
Free PE / Size 0 / 0
VG UUID JbYi1a-uXuN-H9gb-tHka-4nqW-JKnf-tcQ0o5

--- Logical volume ---
LV Name /dev/VolGroup00/LogVol00
VG Name VolGroup00
LV UUID 4Ob3hN-VeSd-tIuO-AeDN-FRCa-JHH9-rlQiK2
LV Write Access read/write
LV Status available
# open 1
LV Size 12.84 GB
Current LE 411
Segments 2
Allocation inherit
Read ahead sectors 0
Block device 253:0

--- Logical volume ---
LV Name /dev/VolGroup00/LogVol01
VG Name VolGroup00
LV UUID L0pn6g-R44S-ildG-rjts-7L3j-5dkn-NLSu0O
LV Write Access read/write
LV Status available
# open 1
LV Size 1.00 GB
Current LE 32
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 253:1

--- Physical volumes ---
PV Name /dev/sda2
PV UUID DFwi4T-xS3b-Q70Q-OofC-IbKq-Y0ga-h2kVOS
PV Status allocatable
Total PE / Free PE 188 / 0

PV Name /dev/sdb1
PV UUID H2UESi-01ZR-uecI-W9j0-Db5i-zFy1-3a1Yeq
PV Status allocatable
Total PE / Free PE 255 / 0

[root@c1 ~]#
The state of a partition is checked.

[root@c1 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
4.8G 4.3G 213M 96% /
/dev/sda1 99M 11M 83M 12% /boot
tmpfs 189M 0 189M 0% /dev/shm
[root@c1 ~]#

6.A file system is made to extend without unmounting.

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

[root@c1 ~]#
I check.

[root@c1 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
13G 4.3G 7.6G 37% /
/dev/sda1 99M 11M 83M 12% /boot
tmpfs 189M 0 189M 0% /dev/shm
[root@c1 ~]#

The availability increased safely.