Skip to content

Commit ad56f63

Browse files
authored
AB#3654: Simplfy and break up article:
1 parent 4c980f5 commit ad56f63

File tree

2 files changed

+137
-128
lines changed

2 files changed

+137
-128
lines changed
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
---
2+
title: Capture Linux Images for Upload Preparation
3+
description: Offers the steps to capture a Linux image for upload preparation.
4+
ms.custom: sap:Cannot create a VM, linux-related-content
5+
ms.service: azure-virtual-machines
6+
ms.date: 05/16/2025
7+
ms.reviewer: srijangupta, scotro, maries, jarrettr, v-weizhu
8+
---
9+
# How to capture a Linux image for upload preparation
10+
11+
**Applies to:** :heavy_check_mark: Linux VMs
12+
13+
This article outlines the steps to capture a Linux image for preparing to upload it to Azure.
14+
15+
## Prerequisites
16+
17+
- Access to the Linux machine whose disk you want to image.
18+
- Azure CLI installed on your local machine.
19+
- An Azure account with appropriate permissions to upload images.
20+
21+
## Steps to capture a Linux image
22+
23+
1. Prepare the Linux VM for imaging, including stopping unnecessary services and cleaning up temporary files:
24+
25+
```bash
26+
sudo systemctl stop <service-name>
27+
sudo apt-get clean
28+
sudo rm -rf /tmp/*
29+
```
30+
31+
2. Create an image of the disk using the `dd` command:
32+
33+
```bash
34+
sudo dd if=/dev/sdX of=/path/to/output/image.img bs=4M
35+
```
36+
37+
> [!NOTE]
38+
> Replace `/dev/sdX` with the appropriate disk identifier.
39+
40+
3. Compress the disk image to save space and reduce upload time:
41+
42+
```bash
43+
gzip /path/to/output/image.img
44+
```
45+
46+
4. Install the Azure CLI on your local machine if it's not installed:
47+
48+
```bash
49+
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
50+
```
51+
52+
5. Sign in to Azure using the Azure CLI:
53+
54+
```bash
55+
az login
56+
```
57+
58+
6. Create a resource group where you'll store the image (if needed):
59+
60+
```bash
61+
az group create --name <ResourceGroupName> --location <Location>
62+
```
63+
64+
7. Create a storage account to upload the image:
65+
66+
```bash
67+
az storage account create --name <StorageAccountName> --resource-group <ResourceGroupName> --location <Location> --sku Standard_LRS
68+
```
69+
70+
8. Create a storage container within the storage account:
71+
72+
```bash
73+
az storage container create --account-name <StorageAccountName> --name <ContainerName>
74+
```
75+
76+
9. Upload the compressed disk image to the storage container:
77+
78+
```bash
79+
az storage blob upload --account-name <StorageAccountName> --container-name <ContainerName> --name image.img.gz --file /path/to/output/image.img.gz
80+
```
81+
82+
10. Create a managed disk from the uploaded VHD:
83+
84+
```bash
85+
az disk create --resource-group <ResourceGroupName> --name <DiskName> --source https://<StorageAccountName>.blob.core.windows.net/<ContainerName>/image.img.gz
86+
```
87+
88+
11. Create an image from the managed disk:
89+
90+
```bash
91+
az image create --resource-group <ResourceGroupName> --name <ImageName> --source <DiskName>
92+
```
93+
94+
12. Verify that the image has been created successfully:
95+
96+
```bash
97+
az image show --resource-group <ResourceGroupName> --name <ImageName>
98+
```
99+
100+
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.
101+
102+
[!INCLUDE [Azure Help Support](../../../includes/azure-help-support.md)]

0 commit comments

Comments
 (0)