You just upgraded your VPS and wondering why your Linux VPS Disk space (same applies to dedicated server) is still not upgraded ?
Well Disk space is upgraded but your Partition Table or File System is not aware of it, so here is how you fix it:
Below is example of Resizing disk space for a VPS from 10 G to 15 G:
After upgrade first login to your VPS control panel and reboot VPS from there to make sure VPS is actually upgraded, then login to your VPS via SSH and run following commands:
root@test27:~# df -h
Filesystem Size Used Avail Use% Mounted on
udev 489M 0 489M 0% /dev
tmpfs 100M 3.6M 96M 4% /run
/dev/vda1 9.9G 1.6G 7.8G 17% / (Current Disk space that we need to upgrade to 15GB from 10GB)
tmpfs 497M 0 497M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 497M 0 497M 0% /sys/fs/cgroup
Now we will use fdisk to first delete the partition and then recreate it at same start position but newer end position to able to use the extra disk space.
root@test27:~# fdisk /dev/vda
Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): p (type p here to print existing partition table)
Disk /dev/vda: 15 GiB, 16106127360 bytes, 31457280 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x8717be48
Device Boot Start End Sectors Size Id Type
/dev/vda1 * 2048 20969215 20967168 10G 83 Linux
Command (m for help): d (By typing "d" we are deleting existing partition)
Selected partition 1
Partition 1 has been deleted.
Command (m for help): n (now we will create a new partition from same start position)
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p (make sure to type "p" as this is your primary partition)
Using default response p.
Partition number (1-4, default 1): (just press enter as default values are good)
First sector (2048-31457279, default 2048): (just press enter as default values are good)
Last sector, +sectors or +size{K,M,G,T,P} (2048-31457279, default 31457279): (again just press enter to take default values)
Created a new partition 1 of type 'Linux' and of size 15 GiB.
Command (m for help): w (type w and then press enter to save the new partition table)
The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Device or resource busy
Now reboot your VPS and then login again to your VPS/Server
Now again login to your VPS via ssh and we will use "resize2fs" to resize your partition.
root@test27:~# resize2fs /dev/vda1
resize2fs 1.42.13 (17-May-2015)
Filesystem at /dev/vda1 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 1
The filesystem on /dev/vda1 is now 3931904 (4k) blocks long.
root@test27:~# df -h
Filesystem Size Used Avail Use% Mounted on
udev 489M 0 489M 0% /dev
tmpfs 100M 3.6M 96M 4% /run
/dev/vda1 15G 1.6G 13G 11% / (Disk upgraded without any data loss)
tmpfs 497M 0 497M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 497M 0 497M 0% /sys/fs/cgroup
The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8).
Note: Please use this tutorial carefully and always backup data before doing it as even a slightest mistake can lead to permanent data loss.