Skip to content

Commit 41241fe

Browse files
committed
Refresh bring linux VM from physical lab
1 parent 1f0c0b2 commit 41241fe

File tree

1 file changed

+74
-38
lines changed

1 file changed

+74
-38
lines changed
Lines changed: 74 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,95 @@
11
---
2-
title: How to bring a Linux custom image from your physical lab environment
3-
description: Describes how to bring a Linux custom image from your physical lab environment.
4-
ms.date: 07/27/2021
2+
title: Import a Linux image from a physical lab
3+
description: Learn how to import a Linux custom image from your physical lab environment into Azure Lab Services.
4+
services: lab-services
5+
ms.service: lab-services
6+
author: ntrogh
7+
ms.author: nicktrog
8+
ms.date: 05/22/2023
59
ms.topic: how-to
610
---
711

8-
# Bring a Linux custom image from your physical lab environment
12+
# Bring a Linux custom image from a physical lab environment to Azure Lab Services
913

10-
The steps in this article show how to import a Linux custom image that starts from your physical lab environment. With this approach, you create a VHD from your physical environment and import the VHD into a compute gallery so that it can be used within Azure Lab Services. Before you use this approach for creating a custom image, read [Recommended approaches for creating custom images](approaches-for-custom-image-creation.md) to decide which approach is best for your scenario.
14+
This article describes how to import a Linux-based custom image from a physical lab environment for creating a lab in Azure Lab Services.
1115

12-
Azure endorses a variety of [distributions and versions](../virtual-machines/linux/create-upload-generic.md). The steps to bring a custom Linux image from a VHD varies for each distribution. Every distribution is different because each one has unique prerequisites that must be set up to run on Azure.
16+
Azure supports various [distributions and versions](/azure/virtual-machines/linux/create-upload-generic). The steps to bring a custom Linux image from a VHD varies for each distribution. Every distribution is different because each one has unique prerequisites for running on Azure.
1317

14-
In this article, we'll show the steps to bring a custom Ubuntu 16.04\18.04\20.04 image from a VHD. For information on using a VHD to create custom images for other distributions, see [Generic steps for Linux distributions](../virtual-machines/linux/create-upload-generic.md).
18+
In this article, you bring a custom Ubuntu 18.04\20.04 image from a VHD. For information on using a VHD to create custom images for other distributions, see [Generic steps for Linux distributions](/azure/virtual-machines/linux/create-upload-generic).
19+
20+
The import process consists of the following steps:
21+
22+
1. Create a virtual hard drive (VHD) from your physical environment
23+
1. Import the VHD into an Azure compute gallery
24+
1. [Attach the compute gallery to your lab plan](/azure/lab-services/how-to-attach-detach-shared-image-gallery)
25+
1. Create a lab based by using the image in the compute gallery
26+
27+
Before you import an image from a physical lab, learn more about [recommended approaches for creating custom images](approaches-for-custom-image-creation.md).
1528

1629
## Prerequisites
1730

18-
You'll need permission to create an [Azure managed disk](../virtual-machines/managed-disks-overview.md) in your school's Azure subscription to complete the steps in this article.
31+
- Your Azure account has permission to create an [Azure managed disk](/azure/virtual-machines/managed-disks-overview). Learn about the [Azure RBAC roles you need to create a managed disk](/azure/virtual-machines/windows/disks-upload-vhd-to-managed-disk-powershell#assign-rbac-role).
1932

20-
When you move images from a physical lab environment to Lab Services, restructure each image so that it only includes software needed for a lab's class. For more information, read the [Moving from a Physical Lab to Azure Lab Services](https://techcommunity.microsoft.com/t5/azure-lab-services/moving-from-a-physical-lab-to-azure-lab-services/ba-p/1654931) blog post.
33+
- Restructure each virtual machine image so that it only includes the software that is needed for a lab's class. Learn more about [moving from a Physical Lab to Azure Lab Services](./concept-migrating-physical-labs.md).
2134

2235
## Prepare a custom image by using Hyper-V Manager
2336

24-
The following steps show how to create an Ubuntu 18.04\20.04 image from a Hyper-V virtual machine (VM) by using Windows Hyper-V Manager.
37+
First, create a virtual hard disk (VHD) for the physical environment. The following steps show how to create an Ubuntu 18.04\20.04 image from a Hyper-V virtual machine (VM) by using Windows Hyper-V Manager.
2538

26-
1. Download the official [Linux Ubuntu Server](https://ubuntu.com/server/docs) image to your Windows host machine that you'll use to set up the custom image on a Hyper-V VM.
39+
1. Download the official [Linux Ubuntu Server](https://ubuntu.com/server/docs) image to the Windows host machine that you use to set up the custom image on a Hyper-V VM.
2740

28-
If you are using Ubuntu 18.04 LTS, we recommend using an image that does *not* have the [GNOME](https://www.gnome.org/) or [MATE](https://mate-desktop.org/) graphical desktops installed. GNOME and MATE currently have a networking conflict with the Azure Linux Agent which is needed for the image to work properly in Azure Lab Services. Instead, use an Ubuntu Server image and install a different graphical desktop, such as [XFCE](https://www.xfce.org/). Another option is to install [GNOME\MATE](https://aka.ms/azlabs/scripts/LinuxDesktop-GnomeMate) using a lab's template VM.
41+
If you're using Ubuntu 18.04 LTS, we recommend using an image that does *not* have the [GNOME](https://www.gnome.org/) or [MATE](https://mate-desktop.org/) graphical desktops installed. GNOME and MATE currently have a networking conflict with the Azure Linux Agent, which is needed for the image to work properly in Azure Lab Services. Instead, use an Ubuntu Server image and install a different graphical desktop, such as [XFCE](https://www.xfce.org/). Another option is to install [GNOME\MATE](https://aka.ms/azlabs/scripts/LinuxDesktop-GnomeMate) using a lab's template VM.
42+
43+
Ubuntu also publishes prebuilt [Azure VHDs for download](https://cloud-images.ubuntu.com/). These VHDs are intended for creating custom images from a Linux host machine and hypervisor, such as KVM. These VHDs require that you first set the default user password, which can only be done by using Linux tooling, such as *qemu*. As a result, when you create a custom image by using Windows Hyper-V, you're not able to connect to these VHDs to make image customizations. For more information about the prebuilt Azure VHDs, read [Ubuntu's documentation](https://help.ubuntu.com/community/UEC/Images?_ga=2.114783623.1858181609.1624392241-1226151842.1623682781#QEMU_invocation).
44+
45+
1. Create a Hyper-V virtual machine in your physical lab environment based on your custom image.
2946

30-
Ubuntu also publishes prebuilt [Azure VHDs for download](https://cloud-images.ubuntu.com/). These VHDs are intended for creating custom images from a Linux host machine and hypervisor, such as KVM. These VHDs require that you first set the default user password, which can only be done by using Linux tooling, such as qemu, which isn't available for Windows. As a result, when you create a custom image by using Windows Hyper-V, you won't be able to connect to these VHDs to make image customizations. For more information about the prebuilt Azure VHDs, read [Ubuntu's documentation](https://help.ubuntu.com/community/UEC/Images?_ga=2.114783623.1858181609.1624392241-1226151842.1623682781#QEMU_invocation).
31-
32-
1. Start with a Hyper-V VM in your physical lab environment that was created from your image. For more information, read the article on [how to create a virtual machine in Hyper-V](/windows-server/virtualization/hyper-v/get-started/create-a-virtual-machine-in-hyper-v). Set the settings as shown here:
3347
- The VM must be created as a **Generation 1** VM.
3448
- Use the **Default Switch** network configuration option to allow the VM to connect to the internet.
35-
- In the **Connect Virtual Hard Disk** settings, the disk's **Size** must *not* be greater than 128 GB, as shown in the following image.
49+
- The VM's virtual disk must be a fixed size VHD. The disk size must *not* be greater than 128 GB. When you create the VM, enter the size of the disk as shown in the below image.
3650

3751
:::image type="content" source="./media/upload-custom-image-shared-image-gallery/connect-virtual-hard-disk.png" alt-text="Screenshot that shows the Connect Virtual Hard Disk screen.":::
3852

3953
- In the **Installation Options** settings, select the **.iso** file that you previously downloaded from Ubuntu.
4054

41-
Images with a disk size greater than 128 GB are *not* supported by Lab Services.
55+
Azure Lab Services does *not* support images with disk size greater than 128 GB.
56+
57+
Learn more about [how to create a virtual machine in Hyper-V](/windows-server/virtualization/hyper-v/get-started/create-a-virtual-machine-in-hyper-v).
4258

43-
1. Connect to the Hyper-V VM and prepare it for Azure by following the steps in [Manual steps to create and upload an Ubuntu VHD](../virtual-machines/linux/create-upload-ubuntu.md#manual-steps).
59+
1. Connect to the Hyper-V VM and prepare it for Azure by following the steps in [Manual steps to create and upload an Ubuntu VHD](/azure/virtual-machines/linux/create-upload-ubuntu#manual-steps).
4460

45-
The steps to prepare a Linux image for Azure vary based on the distribution. For more information and specific steps for each distribution, see [distributions and versions](../virtual-machines/linux/create-upload-generic.md).
61+
The steps to prepare a Linux image for Azure vary based on the distribution. For more information and specific steps for each distribution, see [distributions and versions](/azure/virtual-machines/linux/create-upload-generic).
4662

4763
When you follow the preceding steps, there are a few important points to highlight:
48-
- The steps create a [generalized](../virtual-machines/shared-image-galleries.md#generalized-and-specialized-images) image when you run the **deprovision+user** command. But it doesn't guarantee that the image is cleared of all sensitive information or that it's suitable for redistribution.
49-
- The final step is to convert the **VHDX** file to a **VHD** file. Here are equivalent steps that show how to do it with **Hyper-V Manager**:
5064

51-
1. Go to **Hyper-V Manager** > **Action** > **Edit Disk**.
52-
1. Locate the VHDX disk to convert.
53-
1. Next, choose to **Convert** the disk.
54-
1. Select the option to convert it to a **VHD disk format**.
55-
1. For the **Disk Type**, select **Fixed size**.
56-
- If you also choose to expand the disk size at this point, make sure that you do *not* exceed 128 GB.
57-
:::image type="content" source="./media/upload-custom-image-shared-image-gallery/choose-action.png" alt-text="Screenshot that shows the Choose Action screen.":::
65+
- The steps create a [generalized](/azure/virtual-machines/shared-image-galleries#generalized-and-specialized-images) image when you run the **deprovision+user** command. But it doesn't guarantee that the image is cleared of all sensitive information or that it's suitable for redistribution.
66+
67+
1. Convert the default Hyper-V `VHDX` hard disk file format to `VHD`:
68+
69+
1. In Hyper-V Manager, select the virtual machine, and then select **Action** > **Edit Disk**.
70+
71+
1. Locate the VHDX disk to convert.
72+
73+
1. Next, select **Convert** to convert the disk from a VHDX to a VHD.
74+
75+
1. For the **Disk Type**, select **Fixed size**.
76+
77+
If you also choose to expand the disk size at this point, make sure that you do *not* exceed 128 GB.
78+
79+
:::image type="content" source="./media/upload-custom-image-shared-image-gallery/choose-action.png" alt-text="Screenshot that shows the Choose Action screen.":::
5880

59-
To help with resizing the VHD and converting to a VHDX, you can also use the following PowerShell cmdlets:
81+
Alternately, you can resize and convert a VHDX by using PowerShell:
6082

6183
- [Resize-VHD](/powershell/module/hyper-v/resize-vhd)
6284
- [Convert-VHD](/powershell/module/hyper-v/convert-vhd)
6385

6486
## Upload the custom image to a compute gallery
6587

88+
Next, you upload the VHD file from your physical environment to an Azure compute gallery.
89+
6690
1. Upload the VHD to Azure to create a managed disk.
67-
1. You can use either Azure Storage Explorer or AzCopy from the command line, as shown in [Upload a VHD to Azure or copy a managed disk to another region](../virtual-machines/windows/disks-upload-vhd-to-managed-disk-powershell.md).
91+
92+
1. You can use either Azure Storage Explorer or AzCopy from the command line, as shown in [Upload a VHD to Azure or copy a managed disk to another region](/azure/virtual-machines/windows/disks-upload-vhd-to-managed-disk-powershell).
6893

6994
> [!WARNING]
7095
> If your machine goes to sleep or locks, the upload process might get interrupted and fail. Also, make sure that when AzCopy completes, that you revoke SAS access to the disk. Otherwise, when you attempt to create an image from the disk, you'll see the error "Operation 'Create Image' is not supported with disk 'your disk name' in state 'Active Upload'. Error Code: OperationNotAllowed*."
@@ -74,32 +99,43 @@ To help with resizing the VHD and converting to a VHDX, you can also use the fol
7499
You can use the Azure portal's **Size+Performance** tab for the managed disk to change your disk size. As mentioned before, the size must *not* be greater than 128 GB.
75100

76101
1. In a compute gallery, create an image definition and version:
77-
1. [Create an image definition](../virtual-machines/image-version.md):
102+
103+
1. [Create an image definition](/azure/virtual-machines/image-version):
104+
78105
- Choose **Gen 1** for the **VM generation**.
106+
79107
- Choose **Linux** for the **Operating system**.
108+
80109
- Choose **generalized** for the **Operating system state**.
81110

82-
For more information about the values you can specify for an image definition, see [Image definitions](../virtual-machines/shared-image-galleries.md#image-definitions).
111+
For more information about the values you can specify for an image definition, see [Image definitions](/azure/virtual-machines/shared-image-galleries#image-definitions).
83112

84113
You can also choose to use an existing image definition and create a new version for your custom image.
85114

86-
1. [Create an image version](../virtual-machines/image-version.md):
115+
1. [Create an image version](/azure/virtual-machines/image-version):
116+
87117
- The **Version number** property uses the following format: *MajorVersion.MinorVersion.Patch*. When you use Lab Services to create a lab and choose a custom image, the most recent version of the image is automatically used. The most recent version is chosen based on the highest value of MajorVersion, then MinorVersion, and then Patch.
118+
88119
- For the **Source**, select **Disks and/or snapshots** from the dropdown list.
120+
89121
- For the **OS disk** property, choose the disk that you created in previous steps.
90122

91-
For more information about the values you can specify for an image version, see [Image versions](../virtual-machines/shared-image-galleries.md#image-versions).
123+
For more information about the values you can specify for an image version, see [Image versions](/azure/virtual-machines/shared-image-galleries#image-versions).
92124

93125
## Create a lab
94126

95-
[Create the lab](tutorial-setup-lab.md) in Lab Services and select the custom image from the compute gallery.
127+
Now that the custom image is available in an Azure compute gallery, you can create a lab by using the image.
128+
129+
1. [Attach the compute gallery to your lab plan](./how-to-attach-detach-shared-image-gallery.md)
130+
131+
1. [Create the lab](tutorial-setup-lab.md) and select the custom image from the compute gallery.
96132

97-
If you expanded the disk *after* the OS was installed on the original Hyper-V VM, you might also need to extend the partition in Linux's filesystem to use the unallocated disk space. Log in to the lab's template VM and follow steps similar to what is shown in [Expand a disk partition and filesystem](../virtual-machines/linux/expand-disks.md#expand-a-disk-partition-and-filesystem).
133+
If you expanded the disk *after* the OS was installed on the original Hyper-V VM, you might also need to extend the partition in Linux's filesystem to use the unallocated disk space. Sign in to the lab's template VM and follow steps similar to what is shown in [Expand a disk partition and filesystem](/azure/virtual-machines/linux/expand-disks#expand-a-disk-partition-and-filesystem).
98134

99135
The OS disk typically exists on the **/dev/sad2** partition. To view the current size of the OS disk's partition, use the command **df -h**.
100136

101137
## Next steps
102138

103-
- [Azure Compute Gallery overview](../virtual-machines/shared-image-galleries.md)
139+
- [Azure Compute Gallery overview](/azure/virtual-machines/shared-image-galleries)
104140
- [Attach or detach a compute gallery](how-to-attach-detach-shared-image-gallery.md)
105-
- [Use a compute gallery](how-to-use-shared-image-gallery.md)
141+
- [Use a compute gallery in Azure Lab Services](how-to-use-shared-image-gallery.md)

0 commit comments

Comments
 (0)