Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a bigger boot disk on Google Compute Engine [closed]

Default images have 10GB, but I need more (30GB approx). If I create a disk of 30GB using one of that default images, the usable space it's 10GB, not 30GB. I know I can install the distro using tools like debootstrap, but that seems unnecessarily complicated. is there any other way to do it?

like image 588
user1193085 Avatar asked Dec 07 '22 01:12

user1193085


2 Answers

This may be a new feature as of this writing, but go to

  1. https://console.cloud.google.com/compute/
  2. Click on Disks in the left menu
  3. In the main pane that loads, click on your instance
  4. In the upper horizontal menu that loads, click on Edit
  5. The former disk size will become editable. Change the disk size to your desired size.
  6. Restart your instance (sudo restart -r now). On reboot, df -h lists your new disk size.

So, one approach to answering your question is to create an instance with the default disk and simply resize it via the Compute Engine GUI.

like image 178
Kwame Avatar answered Jan 13 '23 13:01

Kwame


You can create a boot disk larger than 10GB but then you'll need to repartition it, because by default, the provided VM images expand to 10GB so you'll need to use these instructions and run fdisk, reboot, and then run resize2fs to expand the usable space to the full size of the disk. You can automate it so that it runs as part of instance creation by using startup scripts.

Edit 1: I have open-sourced my scripts which do this for you automatically at boot using the startup-script metadata. You can find sample code in my GitHub repo created specifically for this question, which has been verified to work with CentOS and Debian. See fdisk.sh for the repartitioning and gcloud.sh for the deployment commands.

Edit 2: Alternatively, you can also create an additional disk and attach it to your instance but you'll also need to format and mount it before you can use it.

like image 33
Misha Brukman Avatar answered Jan 13 '23 15:01

Misha Brukman