I have an Ubuntu 18.04 server in a VM. The VM administrator has allocated more disk space. How do I resize a partition to use that space?
My setup is as follows:
Device Start End Sectors Size Type
/dev/sda1 2048 1050623 1048576 512M EFI System
/dev/sda2 1050624 5244927 4194304 2G Linux filesystem
/dev/sda3 5244928 424675327 419430400 200G Linux filesystem
/dev/sda4 424675328 529532927 104857600 50G Linux filesystem
/dev/sda5 529532928 1578108927 1048576000 500G Linux filesystem
/dev/sda6 1578108928 1745881087 167772160 80G Linux filesystem
(parted) print free space
Model: Msft Virtual Disk (scsi)
Disk /dev/sda: 1397GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
17.4kB 1049kB 1031kB Free Space
1 1049kB 538MB 537MB fat32 boot, esp
2 538MB 2685MB 2147MB ext4
3 2685MB 217GB 215GB ext4
4 217GB 271GB 53.7GB ext4
5 271GB 808GB 537GB ext4
6 808GB 894GB 85.9GB ext4
894GB 1397GB 503GB Free Space
How can I assign that free space to the fifth partition.
Following the instructions in: https://geekpeek.net/resize-filesystem-fdisk-resize2fs/
I deleted /dev/sda5 and then recreated it, but it remained the same size:
Similarly, following:
https://www.tecmint.com/parted-command-to-create-resize-rescue-linux-disk-partitions/
resizepart doesn't suggest that there's any available disk space to use and the partition remains the same size.
Do I need to remove /dev/sda6 to get access to the available disk space?
If you want to assign free space to partition /dev/sda5
from inside the VM you will first have to get rid of /dev/sda6
partition.
Otherwise the solution is to run GParted from a live CD while the filesystem is not mounted, because you will have to move partitions (in your case, you would have to move the /dev/sda6
partition to the end of the disk, then expand /dev/sda5
with its now adjacent free space).