Skip to main content
  1. All Posts/

compute-archlinux-image-builder

Tools Shell

Arch Linux Image Builder for Google Compute Engine

This project provides a script that creates an Arch
Linux
image that can run on Google Compute
Engine
.
The image is configured to be as close as possible to a base Arch Linux
installation, while still allowing it to be fully functional and optimized for
Compute Engine. Notable choices made and differences compared to a standard
Arch Linux installation are the following:

  • systemd-boot is used with a UEFI-based boot and a GPT partition table.
  • Serial console logging is enabled from kernel command line and journald is
    configured to forward to it.
  • Block multiqueue is configured from the kernel command line to optimize
    Compute Engine disk performance.
  • A minimal initcpio is configured for booting on Compute Engine virtual
    machines.
  • Root filesystem is ext4.
  • Locale is set to en_US.UTF-8 and timezone is set to UTC.
  • Network is configured through dhclient.
  • Systemd-timesyncd is enabled and configured to use the Compute Engine metadata
    server.
  • Pacman keyring is configured to be built and initialized on first boot.
  • Pacman mirror list is taken fresh from Arch Linux servers at the time the
    image is built.
  • Linux Guest Environment for Google Compute
    Engine is
    installed and enabled.
  • An OpenSSH server is installed and enabled, with root login and password
    authentication forbidden. User SSH keys are deployed and managed
    automatically by the Linux Guest Environment as described in the
    corresponding
    documentation
    .
  • Sudo is installed. Permission to use sudo is managed automatically by Linux
    Guest Environment.
  • Root partition and filesystem are automatically extended at boot using
    systemd-repart and systemd-growfs, to support dynamic disk resizing.
  • An additional Pacman repository is used to install and keep the Linux Guest
    Environment

    packages up to date.

Prebuilt Images

You can use Cloud SDK to create instances
with the latest prebuilt Arch Linux image. To do that follow the SDK
installation procedure, and then run the following
command
:

$ gcloud compute instances create INSTANCE_NAME 
      --image-project=arch-linux-gce --image-family=arch

For older images, see the current_images.txt file.

Build Your Own Image

You can build the Arch Linux image yourself with the following procedure:

  1. Install the required dependencies and build the image

    $ sudo pacman -S --needed arch-install-scripts dosfstools e2fsprogs
    $ git clone https://github.com/GoogleCloudPlatform/compute-archlinux-image-builder.git
    $ cd compute-archlinux-image-builder
    $ sudo ./build-arch-gce
    <p>
      You can also use the <code>build-arch-gce</code> package from the AUR, and run<br /> <code>sudo /usr/bin/build-arch-gce</code><br /> If the build is successful, this will create an image file named<br /> arch-vDATE.tar.gz in the current directory, where DATE is the current date. </li> 
      
      <li>
        Install and configure the <a rel="nofollow noopener" target="_blank" href="https://cloud.google.com/sdk/docs/">Cloud SDK</a>.
      </li>
      <li>
        Copy the image file to Google Cloud Storage:</p> <pre>$ gsutil mb gs://BUCKET_NAME
    

    $ gsutil cp arch-vDATE.tar.gz gs://BUCKET_NAME

  2.   <li>
        Import the image file to Google Cloud Engine as a new custom image:</p> <pre>$ gcloud compute images create IMAGE_NAME 
      --source-uri=gs://BUCKET_NAME/arch-vDATE.tar.gz 
      --guest-os-features=GVNIC,UEFI_COMPATIBLE,VIRTIO_SCSI_MULTIQUEUE</pre>
      </li></ol> 
      
      <p>
        You can now create new instances with your custom image:
      </p>
      
      <pre>$ gcloud compute instances create INSTANCE_NAME --image=IMAGE_NAME</pre>
      
      <p>
        The Google Cloud Storage file is no longer needed, so you can delete it if you<br /> want:
      </p>
      
      <pre>$ gsutil rm gs://BUCKET_NAME/arch-vDATE.tar.gz</pre>
      
      <h2 dir="auto">
        <a rel="nofollow noopener" target="_blank" id="user-content-contributing-changes" class="anchor" aria-hidden="true" href="#contributing-changes"></a>Contributing Changes
      </h2>
      
      <ul dir="auto">
        <li>
          See CONTRIB.md
        </li>
      </ul>
      
      <h2 dir="auto">
        <a rel="nofollow noopener" target="_blank" id="user-content-licensing" class="anchor" aria-hidden="true" href="#licensing"></a>Licensing
      </h2>
      
      <p>
        All files in this repository are under the Apache License, Version<br /> 2.0 unless noted otherwise.
      </p>
      
      <h2 dir="auto">
        <a rel="nofollow noopener" target="_blank" id="user-content-support" class="anchor" aria-hidden="true" href="#support"></a>Support
      </h2>
      
      <p>
        Google Inc. does not provide any support, guarantees, or warranty for this<br /> project or the images provided.
      </p>