Let’s assume we are extending a disc which was originally 16GB to 40GB on VMware…
Please note: the following procedure is for ext3 partitions on modern Linux distros on discs that are NOT using LVM. For LVM partitioned disc there are different commands and procedures to follow.
Preparing VM disk
First of all let’s shutdown your VM and then extend the disc size using:
vmware-vdiskmanager -x 40Gb youre-vm-virtual-disk-name.vmdk
Once vdiskmanager is done with extending your disk you can boot up your virtual machine and begin to resize your mounted partition.
Extending ext3 mounted partition size
1) When you Virtual Machine is up and running, login as root and check if fdisk correctly see the new disc size with:
(Please take note of the Total Sectors that fdisk will display)
2) Now let’s create a partition table configuration file for sda (you can change sda disc with your own disc if different) using sfdisk utility:
sfdisk -d /dev/sda > ~/sfdisk_sda.orig
3) Create a backup copy of this configuration:
cp ~/sfdisk_sda.orig ~/sfdisk_sda.new
4) At this point let’s edit the file and change the end of your desired partition, let’s assume you are extending sda1:
Modify where it says size:
/dev/sda1 : start=63, size=1743246, Id= 83
with the number of [total sectors] shown by fdisk output at point 1 – start sector shown on the line you are modifying, save and exit.
Please Note: If you have multiple partitions on the same disk then the math is a bit more complicated than just [total sectors] – [start sector], in fact, you’ll have to subtract all the sizes of all the partitions you have on your sda disc as well as their starting points.
5) Now let’s update your partition table configuration:
sfdisk --force /dev/sda < ~/sfdisk_sda.new
6) Now update Kernel using:
Some Linux distro can’t update kernel live so you may need to reboot after partprobe, if partprobe ask you so then reboot using:
7) When the kernel partition table is updated (if you had to reboot then login again as root) extend your partition to the full available disk space with:
At this point, if everything went well, your sda1 should be of 40GB.
Thanks for reading and, if you enjoyed this post, please support my blog by visiting my on-line hacking and engineering merchandise shop on redbubble.com by clicking here, thank you! 🙂