I created a standard Ubuntu 8.04 Server virtual machine in ESX 3.5 on a 2GB disk but then needed to resize the disk to 60GB. Here’s a guide how to do that, without having to reformat anything. I used LVM using the Ubuntu installer wizard.
Resize your existing disk in VMware Client (using an GParted ISO), and then reboot the virtual host. Then login and check new partition size:
root@ubuntu:~# parted /dev/sda print
Disk /dev/sda: 64.4GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 32.3kB 255MB 255MB primary ext3 boot
2 255MB 2147MB 1892MB extended
5 255MB 2147MB 1892MB logical lvm
Information: Don’t forget to update /etc/fstab, if necessary.
Create new partition from available space. Start with the last end size (2147MB) and end with the total disk size (64.4GB).
root@ubuntu:~# parted /dev/sda "mkpart primary 2147MB 64.4G"
Check newly created partition:
root@ubuntu:~# parted /dev/sda print
Disk /dev/sda: 64.4GB Sector size (logical/physical): 512B/512B Partition Table: msdos
Number Start End Size Type File system Flags
1 32.3kB 255MB 255MB primary ext3 boot
2 255MB 2147MB 1892MB extended
5 255MB 2147MB 1892MB logical lvm
3 2147MB 64.4GB 62.3GB primary
Information: Don’t forget to update /etc/fstab, if necessary.
Create the physical volume from your new parition:
root@ubuntu:~# pvcreate /dev/sda3
Physical volume “/dev/sda3” successfully created
Check newly created physical volume:
root@ubuntu:~# pvdisplay /dev/sda3
— NEW Physical volume —
PV Name /dev/sda3
VG Name
PV Size 58.00 GB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID 7gsSxU-Vsf7-QpJp-ZPlR-a3BG-x1b8-tz4pyV
root@ubuntu:~# pvs
PV VG Fmt Attr PSize PFree
/dev/sda3 lvm2 — 58.00G 58.00G
/dev/sda5 ubuntu lvm2 a- 1.76G 0
Extend your existing volume group with the newly created physical volume
root@ubuntu:~# vgextend ubuntu /dev/sda3
Volume group “ubuntu” successfully extended
Check it:
root@ubuntu:~# pvs
PV VG Fmt Attr PSize PFree
/dev/sda3 ubuntu lvm2 a- 58.00G 58.00G
/dev/sda5 ubuntu lvm2 a- 1.76G 0
root@ubuntu:~# vgdisplay
— Volume group —
VG Name ubuntu
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 59.75 GB
PE Size 4.00 MB
Total PE 15297
Alloc PE / Size 450 / 1.76 GB
Free PE / Size 14847 / 58.00 GB
VG UUID 5hZbAz-0AgU-I0ui-WNvs-2IgD-IjKi-5sHKi4
Now extend your logical volume with the free PE space (14547):
root@ubuntu:~# lvextend -l +100%FREE /dev/ubuntu/root
Extending logical volume root to 59.62 GB
Logical volume root successfully resized
Resize your root volume (can be done on a live sysyem):
root@ubuntu:~# resize2fs /dev/ubuntu/root
resize2fs 1.40.8 (13-Mar-2008)
Filesystem at /dev/ubuntu/root is mounted on /; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 4
Performing an on-line resize of /dev/ubuntu/root to 15628288 (4k) blocks.
Perform a e2fsck on your root system, if needed. Or just reboot your server, which is safer as it will check the filesystem while it’s not mounted.
root@ubuntu:~# e2fsck -f /dev/ubuntu/root
/dev/ubuntu/root is mounted.
WARNING!!! Running e2fsck on a mounted filesystem may cause SEVERE filesystem damage.
Do you really want to continue (y/n)? yes
/dev/ubuntu/root: recovering journal
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts /dev/ubuntu/root:
***** FILE SYSTEM WAS MODIFIED ***** /dev/ubuntu/root:
***** REBOOT LINUX *****
/dev/ubuntu/root: 45642/3907584 files (0.5% non-contiguous), 344059/15628288 blocks
Reboot your virtual guest and you’re done!