Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can size of the root disk in Google Compute Engine be increased?

The root disk size in GCE is 10 gigs. How do I increase this? I cant find the option in the console or the gcutil flags. This can be easily done in AWS.

like image 521
Rishin S Babu Avatar asked Mar 13 '14 14:03

Rishin S Babu


People also ask

Can I attach more disks or resize current disk of the Compute Engine without any downtime?

You can check your instance before adding the new disk with this command. Connect your instance by clicking the SSH button and execute the following command. You can also resize the disk without any downtime.

What is the maximum size of Compute Engine local disks?

Compute Engine offers always-encrypted local solid-state drive (SSD) block storage for virtual machine (VM) instances. Each local SSD is 375 GB in size, but you can attach a maximum of 24 local SSD partitions for 9 TB per instance.


4 Answers

As of 31 Mar 2016, you can resize a persistent disk online without stopping or rebooting the VM, without taking snapshots, and without having to restore it to a larger disk.

The blog post announcing the feature has the details, and you can see the docs for how to do this via the console:

Resize the persistent disk in the Google Cloud Platform Console:

  1. Click on Compute Engine product tab.
  2. Select Disks under the "Storage" section.
  3. Click on the name of the disk that you want to resize to get to the disk details page.
  4. At the top of the disk details page, click "Edit".
  5. In the "Size" field, enter the new size for your disk.
  6. At the bottom of the disk details page, click "Save" to apply your changes to the disk.
  7. After you resize the disk, you must resize the disk partitions so that the operating system can access the additional space.

Or via CLI:

gcloud compute disks resize example-disk --size 250

Then, on Debian/Ubuntu/etc. run:

$ sudo apt install -y cloud-utils         # Debian jessie
$ sudo apt install -y cloud-guest-utils   # Debian stretch, Ubuntu
$ sudo growpart /dev/sda 1
$ sudo resize2fs /dev/sda1

or, for RedHat/Fedora/CentOS/etc.:

$ sudo dnf install -y cloud-utils-growpart
$ sudo growpart /dev/sda 1
$ sudo xfs_growfs -d /                    # CentOS 6 needs `resize2fs`

Note that some operating systems will automatically resize your partition on reboot without requiring you to do any manual steps with tools such as fdisk, resize2fs or xfs_growfs, so it should be sufficient to just resize the disk and reboot the VM for changes to take effect.

like image 140
Misha Brukman Avatar answered Oct 19 '22 20:10

Misha Brukman


  1. create a new disk from snapshot, but increase the size when doing so
  2. create a new instance, using new, embiggened disk
  3. embiggen the partition to recognize the new space (https://cloud.google.com/compute/docs/disks/persistent-disks#repartitionrootpd) (NOTE: pay special attention to the starting sector, don't just blindly hit return, you can, however blindly hit return on the ending sector)
  4. sudo resize2fs /dev/sda1 (note, this step is not mentioned in the google cloud docs)
like image 20
user1130176 Avatar answered Oct 19 '22 21:10

user1130176


In most cases, it will be simpler and more flexible to create a second data disk of the size you want, and attach it to the instance.

To resize a Persistent Disk (including a root disk), snapshot the disk, then create a new larger disk from the snapshot.

like image 5
Brian Dorsey Avatar answered Oct 19 '22 20:10

Brian Dorsey


This is more like a follow-up to @user1130176's answer, but if you are running CentOS 7+, you'll need to do the following for step #4 (expanding the filesystem): xfs_growfs /dev/sda1

The new disks on CentOS 7 are of type xfs. Hope this helps, it was not very clear from all the links around.

like image 5
mohsenrezaeithe Avatar answered Oct 19 '22 21:10

mohsenrezaeithe