user1193085
user1193085

Reputation: 207

Can I create an OS image of more than 10GB on Google Compute Engine?

I need to boot about 500 instances with an specific image to do a job with big files that requires POSIX access to more than 10GB. According to that doc https://developers.google.com/compute/docs/images it's impossible create a boot disk of more than 10GB and I need POSIX access to more than 10 GB. Does this mean I will need to create another non-boot disk on each instance with disk space I need? Is there another way to do that?

Upvotes: 3

Views: 1252

Answers (4)

maljub01
maljub01

Reputation: 384

You can easily do this without having to manually resize/partition/format a disk or any of the complications introduced in all the other answers on StackOverflow. Please see my answer here for how this can be done: How to get a bigger boot disk on Google Compute Engine

Upvotes: 0

Misha Brukman
Misha Brukman

Reputation: 13424

You can use Packer to create images on GCE which will auto-resize on boot. I have created a repo specifically for this question which has a demo of an auto-resizing image using recent versions of either Debian-7 backports or container-optimized VM images.

It uses cloud-initramfs-growroot:

automatically resize the root partition on first boot

This package adds functionality to an initramfs built by initramfs-tools. When installed, the initramfs will repartition a disk to make the root volume consume all space that follows it.

You most likely do not want this package unless you know what you are doing. It is primarily interesting in a virtualized environment when a disk can provisioned with a size larger than its original size. In this case, with this package installed, you can automatically use the new space without requiring a reboot to re-read the partition table.

See my script growroot.sh for details and how you can adapt it to your use case.

Upvotes: 1

Misha Brukman
Misha Brukman

Reputation: 13424

You have two options:

  1. 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.

  2. Another alternative is to create a separate persistent disk and attach it separately, but then it won't be a boot disk but just a data disk. For that you can use the instructions on the same page, namely:

    • gcutil adddisk [...]
    • gcutil attachdisk [...], unless the boot and data disks are added during instance creation via gcutil addinstance --disk=disk1 --disk=disk2 [...], in which case this is not needed
    • /usr/share/google/safe_format_and_mount [...] to automate the rest

Upvotes: 0

IanGSY
IanGSY

Reputation: 3714

That doc refers to a limit to the size of the operating system Image, not the size of the boot disk.

You can create a boot disk of any size, and then use it when creating the instance, e.g:

gcutil adddisk "disk-1" --size_gb="15" --zone="europe-west1-b" --source_image="https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-7-wheezy-v20140522"

gcutil addinstance "instance-1" --zone="europe-west1-b" --machine_type="n1-standard-1" --network="default" --external_ip_address="ephemeral" --metadata="sshKeys:" --disk="disk-1,deviceName=disk-1,mode=READ_WRITE,boot" --auto_delete_boot_disk="true"

See: https://developers.google.com/compute/docs/disks#create_disk

Upvotes: 1

Related Questions