Linux
The image import feature on Compute Engine is being moved to Migrate to Virtual Machines. We recommend that you use the new image 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 from your physical datacenters, from virtual machines (VMs) on your local workstation, or from VMs that run on another cloud platform, is to use the virtual 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 can import only one disk at a time, and this guide focuses on how to import boot disk images.
Import your existing boot disks only if you are unable to build or migrate your apps to run on top of Compute Engine public images. Public images are already configured to run in the Compute Engine environment, so you can run apps on those images without having to worry about bootloader and operating system configurations. However, you might need to import your own boot disk images in the following scenarios:
Alternatively, you can get assistance with migration for your VMs using partner services. For more information, see Migrating VMs to Compute Engine.
OverviewTo import a boot disk image to Compute Engine, use the following process:
To import boot disks to Compute Engine, the boot disks must meet the following requirements:
quiet
, rhgb
, or splashimage=
kernel command-line arguments. Compute Engine does not support splash screens on startup. You can remove these values from the GRUB config during the bootloader configuration step.The image file that you import must meet the following requirements:
qemu-img check
command on the disk.disk.raw
..tar.gz
file that uses gzip compression and the --format=oldgnu
option for the tar
utility (manual).When you create a VM instance from an imported image, the instance must be able to access the external package repository for the operating system that is configured on the boot disk.
This repository can be accessed directly from the operating system vendor or through a network connection to your on-premises infrastructure that hosts these repositories.
To set up access to the external repository, complete one of the following steps in your project:
To import disks using networks that don't allow external IP addresses you need to meet additional networking requirements. For more information, see Importing disks using networks that don't allow external IP addresses.
Image import costsBefore you begin, understand the costs for the import process. There is no cost for the inbound network data transfer to upload your boot disk image file to Cloud Storage and there is no cost to import that image as a Compute Engine custom image. However, there are costs for some specific steps in the import process:
Your method for importing your disk depends on the current configuration of the system that you want to move to Compute Engine. You need a system where you can create and compress the boot disk image file as well as a system where you can upload the image file to Cloud Storage. Consider the following items when you plan your import path:
tar.gz
files use 2–3 times as much space as the boot disk itself.After you identify or create a system where you can complete the import process, connect to that system and configure the bootloader.
Prepare the boot disk imageOn a running system, prepare the boot disk image so that it can function in a Compute Engine environment.
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 a copy of the boot disk that you want to import.
Configure the bootloaderConfigure the bootloader on the system so that it can boot on Compute Engine.
Connect to the terminal on the system with the boot disk that you plan to import.
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-standard directory.
Make the following changes to the GRUB config file:
splashimage=
. Compute Engine does not support splash screens on startup.rhgb
and quiet
kernel command-line arguments.console=ttyS0,38400n8d
to the kernel command-line arguments, so that the instance can interact with the Serial Console.Regenerate the grub.cfg
file. Use one of the following commands, depending on your distribution.
sudo update-grub
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
Edit the /etc/fstab
file and remove references to all disks and partitions other than the boot disk itself and partitions on that boot disk. Invalid entries 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 imageAfter your image is running in Compute Engine as a VM instance, you must have a way to access that instance. You can either connect to the instance using an existing SSH configuration or you can sign in using a username and password by connecting to the Serial Console.
Complete the SSH or user login configuration before you create and compress the disk image file.
Create and compress the disk image fileCreate and compress the boot disk image file for the system that you want to import to Compute Engine. The process to create and compress the image file is different depending on the platform where your systems operate.
GenericOn almost any system, you can use this process to create a RAW image file that you can import to Compute Engine. You can complete this process on the running system that you are importing, or you can attach your boot disk as a secondary disk on another system and create the boot disk image from the stopped disk. Ensure that you have enough available storage space to temporarily hold the disk image files. This example takes an image from a running system.
Connect to the terminal on the system that has the boot disk that you plan to import.
Use the lsblk
command to identify the source boot disk from which you want to create an image and the location where you have sufficient space to write the image files. For this example, /dev/sda
is the source boot disk and /dev/sdb
is a large secondary disk mounted at the /tmp
directory. Although /dev/sda is running, you can still create an image from it. It is best to do this on a quiet system that is not actively processing data or running apps.
lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 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 /tmp sr0 11:0 1 1024M 0 rom
Create the image file from your boot disk.
sudo dd if=/dev/sda of=/tmp/disk.raw bs=4M conv=sparse
Change to the directory where you wrote the disk.raw
file.
cd /tmp
Compress the raw disk into tar.gz
format. This step compresses the image file so that you can more quickly upload it to Cloud Storage. On OSX, install gtar
and use it for this step instead of tar
.
tar --format=oldgnu -Sczf /tmp/compressed-image.tar.gz disk.raw
If you prepared your system in a VirtualBox environment, you can use the VBoxManage
tool to convert a .vdi
or .qcow2
disk image to disk.raw
format.
Shut down the VirtualBox guest machine that you want to import, replacing GUEST_NAME with the name of your guest machine. You can shut down the guest machine with the VirtualBox interface or by using the VBoxManage utility.
VBoxManage controlvm GUEST_NAME acpipowerbutton
Convert the guest image to RAW format by using the VBoxManage utility, replacing GUEST_NAME with the path to your guest image. This guest image can be supplied as either a vdi
or qcow2
file:
VBoxManage clonemedium GUEST_NAME ~/disk.raw --format RAW
Compress the raw disk into tar.gz
format. This step compresses the image file so that you can more quickly upload it to Cloud Storage. On OSX, install gtar
, and use it for this step instead of tar
.
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 listUpload the file to Cloud Storage and import the image into your custom images list. Optionally, you can encrypt the image during the image import step.
Import the image with either the console or the Google Cloud CLI tools:
ConsoleCopy the compressed-image.tar.gz
file to your local workstation and use the Google Cloud console to create a bucket and upload the file.
compressed-image.tar.gz
file that you downloaded from your system. The file uploads from your local workstation. This step can take several hours depending on the size of your compressed image file and the speed of your network connection.After you upload the image to Cloud Storage, import the image file to your custom images list.
Enter the path to the compressed-image.tar.gz
file that you uploaded to Cloud Storage.
BUCKET_NAME/compressed-image.tar.gz
Click Create to import the image. The process can take several minutes depending on the size of the boot disk image.
The image is now included on the Images page. You can create a VM using this imported image. If there is a boot failure, verify and ensure that you have configured the bootloader correctly.
gcloud and gcloud storageUse the gcloud CLI to upload the compressed boot disk image file. You can complete this process on the system where you created the boot disk image, or you can copy that file to another system and complete the upload process there, instead.
Install and initialize the gcloud CLI on the system from which you plan to upload the compressed-image.tar.gz
.
Use the gcloud CLI to create a new Cloud Storage bucket.
gcloud storage buckets create gs://BUCKET_NAME
Upload the compressed-image.tar.gz
file to the new bucket.
gcloud storage cp compressed-image.tar.gz gs://BUCKET_NAME
Import the image file as a new custom image.
Note: When you manually import an image, you must set the right license code for your operating system using the--licenses
flag. For more information on license codes, in the Operating system details page, see the License tab in the section applicable to your operating system.
gcloud compute images create IMAGE_NAME --source-uri gs://BUCKET_NAME/compressed-image.tar.gz
Replace the following:
The image is now included in the list of custom images. You can create a VM using this imported image. If there is a boot failure, 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] READYTest the imported image to ensure it works
Confirm that the imported image works as expected. Create a VM with a boot disk that uses the imported image.
ConsoleIn the Google Cloud console, go to the Create an instance page.
In the Boot disk section, click Change, and then do the following:
Click Create.
gcloud compute instances create VM_NAME --zone ZONE --image IMAGE_NAME
Replace the following:
After you create the VM, confirm that it booted properly. Check the serial port output:
ConsoleIf the VM stopped at Booting from Hard Disk 0...
, you must troubleshoot the issues from within the Compute Engine environment, or you can reconfigure the boot disk on your original system and repeat the import process.
gcloud compute instances get-serial-port-output VM_NAME
If the VM stopped at Booting from Hard Disk 0...
, you must troubleshoot the issues from within the Compute Engine environment or you can reconfigure the boot disk on your original system and repeat the import process.
You can also test the VM by connecting to it. Connect to the VM through one of the following options:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4