Log in

No account? Create an account
entries friends calendar profile Previous Previous Next Next
Extending an EXT3 linux filesystem on VMWare ESX - Ed's journal
Extending an EXT3 linux filesystem on VMWare ESX
VMWare ESX is a tool for hosting multiple concurrent instances of guest operating systems.

Sometimes it's necessary to increase disk space on your guest VM.

To do this:
Expanding the disk is easy enough. A filesystem expansion will only work if it's the last filesystem on the disk, without major effort. This is often a problem with root filesystems on redhat enterprise, as they seem to like to 'default' having swap as the last partition. (That case is actaully fairly easy to handle, I'll get to how to do it)

Find the disk file you need to extend. It'll be listed in the config file, under VirtualCentre or in the host properties. (sda = scsi0:0, sdb = scsi0:1 etc.). Find out which disk file that 'means' - it'll either be vmhba0:0:2 or similar, or using one of the labels that you gave your vmfs filesystems. And it'll generally be a vmdk file on the filesystem.

Log into the vmware server. cd /vmfs/vmhba0:0:2
vmkfstools -X .vmdk ( is _total size_ not 'how much to extend by' so be careful, making it smaller might cause badness)

Start the vm.

For the purposes of this, lets assume /dev/sdc1 is mounted as /data). EXT3 is basically EXT2 with a journal file. The linux utility 'resize2fs' can't cope with EXT3 journals, so you have to delete it (and make it EXT2) first, extend, and then recreate the journal.

umount /data

tune2fs -O ^has_journal /dev/sdc1
e2fsck -f /dev/sdc1
fdisk /dev/sdc
delete and recreate the partion. IT MUST START AT THE SAME POINT ON THE DISK.
resize2fs /dev/sdc1
tune2fs -j /dev/sdc1
mount -t ext3 /dev/sdc1 /data

And that should do it.
There's options to resize2fs, but on my vmware config, with virtual disks, it really does make a lot of sense to have 1 filesystem per virtual disk

Now, if you've got a default install of Redhat enterprise, you'll find about the point where you fdisk, you have a swap partition on the last part of the disk.
This is actually fairly easy to deal with. Assuming you only want to expand a filesystem, not insert one in the middle

Make a note of the size of the swap partition. (in cylinders is easiest to deal with). (Actually, when messing with fdisk, it's worth saving a copy of the partition table layout anyway)
Delete it.
Create another 'swap' partition at the end of the disk, of the same number of cylinders.
sync and reboot.
The partition table on the disk won't get read until boot time.
Your machine will come up, and you should see no difference in your swap - /dev/sda3 (default on RHEL is /boot as /dev/sda1, / as /dev/sda2 and swap as /dev/sda3)

Now you can resize '/' in the manner I suggested, although be REALLY careful that you don't overlap on the first cylinder of the swap partition.
You will probably need to reboot after doing the fdisk, removing the journal, and resize2fs if you're working on the root filesystem. Well, by 'need' I mean 'it would be a really good idea to'


2 comments or Leave a comment
csi_ellie From: csi_ellie Date: April 6th, 2006 03:21 pm (UTC) (Link)
wha?? bah!
sobrique From: sobrique Date: May 22nd, 2006 08:52 am (UTC) (Link)
Vital things to know, don'tcha know.
2 comments or Leave a comment