Manually import boot disks

Linux
The image import feature on Compute Engine is being moved to Migrate to Virtual Machines. We recommend that you use the newimage import feature on Migrate to Virtual Machines to import your virtual disks to Google Cloud.

The recommended way to import boot disk images to Compute Engine fromyour physical datacenters, from virtual machines (VMs) on your localworkstation, orfrom VMs that run on another cloud platform, is to use thevirtual disk import tool,which automates all of the steps in this guide.

If you prefer not to use the automated tool, you can follow the manual,step-by-step instructions in this guide.

This image import process canimport only one disk at a time, and this guide focuses on how to import bootdisk images.

Import your existing boot disks only if you are unable to build or migrate yourapps to run on top ofCompute Engine public images.Public images are already configured to run in the Compute Engineenvironment, so you can run apps on those images without having toworry about bootloader and operating system configurations. However, you mightneed to import your own boot disk images in the following scenarios:

  • Your apps require an operating system that is not provided as apublic image.
  • You already have a set of basic images that you use to create VMsin another cloud platform.
  • The work required to migrate app code to one of the public imagesis greater than the work required to complete the boot disk image importprocess.

Alternatively, you can get assistance with migration for your VMsusing partner services. For more information, seeMigrating VMs to Compute Engine.

Overview

To import a boot disk image to Compute Engine, use the followingprocess:

  1. Plan your import path. You must identify where you are going to prepare yourboot disk image before you upload it, and how you are going to connect tothat image after it boots in the Compute Engine environment.
  2. Prepare your boot disk so it can boot within the Compute Engineenvironment and so you can access it after it boots.
  3. Create and compress the boot disk image file.
  4. Upload the image file toCloud Storage and import theimage to Compute Engine as a newcustom image.
  5. Use the imported image to create a VM instance and make sureit boots properly.
  6. If the image does not successfully boot, you can troubleshoot the issue byattaching the boot disk image to another instance and reconfiguring it.
  7. Optimize the imageand install theguest environmentso that your imported operating system image can communicate with themetadata server and use additional Compute Engine features.

Requirements

Requirements for the boot disk

To import boot disks to Compute Engine, the boot disks must meetthe following requirements:

  • We recommend that you install all available updates in your source VM.
  • If you built a custom operating system kernel, it must meet thehardware and kernel configuration requirements.Most stock Linux distributions already meet these requirements, so thisrequirement is only for advanced users who build their own custom operatingsystems to run on Compute Engine.
  • The boot disk must be no larger than 2048 GB (2 TB).
  • The boot disk that you import must have a functionalMBR partition table or a hybrid configuration of aGPT partition table with an MBR bootloader.
  • The primary partition on the boot disk can be in any format that you like aslong as it boots properly from the MBR bootloader.
  • The bootloader on the boot disk must not havequiet,rhgb, orsplashimage= kernel command-line arguments. Compute Engine doesnot support splash screens on startup. You can remove these values from theGRUB config during thebootloader configuration step.
  • The operating system on the boot disk must supportACPI.

Requirements for the image file

The image file that you import must meet the following requirements:

  • Perform a consistency check on the disk image by using theqemu-img checkcommand on the disk.
  • To export the virtual disk, use the export function of your VM managementsoftware. Don't copy the VMDK file from your VM manager's file system.
  • The image file must be of asupported image.
  • The disk image filename must bedisk.raw.
  • The RAW image file must have a size in an increment of 1 GB. For example,the file must be either 10 GB or 11 GB but not 10.5 GB.
  • The compressed file must be a.tar.gz file that usesgzip compression and the--format=oldgnu option for thetar utility (manual).

Requirements for your project

When you create a VM instance from an imported image, theinstance must be able to access the external package repository for theoperating system that is configured on the boot disk.

This repository can be accessed directly from the operating system vendor orthrough a network connection to your on-premises infrastructure that hosts theserepositories.

To set up access to the external repository, complete one of thefollowing steps in your project:

Limitations

To import disks using networks that don't allow external IP addresses you needto meet additional networking requirements. For more information,seeImporting disks using networks that don't allowexternal IP addresses.

Image import costs

Before you begin, understand the costs for the import process. There is nocost for theinbound network data transfer to uploadyour boot disk image file to Cloud Storage and there is no cost toimport that image as a Compute Enginecustom image. However, thereare costs for some specific steps in the import process:

  • The cost to temporarily store your compressed image files in aCloud Storagestandard bucket.You must use a temporary Cloud Storage bucket to hold your filesbefore you can import them as custom Compute Engine images. Youcan remove the bucket after you complete the import process.
  • The cost forstoring custom imagesafter you finish importing them to Compute Engine.
  • The potential cost for outbound data transfers on your existing data center,network provider, or your current cloud service. Image files can be very largeeven after you compress them, so copying those files toCompute Engine could incur significant outbound data transfercharges on some platforms.
  • The cost for Compute Enginepersistent disks andVM instances where you canconfigure your image after you import it to Compute Engine.

Plan and prepare your import path

Your method for importing your disk depends on the current configuration of thesystem that you want to move to Compute Engine. You need a systemwhere you can create and compress the boot disk image file as well as a systemwhere you can upload the image file to Cloud Storage. Consider thefollowing items when you plan your import path:

  • The image import path requires you to configure your boot disk in a workingoperating system environment. This process can cause the boot disk to notboot anywhere outside of a Compute Engine environment. It is yourresponsibility to ensure that you do not lose data on your disks or disruptyour functional business apps while you import your system toCompute Engine.
  • Identify what your existing system access configuration is, and plan how youwant to access the system after you import it to Compute Engine.
    • If your system has existing user login or SSH configurations, you canconfigure only the bootloader and then later configure the image to runoptimally on Compute Engine. You can access theinstance through your existing SSH configuration or through a directuser login in theinteractive serial console.
    • If your system does not have existing user login or SSH configurations,you must configure the boot disk so that you are able to access it afterit boots on Compute Engine.
  • The length of the import process can take several hours or days dependingon the size of your boot disk and the speed of your network connection.
  • The system where you create and compress your boot disk image must have enoughstorage space to create the image files on a storage device other than theboot disk itself. Typically your image andtar.gz files use 2–3 timesas much space as the boot disk itself.
  • Understand the file system structure for the existing system that you wantto import.
    • If your operating system and app files are spread acrossmultiple disks, import each of those disks individually and useeach image to create a unique persistent disk for yourCompute Engine VM instance.
    • If your systems have boot volumes in aRAID configuration where multiple disks act as a single logical volume, createa single image from the entire array rather than creating one image foreach disk in the array. Compute Engine persistent diskseliminate the need for RAID configurations.
  • If your system encrypts the contents of your boot disk with aTrusted Platform Module or with software-level encryption, decrypt your boot disk before you createthe boot disk image file. Google cannot read your images if they areencrypted. We encrypt your images for you after you upload them, and let youprovide your own encryption keys for yourpersistent disks andCloud Storage buckets.

After you identify or create a system where you can complete the importprocess, connect to that system andconfigure the bootloader.

Prepare the boot disk image

On a running system, prepare the boot disk image so that it can function ina Compute Engine environment.

  • Configure the bootloader on the boot disk so that the image can boot onCompute Engine.
  • Configure SSH or user login access on the boot disk so that you canaccess it after you import it to Compute Engine and start itas a VM instance.

This process can make the system unbootable outside of Compute Engine,so the best practice is to complete this step on an isolated system using acopy of the boot disk that you want to import.

Configure the bootloader

Configure the bootloader on the system so that it can boot onCompute Engine.

  1. Connect to the terminal on the system with the boot disk that you plan toimport.

  2. Edit the GRUB config file. Usually this file is at/etc/default/grub,but on some earlier distributions, it might be located in a non-standarddirectory.

  3. Make the following changes to the GRUB config file:

    • Remove any line that hassplashimage=. Compute Engine doesnot support splash screens on startup.
    • Remove therhgb andquiet kernel command-line arguments.
    • Addconsole=ttyS0,38400n8d to the kernel command-line arguments, sothat the instance caninteract with the Serial Console.
  4. Regenerate thegrub.cfg file. Use one of the following commands, dependingon your distribution.

    • Debian and Ubuntu:sudo update-grub
    • RHEL, CentOS, SUSE, openSUSE:sudo grub2-mkconfig -o /boot/grub2/grub.cfg
  5. Edit the/etc/fstab file and remove references to all disks and partitionsother than the boot disk itself and partitions on that boot disk. Invalidentries in/etc/fstab can cause your system startup process to stop.

After you configure the bootloader,create and compress the disk image file.

Configure SSH or user login access on the image

After your image is running in Compute Engine as a VMinstance, you must have a way to access that instance. You can either connectto the instance using an existing SSH configuration or you can sign in usinga username and password by connecting to theSerial Console.

Complete the SSH or user login configuration before youcreate and compress the disk image file.

Create and compress the disk image file

Create and compress the boot disk image file for the system that you want toimport to Compute Engine. The process to create and compress theimage file is different depending on the platform where your systems operate.

Generic

On almost any system, you can use this process to create a RAW image filethat you can import to Compute Engine. You can complete thisprocess on the running system that you are importing, or you can attachyour boot disk as a secondary disk on another system and create the bootdisk image from the stopped disk. Ensure that you have enough availablestorage space to temporarily hold the disk image files. This exampletakes an image from a running system.

  1. Connect to the terminal on the system that has the boot disk that youplan to import.

  2. Use thelsblk command to identify the source boot disk from which youwant to create an image and the location where you have sufficient spaceto write the image files. For this example,/dev/sda is the sourceboot disk and/dev/sdb is a large secondary disk mounted at the/tmp directory. Although /dev/sda is running, you can still createan image from it. It is best to do this on a quiet system that is notactively processing data or running apps.

    lsblk
    NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTsda      8:0    0  100G  0 disk├─sda1   8:1    0   96G  0 part /├─sda2   8:2    0    1K  0 part└─sda3   8:5    0    4G  0 part [SWAP]sdb      8:16   0  500G  0 disk /tmpsr0     11:0    1 1024M  0 rom
  3. Create the image file from your boot disk.

    sudo dd if=/dev/sda of=/tmp/disk.raw bs=4M conv=sparse
  4. Change to the directory where you wrote thedisk.raw file.

    cd /tmp
  5. Compress the raw disk intotar.gz format. This step compresses theimage file so that you can more quickly upload it toCloud Storage. On OSX,installgtar and use it for this step instead oftar.

    tar --format=oldgnu -Sczf /tmp/compressed-image.tar.gz disk.raw

VirtualBox

If you prepared your system in a VirtualBox environment, you can use theVBoxManage tool to convert a.vdi or.qcow2 disk image todisk.raw format.

  1. Shut down the VirtualBox guest machine that you want to import, replacingGUEST_NAME with the name of your guest machine. You canshut down the guest machine with the VirtualBox interface or by using theVBoxManage utility.

    VBoxManage controlvmGUEST_NAME acpipowerbutton
  2. Convert the guest image to RAW format by using theVBoxManage utility, replacingGUEST_NAME with the path to your guestimage. This guest image can be supplied as either avdi orqcow2file:

    VBoxManage clonemediumGUEST_NAME ~/disk.raw --format RAW
  3. Compress the raw disk intotar.gz format. This step compresses theimage file so that you can more quickly upload it toCloud Storage. On OSX,installgtar,and use it for this step instead oftar.

    sudo tar --format=oldgnu -Sczf /tmp/compressed-image.tar.gz disk.raw

The image file is compressed and ready to upload to Cloud Storage.

Import the image to your custom images list

Upload the file to Cloud Storage and import the image into your customimages list. Optionally, you canencrypt the imageduring the image import step.

Import the image with either the console or theGoogle Cloud CLI tools:

Console

Copy thecompressed-image.tar.gz file to your local workstation anduse the Google Cloud console tocreate a bucket and upload the file.

  1. In the Google Cloud console, go to the Cloud Storagebrowser page.

    Go to Browser

  2. At the top of the page, clickCreate bucket.
  3. Specify a unique bucket name, theStandard storage class, and a locationwhere you want to store your image files.
  4. ClickCreate to create the bucket. The browser page navigates tothe new bucket.
  5. At the top of the page, clickUpload files.
  6. In the file dialog, select thecompressed-image.tar.gz filethat you downloaded from your system. The file uploads from yourlocal workstation. This step can take several hours depending on thesize of your compressed image file and the speed of your networkconnection.

After you upload the image to Cloud Storage, import the image fileto your custom images list.

  1. In the Google Cloud console, go to theImages page.

    Go to Images

  2. At the top of the page, clickCreate image.
  3. In theName field, specify a unique name for the image.
  4. Optionally, specify an image family for your new image, or configurespecific encryption settings for the image.
  5. Click theSource menu and selectCloud Storage file.
  6. Enter the path to thecompressed-image.tar.gz file that you uploadedto Cloud Storage.

    BUCKET_NAME/compressed-image.tar.gz
  7. ClickCreate to import the image. The process can takeseveral minutes depending on the size of the boot disk image.

The image is now included on theImages page. You cancreate a VM using this imported image. If there is a bootfailure, verify and ensure that you have configured the bootloader correctly.

gcloud and gcloud storage

Use the gcloud CLI to upload thecompressed boot disk image file. You can complete this process on thesystem where you created the boot disk image, or you can copy that file toanother system and complete the upload process there, instead.

  1. Install and initialize the gcloud CLI on thesystem from which you plan to upload thecompressed-image.tar.gz.

  2. Use the gcloud CLI to create a new Cloud Storagebucket.

    gcloud storage buckets create gs://BUCKET_NAME
  3. Upload thecompressed-image.tar.gz file to the new bucket.

    gcloud storage cp compressed-image.tar.gz gs://BUCKET_NAME
  4. Import the image file as a new custom image.

    Note: When you manually import an image, you must set the right licensecode for your operating system using the--licenses flag. For more information on license codes,in theOperating system details page,see theLicense tab in the section applicable to your operatingsystem.
    gcloud compute images createIMAGE_NAME --source-uri gs://BUCKET_NAME/compressed-image.tar.gz

    Replace the following:

    • IMAGE_NAME: the name of the image that you imported.
    • BUCKET_NAME: the name of the bucket that the imported imageis stored in.

The image is now included in the list of custom images. You cancreate a VM using this imported image. If there is a bootfailure, verify and ensure that you have configured the bootloader correctly.

gcloud compute images list --no-standard-images
NAME                                            PROJECT                  FAMILY                    DEPRECATED  STATUS[IMAGE_NAME]                                    [PROJECT_ID]                                                   READY

Test the imported image to ensure it works

Confirm that the imported image works as expected. Create a VM witha boot disk that uses the imported image.

Console

  1. In the Google Cloud console, go to theCreate an instance page.

    Go to Create an instance

  2. In theBoot disk section, clickChange, and then do the following:

    1. Select theCustom images tab.
    2. To select the image project, clickSelect a project, and then dothe following:
      1. Select the project that contains the image.
      2. ClickOpen.
    3. In theImage list, click the image that you imported.
    4. Select the type and size of your boot disk.
    5. To confirm your boot disk options, clickSelect.
  3. ClickCreate.

gcloud

gcloud compute instances createVM_NAME --zoneZONE --imageIMAGE_NAME

Replace the following:

  • VM_NAME: a unique name for your VM.
  • ZONE: the zone where you created the standalone disk.
  • IMAGE_NAME: the name of the image that you imported.

After you create the VM, confirm that it booted properly. Check theserial port output:

Console

  1. In the Google Cloud console, go to theVM instances page.

    Go to Instances

  2. On the list of VMs, click the name of the VM that youcreated from the imported image. The VM details page opens.
  3. In theLogs section, click the appropriate serial port to expand andview the serial port output for this VM.

If the VM stopped atBooting from Hard Disk 0..., you musttroubleshootthe issues from within the Compute Engine environment, or you canreconfigure the boot disk on your original system and repeat the importprocess.

gcloud

gcloud compute instances get-serial-port-outputVM_NAME

If the VM stopped atBooting from Hard Disk 0..., you musttroubleshootthe issues from within the Compute Engine environment or you canreconfigure the boot disk on your original system and repeat the importprocess.

You can also test the VM by connecting to it. Connect to the VMthrough one of the following options:

  • SSH: If the VM had a functional SSH configuration, you can connectto the VM using SSH and your private key. You can find the VM instance IPaddress on theVM instances page.
  • Serial Console: If you need to sign in to the VM directlywithout SSH, you can enable theSerial Consoleand sign in with a username and password.

What's next

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-15 UTC.