1

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?

Sean
  • 35
  • 1
  • 7
  • Well, just deleting `/dev/sda5` doesn't help because `/dev/sda4` and `/dev/sda6` remain in the same location on the disk. If you want to enlarge `/dev/sda5`, you must either move `/dev/sda6` forward on the disk to occupy the new space and then `grow` the existing `/dev/sda5` to fill the new space between `4` and `6`. `gparted` is the go to tool with a nice graphical interface that will help. That said, your question is OT here (not "Programming" related) and should be asked on [AskUbuntu](https://askubuntu.com/) or [**Unix & Linux**](http://unix.stackexchange.com/). – David C. Rankin Jun 05 '20 at 08:09
  • This is a very good partitioning question, but you have posted to the wrong StackExchange site. I’m voting to close this question because your question is not "Programming" realated and is more appropriate for the StackExchange sites [Super User](http://superuser.com/) or [Unix & Linux](http://unix.stackexchange.com/) or [AskUbuntu](https://askubuntu.com/). – David C. Rankin Jun 05 '20 at 08:12

1 Answers1

0

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).

mtnezm
  • 1,009
  • 1
  • 7
  • 19