Extend An ext3/4 Partition Online
Written by: Will Kruss on 21 April 2017 09:04 AM
Here is the instructions that extend a regular ext3 or ext4 partition in your VPS without needing a boot CD. Follow the steps.
* Note: Our VPSs generally use LVM and as such as NOT regular ext3/4 partitions.
This article should not be used for resizing an LVM partition. DO NOT USE THIS FOR SYSTEM PARTITIONS ON VPSs with VPSBLOCKS
To extend a regular ext3 or ext4 partition in your VPS without needing a boot CD you can follow the below instructions. Please note that this example is to extend /dev/sda3 (the root partition on this system). This will work with /dev/sda, /dev/mda and /dev/hda partitions.
Current mounted partition is as below:
From the fdisk you can see that /dev/sda has 107.3GB available. The above df shows that currently about 50GB is being used. So we first need to recreate the partition in fdisk. We do this by deleting the existing partition and recreating it ensuring the same starting sector. Note this will only work to extend the LAST partition that exists (in this case sda3). If your swap partition is the last partition you must delete it first.
Now that you've resized the partition you'll need to resync the partitions list.
You can do that by:
1. Rebooting the server
2. Running the command:
# partx -v -a /dev/sdX
Where sdX is the actual drive (sda, sdb, sdc, etc). The flag -v meaens "verbose output", -a means "Add all partitions". The outpu will contain errors about already existing partitions, but new ones will be added.
Note if you deleted the swap partition first you will need to remove it from the /etc/fstab file or the system will not boot up properly. If you didn't delete any partitions and just followed the above instructions you can safely reboot your server.
Once the server is back online you need to resize the file system. This is done online and no further reboots are required. Simply type:
After this has completed you will see the new space is now available: