It's possible to resize disks in a VMware ESX / Infrastructure environment. Increasing is easy, and there's almost no risk on losing data. If you need to make a disk smaller you should always turn the guest off, since there is a serious chance of losing data. To resize disks there are two steps to follow, first resize the actual disk and then you need the guest operating system to recognize the new available disk space.
There are two ways to resize disks:
Before you start following this procedure keep these points in mind:
Shrinking the volume works on the same way, just add an extra switch --force
This functionality only works with ESX editions prior to 3.
Procedure:
Use the just described way to check where in the filesystem the diskfile is located
Log on to the ESX server on the commandline and become root
Navigate to the diskfile
Issue this command to resize the disk:
vmkfstools -X <new size> <disk name>.vmdk
In linux you could also assign the disk to another guest to resize the partition, you can use the normal system tools then. In Suse, that would be: Yast2 → System → Partitioner.
Not so long ago, I tried this procedure on a SLES 10 SP2 box and ran into some problems. I downloaded the latest Knoppix version, 6.2.1 and there was no qtpart application available, on both the CD and the DVD. So eventually, I resized the disk using 'gparted'. When I rebooted the machine I ran into the problem that only the partition was resized and not the file system:
Partitioner:
/dev/sdb │ 20.0 GB│ │VMware-Virtual disk│ │ │ 0│2609│
/dev/sdb1│ 19.9 GB│ │Linux native │/opt │K │ 0│2609│
This is however what df -h said:
/dev/sdb1 9.9G 4.2G 5.3G 45% /opt
So, I still had to resize the filesystem:
slesbox:~ # resize2fs /dev/sdb1
resize2fs 1.38 (30-Jun-2005)
Please run 'e2fsck -f /dev/sdb1' first.
slesbox:~ # e2fsck -f /dev/sdb1
e2fsck 1.38 (30-Jun-2005)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/sdb1: 9143/1310720 files (8.1% non-contiguous), 1205470/2620595 blocks
slesbox:~ # resize2fs /dev/sdb1
resize2fs 1.38 (30-Jun-2005)
Resizing the filesystem on /dev/sdb1 to 5241198 (4k) blocks.
The filesystem on /dev/sdb1 is now 5241198 blocks long.
After these steps I could mount the filesystem again and use the new space:
slesbox:~ # mount /opt
slesbox:~ # df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sdb1 20G 4.5G 15G 24% /opt
Discussion