News
Seven days of Black Friday madness — great deal from Serverspace!

THE NEW YEAR
WHEEL OF FORTUNE

Spin the wheel and win a guaranteed prize right now!

By registering, you are signing up to receiving emails.
DC
May 14 2020
Updated December 11 2024

How to expand disk space on Ubuntu 16.04

Ubuntu VPS

Using another OS?

Select the desired version or distribution.

After expanding the disk space in the control panel, you need to expand it at the operating system level.

Open a terminal as root and type the following commands:

root@Serverspace:~# echo 1 /sys/block/sda/device/rescan

Check the disk information

Using the section and disk utility parted, get information about the sections:

root@Serverspace:~# parted
(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%

(parted) resizepart %partnum%

As "End" value we use %size% value from the (parted) p output, which you memorized earlier.

End? [XX.X GB]? %Size%GB

Finish the work of the utility parted with the command:

(parted) quit

After that we will get information about the need to make changes in the fstab:

Information: You may need to update /etc/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 -l
root@Serverspace:~# fdisk /dev/sda

Create a section- section type (L) - logical

Command (m for help): n
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:

First sector (XXX-YYY, default ZZZ):
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%).

Command (m for help): t
Partition number (1-X): %lpart%
Hex code (type L to list codes): 8e Command (m for help): w

nform the kernel about the changes:

root@Serverspace:~# partx -v -a /dev/sda

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.

root@Serverspace:~# pvcreate /dev/sda%lpart%
Physical volume "/dev/sda%lpart" successfully created

Add a physical section to an existing volume group:

root@Serverspace:~# vgextend ubuntu-vg /dev/sda%lpart%
Volume group "ubuntu-vg" successfully extended

Expand the logical volume with lvextend.

root@Serverspace:~# lvextend -l +100%FREE //dev/ubuntu-vg/root
Extending logical volume root to YY.ZZ GiB
Logical volume root successfully resized

Expand the file system. with the utility resize2fs.

root@Serverspace:~# resize2fs /dev/ubuntu-vg/root

Vote:
5 out of 5
Аverage rating : 5
Rated by: 1
1101 CT Amsterdam The Netherlands, Herikerbergweg 292
+31 20 262-58-98
700 300
ITGLOBAL.COM NL
700 300
We use cookies to make your experience on the Serverspace better. By continuing to browse our website, you agree to our
Use of Cookies and Privacy Policy.