0

I've got a virtual Ubuntu 18.04 server which is running low on disk space. As this is a virtual server I increased the hard disk size in vSphere. I can see the free space in cfdisk but am unsure how to expand the filesystem partition to take advantage of the new space. I can see there is a resize option for the partition but I'm unclear on whether or not that will also format the partitions and lose my data... Bit of a linux n00b, any help would be greatly appreciated.

cfdisk output:

Device         Start        End       Sectors    Size  Type

/dev/sda1       2048       4095          2048      1M  BIOS boot
/dev/sda2       4096   41940991      41936896     20G  Linux filesystem
Free space  41940992  104857566      62916575     30G  

Thanks!

3

For the n00b: Connect with X forwarding enabled (ssh -X yourserver), install gparted and use the user-friendly GUI to resize /dev/sda2.

A more advanced user would probably fire up parted /dev/sda, then enter resizepart 2. The end of the partition will automatically be selected to match the end of the disk. This will only resize the partition, though. The file-system can be resized to span the whole partition with the appropriate tool, like resize2fs /dev/sda2 for ext2/3/4.

| improve this answer | |
0

As an additional note: In this case (free space after the end of the partition which will be resized) it should be possible to resize the partition by:

growpart /dev/sda 2

You can install growpart by installing the package: cloud-guest-utils.

Just as a note: There is always a risk of losing data when performing this kind of operations on disks/partitions.

| improve this answer | |
  • Good point. Yet I want to add that data-loss during online growing is so very unlikely, I consider it safe. – Hermann Feb 1 at 15:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.