Andrea Zonzin
Andrea Zonzin

Reputation: 1154

Ubuntu GCE does not see new system disk space after disk resize

I have an Ubuntu 16.04.3 LTS GCE instance. I increased system disk space (from 20 GB to 30 GB) but after GCE restart, if I run

df -h 

I still get 20GB on disk size.

In the past, on Ubuntu GCE Instances, after the instance restart, the System automatically saw new disk space.

Also in the documentation I read:

"Alternatively, instances that use most recent versions of Public Images can automatically resize their partitions and file systems after a system reboot. The SUSE Linux Enterprise Server (SLES) public images are the only images that do not support this feature."

So, what is the problem? What can I do to get the new space?

Upvotes: 1

Views: 438

Answers (1)

hkanjih
hkanjih

Reputation: 1301

You can execute:

$ sudo lsblk
$ sudo resize2fs /dev/sda1 30G

If you receive the message:

The filesystem is already 5242619 (4k) blocks long. Nothing to do!

Sorry, I believe that you can't resize the disk using resize2fs.

So, I know two alternatives that you can follow.

Alternative 1 - Attach another one disk in the VM.

Alternative 2 - Create a new disk from a snapshot of the original disk. Steps to create a disk from a snapshot:

  1. Stop the machine (not necessary but it is safe)
  2. Take a snapshot
gcloud beta compute disks snapshot <disk_name> --project=<project_id> --snapshot-names=snapshot-1 --zone=<zone> --storage-location=us 
  1. Create a new machine from that snapshot

Upvotes: 2

Related Questions