After increasing the disk size in your hosting or control panel, you must also expand the available space within the Ubuntu 16.04 operating system to make full use of it.
Open a terminal as root and type the following commands:
Check the disk information
Using the section and disk utility parted, get information about the sections:
(parted) p
Model: VMware Virtual disk (scsi)
Disk /dev/sda: %size%GB
Memorize disk size %size%GB.
Resize the section using the resizepart command of the parted utility, specifying the section number %partnum%
As "End" value we use %size% value from the (parted) p output, which you memorized earlier.
Finish the work of the utility parted with the command:
After that we will get information about the need to make changes in the fstab:
Now we will use the fdisk section utility:
After receiving the list of sections with the -l parameter, select the section we need (in our example /dev/sda)
root@Serverspace:~# fdisk /dev/sda
Create a section- section type (L) - logical
Select (default p): l
Adding logical partition %lpart%
Memorize the section number you created during the command (in the example it will be %lpart%).
Accept the value by default - press Enter twice:
Last sector, +sectors or +size{K,M,G} (XXX-YYY, default ZZZ):
Change the section type, write the number of the section you memorized earlier (in the example it was %lpart%).
Partition number (1-X): %lpart%
Hex code (type L to list codes): 8e Command (m for help): w
nform the kernel about the changes:
In the response you’ll see a line. /dev/sda: partition %lpart% added
Initialize the section, instead of %lpart% we again use the section number that we memorized earlier.
Physical volume "/dev/sda%lpart" successfully created
Add a physical section to an existing volume group:
Volume group "ubuntu-vg" successfully extended
Expand the logical volume with lvextend.
Extending logical volume root to YY.ZZ GiB
Logical volume root successfully resized
Expand the file system. with the utility resize2fs.
FAQ: Expanding Disk Space on Ubuntu 16.04
- Q1: Why do I need to expand the disk space in the OS if I already did it in the control panel?
Expanding disk space in the control panel only allocates more virtual storage. To make that space usable by the OS, you must manually resize partitions and logical volumes within Ubuntu. - Q2: Will these instructions work on other Ubuntu versions?
While the general steps are similar, partition names, volume group names, or available tools might differ in newer versions. Always adapt commands to your specific setup. - Q3: What if I don’t use LVM?
If your system doesn’t use LVM, you’ll need to resize the partition and filesystem directly (e.g., using parted and resize2fs), skipping the pvcreate, vgextend, and lvextend steps. - Q4: Is it safe to resize partitions on a live system?
It’s recommended to take a backup or snapshot before proceeding. While resizing is usually safe, any mistake with partition numbers or commands can cause data loss. - Q5: I see a warning about updating /etc/fstab. Should I be worried?
This is a general reminder. If you're only resizing and not changing UUIDs or mount points, /etc/fstab usually doesn't require any changes. - Q6: How can I check if the disk expansion was successful?
You can run df -h to see the updated disk usage, and lsblk or lvdisplay to confirm logical volume changes.