Translator
      English flagItalian flagKorean flagChinese (Simplified) flagChinese (Traditional) flagPortuguese flagGerman flagFrench flag
      Spanish flagJapanese flagArabic flagRussian flagGreek flagDutch flagBulgarian flagCzech flag
      Croatian flagDanish flagFinnish flagHindi flagPolish flagRomanian flagSwedish flagNorwegian flag
      Catalan flagFilipino flagHebrew flagIndonesian flagLatvian flagLithuanian flagSerbian flagSlovak flag
      Slovenian flagUkrainian flagVietnamese flagAlbanian flagEstonian flagGalician flagMaltese flagThai flag
      Turkish flagHungarian flagBelarus flagIrish flagIcelandic flagMacedonian flagMalay flagPersian flag
    Tag Cloud
    Sponsors
    Recent Comments
      Link with us

      IT Solutions Knowledge Base

      Copyright Protected
      256-bit Secured



How to extend VMWare LVM disks in Linux
Home » CentOS, Linux » How to extend VMWare LVM disks in Linux
By | 3 CommentsLeave a Comment
Last updated: Tuesday, May 18, 2010

In this article we will explain the process of increasing VMWare LVM disks under Linux OS.

Our current setup shows that we have only 1.3GB of available free space

This is the current filesystem

Step1:

df -h

Step2:

Power Off VMWare Guest

shutdown -h now

Increase the size of the Virtual Disk by 10GB

vmware-vdiskmanager.exe -x 10GB  disk.vmdk

Step 3:

Start up VMWare Guest

Create a partition on the new space

fdisk /dev/sda

# List current partitions

Command (m for help): p

Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        1044     8281507+  8e  Linux LVM

# Create a new partition /dev/sda3

Command (m for help): n
Command action
e   extended
p   primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (1045-1305, default 1045):
Using default value 1045
Last cylinder or +size or +sizeM or +sizeK (1045-1305, default 1305):
Using default value 1305

# Change partition type to LVM

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

# List partitions

Command (m for help): p

Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        1044     8281507+  8e  Linux LVM
/dev/sda3            1045        1305     2096482+  8e  Linux LVM

# Write the changes

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.

Step 4:

Reboot the VMWare Guest

Validate that the new partition has been created

fdisk -l

[root@localhost ~]# fdisk -l

Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        1044     8281507+  8e  Linux LVM
/dev/sda3            1045        1305     2096482+  8e  Linux LVM

Create a physical volume for LVM

pvcreate /dev/sda3

[root@localhost ~]# pvcreate /dev/sda3
Physical volume “/dev/sda3″ successfully created

Step 5:

Add the new physical volume to the volume group

vgextend VolGroup00 /dev/sda3

[root@localhost ~]# vgextend VolGroup00 /dev/sda3
Volume group “VolGroup00″ successfully extended

Step 6:

Find how much space is available to expand the volume

vgdisplay

[root@localhost ~]# vgdisplay
— 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               9.84 GB
PE Size               32.00 MB
Total PE              315
Alloc PE / Size       252 / 7.88 GB
Free  PE / Size 63 / 1.97 GB
VG UUID               9fPKQ9-vy4z-kmJ8-eO8n-3Yw9-qcwK-gJhz0q

Step 7:

Extend the volume

lvextend -L+1.9G /dev/VolGroup00/LogVol00

[root@localhost ~]# lvextend -L+1.9G /dev/VolGroup00/LogVol00
Rounding up size to full physical extent 1.91 GB
Extending logical volume LogVol00 to 7.84 GB
Logical volume LogVol00 successfully resized

Step 8:

Resize the filesystem

resize2fs /dev/VolGroup00/LogVol00

[root@localhost ~]# resize2fs /dev/VolGroup00/LogVol00
resize2fs 1.35 (28-Feb-2004)
/dev/VolGroup00/LogVol00 is mounted; can’t resize a mounted filesystem!

Lets use ext2online instead

ext2online /dev/VolGroup00/LogVol00

[root@localhost ~]# ext2online /dev/VolGroup00/LogVol00
ext2online v1.1.18 – 2001/03/18 for EXT2FS 0.5b

Final Result
We can see our new disk layout with our disk increased with a new size of 3.0GB.

Comments

3 comments
  1. mrfoo
    June 27, 2011

    Thanks that really worked for me!

    [Reply]

    Leave a reply
  2. Philip Galloway
    July 14, 2011

    Just followed this though on a centos 5 box. Worked a treat with a few dodgy moments. The pvcreate, vgextend commands are under the “lvm” shell which confused me initially, other than that a cracking howto. Thanks.

    [Reply]

    Leave a reply
  3. Martin Dahl-Larsen
    March 5, 2012

    It did the job for my Centos 6.2,
    Realy nice and easy how to..
    Keep up the good job.

    //Martin

    [Reply]

    Leave a reply

Leave a Comment

Add your picture!
Join Gravatar and upload your avatar. C'mon, it's free!