Category Archives: Google Cloud Platform

How to Expand a Boot Disk on a GCE Instance

Google now allows you specify the size of your boot disk larger than 10GB when you create your instance. In any case, if you need to resize your boot disk for any reason, these are the steps I followed.

Here I’ve attached a 250GB blank disk to the instance:

“pv” gives you a progress of the “dd” command. This will take some time. Once it’s finished:

Now we re-partition the disk:

fdisk-expand

Now you could run:

  1. Detach the disk,
  2. Clone the instance and choose this disk as the root disk.
  3. SSH and make sure everything looks good.
  4. Once it looks good, you could delete the original instance and create a new instance with this disk.

Google Cloud Services – How to Use Access Tokens Directly

For whatever reason you can’t use gsutil, gcloud, or a client library, you could request an access token directly. This example uses PHP 5.2 (the PHP client library only works  with PHP 5.3+). Please make sure your instance has access to the correct scopes and that a service account is enabled.
gce-project-access-scope

Related Resources:

  • https://cloud.google.com/compute/docs/metadata?hl=en
  • https://cloud.google.com/compute/docs/authentication

Example Usage of Ruby Client LIbrary for Google Cloud Storage

How to Create a Swap File on Google Compute Engine Virtual Machines

These are the procedures I followed for Ubuntu 14.04 LTS but should work with other Debian distros.

Once you’ve done this you could make this permanent by editing the /etc/fstab file:

If you’re using CentOS 7, Patrick in comments points out:

  1. The fallocate failed if you did not use ‘sudo’.
  2. the ‘swapon’ command failed on the root xfs, moved swap to ext works fine.

How to Setup gcloud Tool on Ubuntu 12.04 LTS

If you see:

CommandException: arg (XXXXX) does not name a directory, bucket, or bucket subdir.

Keep in mind rsync works on directories, cp works on files.