Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies to: ✔️ Linux VMs
This article provides step-by-step instructions for capturing a Linux image to prepare it for upload to Azure.
Prerequisites
Before proceeding, ensure the following prerequisites are met:
- Access to the Linux machine whose disk you want to image.
- Azure CLI installed on your local machine.
- An Azure account with appropriate permissions to upload images.
Steps to capture a Linux image
Prepare the Linux VM for imaging, including stopping unnecessary services and cleaning up temporary files:
sudo systemctl stop <service-name> sudo apt-get clean sudo rm -rf /tmp/*
Create an image of the disk using the
dd
command:sudo dd if=/dev/sdX of=/path/to/output/image.img bs=4M
Note
Replace
/dev/sdX
with the appropriate disk identifier.Compress the disk image to save space and reduce upload time:
gzip /path/to/output/image.img
Install the Azure CLI on your local machine if it's not installed:
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
Sign in to Azure using the Azure CLI:
az login
Create a resource group where you'll store the image (if needed):
az group create --name <ResourceGroupName> --location <Location>
Create a storage account to upload the image:
az storage account create --name <StorageAccountName> --resource-group <ResourceGroupName> --location <Location> --sku Standard_LRS
Create a storage container within the storage account:
az storage container create --account-name <StorageAccountName> --name <ContainerName>
Upload the compressed disk image to the storage container:
az storage blob upload --account-name <StorageAccountName> --container-name <ContainerName> --name image.img.gz --file /path/to/output/image.img.gz
Create a managed disk from the uploaded VHD:
az disk create --resource-group <ResourceGroupName> --name <DiskName> --source https://<StorageAccountName>.blob.core.windows.net/<ContainerName>/image.img.gz
Create an image from the managed disk:
az image create --resource-group <ResourceGroupName> --name <ImageName> --source <DiskName>
Verify that the image has been created successfully:
az image show --resource-group <ResourceGroupName> --name <ImageName>
You have now created a Linux image from an on-premises disk and uploaded it to Azure. You can use this image to create new VMs in your Azure environment.
Contact us for help
If you have questions or need help, create a support request, or ask Azure community support. You can also submit product feedback to Azure feedback community.