There are a bunch of steps you need to do, if memory serves.
Firstly, you'll need to use pvresize
to expand the existing PV to the new top-of-partition.
Then you'll need to use lvresize
or lvextend
to resize the existing LV volume(s) into the enlarged PV.
Then you can use resize2fs
to resize the file system(s) into the new enlarged volume(s).
As you pointed out:
All Compute Engine Ubuntu images will automatically resize the root
partition to use the entire disk
Then, as per your output, you have a 10GB disk and a 10GB partition so it's not possible to resize that partition.
If you want to have a larger root disk, you'll need to create disk with the desired space. You can do it with the Cloud SDK with the following steps:
1- Create a snapshot of your instance:
gcloud compute disks snapshot DISK_NAME --snapshot-names SNAPSHOT_NAME --zone ZONE --project PROJECT_ID
2- Create a disk based on that snapshot:
gcloud compute disks create NAME --source-snapshot SOURCE_SNAPSHOT --size SIZE --zone ZONE --project PROJECT_ID
After that the disk is automatically partitioned with enough space for the root filesystem
3- Create an instance with that disk:
gcloud compute instances create NAME --disk "name=DISK_NAME" "boot=yes" --zone ZONE --project PROJECT_ID
Since Ubuntu supports automatic resizing, once it boots it should resize the partition and you should have the desired GB.
Alternatively, if you are still able to SSH into the instance, you can attach a new disk to the instance following these steps:
4- Create a new disk:
gcloud compute disks create NAME --size SIZE --zone ZONE --project PROJECT_ID
5- Attach the new disk:
gcloud compute instances attach-disk INSTANCE_NAME --disk NEW_DISK_NAME --zone ZONE --project PROJECT_ID
6- SSH into the instance:
gcloud compute ssh INSTANCE_NAME --zone ZONE --project PROJECT_ID
7- Format the new disk.
8- Transfer files from the root disk to the new one to free up space and upload the other files to the new disk.
Best Answer
Apparently I just had to restart the instance and it was automatically resized. This behavior was mentioned in another point of the documentation: