Skip to content

Commit 31324d1

Browse files
authored
Merge pull request #253067 from esvmicrosoft/importubuntu
Adding support for 22.04
2 parents 464b5dd + d308f05 commit 31324d1

File tree

1 file changed

+115
-127
lines changed

1 file changed

+115
-127
lines changed

articles/virtual-machines/linux/create-upload-ubuntu.md

Lines changed: 115 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Ubuntu now publishes official Azure VHDs for download at [https://cloud-images.u
1818

1919
* Ubuntu 18.04/Bionic: [bionic-server-cloudimg-amd64-azure.vhd.zip](https://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-amd64-azure.vhd.tar.gz)
2020
* Ubuntu 20.04/Focal: [focal-server-cloudimg-amd64-azure.vhd.zip](https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64-azure.vhd.tar.gz)
21+
* Ubuntu 22.04/Jammy: [jammy-server-cloudimg-amd64-azure.vhd.zip](https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64-azure.vhd.tar.gz)
2122

2223
## Prerequisites
2324
This article assumes that you've already installed an Ubuntu Linux operating system to a virtual hard disk. Multiple tools exist to create .vhd files, for example a virtualization solution such as Hyper-V. For instructions, see [Install the Hyper-V Role and Configure a Virtual Machine](/previous-versions/windows/it-pro/windows-server-2012-R2-and-2012/hh846766(v=ws.11)).
@@ -45,139 +46,131 @@ This article assumes that you've already installed an Ubuntu Linux operating sys
4546

4647
Before editing `/etc/apt/sources.list`, it's recommended to make a backup:
4748

48-
```bash
49-
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
50-
```
49+
```bash
50+
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
51+
```
5152

52-
Ubuntu 18.04 and Ubuntu 20.04:
53-
54-
```bash
55-
sudo sed -i 's/http:\/\/archive\.ubuntu\.com\/ubuntu\//http:\/\/azure\.archive\.ubuntu\.com\/ubuntu\//g' /etc/apt/sources.list
56-
sudo sed -i 's/http:\/\/[a-z][a-z]\.archive\.ubuntu\.com\/ubuntu\//http:\/\/azure\.archive\.ubuntu\.com\/ubuntu\//g' /etc/apt/sources.list
57-
sudo sed -i 's/http:\/\/security\.ubuntu\.com\/ubuntu\//http:\/\/azure\.archive\.ubuntu\.com\/ubuntu\//g' /etc/apt/sources.list
58-
sudo sed -i 's/http:\/\/[a-z][a-z]\.security\.ubuntu\.com\/ubuntu\//http:\/\/azure\.archive\.ubuntu\.com\/ubuntu\//g' /etc/apt/sources.list
59-
sudo apt-get update
60-
```
53+
```bash
54+
sudo sed -i 's#http://archive\.ubuntu\.com/ubuntu#http://azure\.archive\.ubuntu\.com/ubuntu#g' /etc/apt/sources.list
55+
sudo sed -i 's#http://[a-z][a-z]\.archive\.ubuntu\.com/ubuntu#http://azure\.archive\.ubuntu\.com/ubuntu#g' /etc/apt/sources.list
56+
sudo sed -i 's#http://security\.ubuntu\.com/ubuntu#http://azure\.archive\.ubuntu\.com/ubuntu#g' /etc/apt/sources.list
57+
sudo sed -i 's#http://[a-z][a-z]\.security\.ubuntu\.com/ubuntu#http://azure\.archive\.ubuntu\.com/ubuntu#g' /etc/apt/sources.list
58+
sudo apt-get update
59+
```
6160

6261
4. The Ubuntu Azure images are now using the [Azure-tailored kernel](https://ubuntu.com/blog/microsoft-and-canonical-increase-velocity-with-azure-tailored-kernel). Update the operating system to the latest Azure-tailored kernel and install Azure Linux tools (including Hyper-V dependencies) by running the following commands:
6362

64-
- Ubuntu 18.04 and Ubuntu 20.04:
65-
66-
```bash
67-
sudo apt update
68-
sudo apt install linux-azure linux-image-azure linux-headers-azure linux-tools-common linux-cloud-tools-common linux-tools-azure linux-cloud-tools-azure
69-
```
70-
- Recommended:
7163

72-
```bash
73-
sudo apt full-upgrade
74-
sudo reboot
75-
```
64+
```bash
65+
sudo apt update
66+
sudo apt install linux-azure linux-image-azure linux-headers-azure linux-tools-common linux-cloud-tools-common linux-tools-azure linux-cloud-tools-azure
67+
sudo apt full-upgrade
68+
sudo reboot
69+
```
7670

7771
5. Modify the kernel boot line for Grub to include additional kernel parameters for Azure. To do this open `/etc/default/grub` in a text editor, find the variable called `GRUB_CMDLINE_LINUX_DEFAULT` (or add it if needed) and edit it to include the following parameters:
7872

79-
```config
80-
GRUB_CMDLINE_LINUX_DEFAULT="console=tty1 console=ttyS0,115200n8 earlyprintk=ttyS0,115200 rootdelay=300 quiet splash"
81-
```
73+
```config
74+
GRUB_CMDLINE_LINUX_DEFAULT="console=tty1 console=ttyS0,115200n8 earlyprintk=ttyS0,115200 rootdelay=300 quiet splash"
75+
```
8276

83-
Save and close this file, and then run `sudo update-grub`. This will ensure all console messages are sent to the first serial port, which can assist Azure technical support with debugging issues.
77+
Save and close this file, and then run `sudo update-grub`. This will ensure all console messages are sent to the first serial port, which can assist Azure technical support with debugging issues.
8478

8579
6. Ensure that the SSH server is installed and configured to start at boot time. This is usually the default.
8680

8781
7. Install cloud-init (the provisioning agent) and the Azure Linux Agent (the guest extensions handler). Cloud-init uses `netplan` to configure the system network configuration (during provisioning and each subsequent boot) and `gdisk` to partition resource disks.
8882

89-
```bash
90-
sudo apt update
91-
sudo apt install cloud-init gdisk netplan.io walinuxagent && systemctl stop walinuxagent
92-
```
83+
```bash
84+
sudo apt update
85+
sudo apt install cloud-init gdisk netplan.io walinuxagent && systemctl stop walinuxagent
86+
```
9387

94-
> [!Note]
95-
> The `walinuxagent` package may remove the `NetworkManager` and `NetworkManager-gnome` packages, if they are installed.
88+
> [!Note]
89+
> The `walinuxagent` package may remove the `NetworkManager` and `NetworkManager-gnome` packages, if they are installed.
9690
9791
8. Remove cloud-init default configs and leftover `netplan` artifacts that may conflict with cloud-init provisioning on Azure:
9892

99-
```bash
100-
sudo rm -f /etc/cloud/cloud.cfg.d/50-curtin-networking.cfg /etc/cloud/cloud.cfg.d/curtin-preserve-sources.cfg /etc/cloud/cloud.cfg.d/99-installer.cfg /etc/cloud/cloud.cfg.d/subiquity-disable-cloudinit-networking.cfg
101-
sudo rm -f /etc/cloud/ds-identify.cfg
102-
sudo rm -f /etc/netplan/*.yaml
103-
```
93+
```bash
94+
sudo rm -f /etc/cloud/cloud.cfg.d/50-curtin-networking.cfg /etc/cloud/cloud.cfg.d/curtin-preserve-sources.cfg /etc/cloud/cloud.cfg.d/99-installer.cfg /etc/cloud/cloud.cfg.d/subiquity-disable-cloudinit-networking.cfg
95+
sudo rm -f /etc/cloud/ds-identify.cfg
96+
sudo rm -f /etc/netplan/*.yaml
97+
```
10498

10599
9. Configure cloud-init to provision the system using the Azure datasource:
106100

107-
```bash
108-
sudo cat > /etc/cloud/cloud.cfg.d/90_dpkg.cfg << EOF
109-
datasource_list: [ Azure ]
110-
EOF
111-
112-
cat > /etc/cloud/cloud.cfg.d/90-azure.cfg << EOF
113-
system_info:
114-
package_mirrors:
115-
- arches: [i386, amd64]
116-
failsafe:
117-
primary: http://archive.ubuntu.com/ubuntu
118-
security: http://security.ubuntu.com/ubuntu
119-
search:
120-
primary:
121-
- http://azure.archive.ubuntu.com/ubuntu/
122-
security: []
123-
- arches: [armhf, armel, default]
124-
failsafe:
125-
primary: http://ports.ubuntu.com/ubuntu-ports
126-
security: http://ports.ubuntu.com/ubuntu-ports
127-
EOF
128-
129-
cat > /etc/cloud/cloud.cfg.d/10-azure-kvp.cfg << EOF
130-
reporting:
131-
logging:
132-
type: log
133-
telemetry:
134-
type: hyperv
135-
EOF
136-
```
101+
```bash
102+
cat <<EOF | sudo tee /etc/cloud/cloud.cfg.d/90_dpkg.cfg
103+
datasource_list: [ Azure ]
104+
EOF
105+
106+
cat <<EOF | sudo tee /etc/cloud/cloud.cfg.d/90-azure.cfg
107+
system_info:
108+
package_mirrors:
109+
- arches: [i386, amd64]
110+
failsafe:
111+
primary: http://archive.ubuntu.com/ubuntu
112+
security: http://security.ubuntu.com/ubuntu
113+
search:
114+
primary:
115+
- http://azure.archive.ubuntu.com/ubuntu/
116+
security: []
117+
- arches: [armhf, armel, default]
118+
failsafe:
119+
primary: http://ports.ubuntu.com/ubuntu-ports
120+
security: http://ports.ubuntu.com/ubuntu-ports
121+
EOF
122+
123+
cat <<EOF | sudo tee /etc/cloud/cloud.cfg.d/10-azure-kvp.cfg
124+
reporting:
125+
logging:
126+
type: log
127+
telemetry:
128+
type: hyperv
129+
EOF
130+
```
137131

138132
10. Configure the Azure Linux agent to rely on cloud-init to perform provisioning. Have a look at the [WALinuxAgent project](https://github.com/Azure/WALinuxAgent) for more information on these options.
139133

140-
```bash
141-
sudo sed -i 's/Provisioning.Enabled=y/Provisioning.Enabled=n/g' /etc/waagent.conf
142-
sudo sed -i 's/Provisioning.UseCloudInit=n/Provisioning.UseCloudInit=y/g' /etc/waagent.conf
143-
sudo sed -i 's/ResourceDisk.Format=y/ResourceDisk.Format=n/g' /etc/waagent.conf
144-
sudo sed -i 's/ResourceDisk.EnableSwap=y/ResourceDisk.EnableSwap=n/g' /etc/waagent.conf
145-
```
146-
147-
```bash
148-
sudo cat >> /etc/waagent.conf << EOF
149-
# For Azure Linux agent version >= 2.2.45, this is the option to configure,
150-
# enable, or disable the provisioning behavior of the Linux agent.
151-
# Accepted values are auto (default), waagent, cloud-init, or disabled.
152-
# A value of auto means that the agent will rely on cloud-init to handle
153-
# provisioning if it is installed and enabled, which in this case it will.
154-
Provisioning.Agent=auto
155-
EOF
156-
```
134+
```bash
135+
sudo sed -i 's/Provisioning.Enabled=y/Provisioning.Enabled=n/g' /etc/waagent.conf
136+
sudo sed -i 's/Provisioning.UseCloudInit=n/Provisioning.UseCloudInit=y/g' /etc/waagent.conf
137+
sudo sed -i 's/ResourceDisk.Format=y/ResourceDisk.Format=n/g' /etc/waagent.conf
138+
sudo sed -i 's/ResourceDisk.EnableSwap=y/ResourceDisk.EnableSwap=n/g' /etc/waagent.conf
139+
```
140+
141+
```bash
142+
cat <<EOF | sudo tee -a /etc/waagent.conf
143+
# For Azure Linux agent version >= 2.2.45, this is the option to configure,
144+
# enable, or disable the provisioning behavior of the Linux agent.
145+
# Accepted values are auto (default), waagent, cloud-init, or disabled.
146+
# A value of auto means that the agent will rely on cloud-init to handle
147+
# provisioning if it is installed and enabled, which in this case it will.
148+
Provisioning.Agent=auto
149+
EOF
150+
```
157151

158152
11. Clean cloud-init and Azure Linux agent runtime artifacts and logs:
159153

160-
```bash
161-
sudo cloud-init clean --logs --seed
162-
sudo rm -rf /var/lib/cloud/
163-
sudo systemctl stop walinuxagent.service
164-
sudo rm -rf /var/lib/waagent/
165-
sudo rm -f /var/log/waagent.log
166-
```
154+
```bash
155+
sudo cloud-init clean --logs --seed
156+
sudo rm -rf /var/lib/cloud/
157+
sudo systemctl stop walinuxagent.service
158+
sudo rm -rf /var/lib/waagent/
159+
sudo rm -f /var/log/waagent.log
160+
```
167161

168162
12. Run the following commands to deprovision the virtual machine and prepare it for provisioning on Azure:
169163

170-
> [!NOTE]
171-
> The `sudo waagent -force -deprovision+user` command generalizes the image by attempting to clean the system and make it suitable for re-provisioning. The `+user` option deletes the last provisioned user account and associated data.
164+
> [!NOTE]
165+
> The `sudo waagent -force -deprovision+user` command generalizes the image by attempting to clean the system and make it suitable for re-provisioning. The `+user` option deletes the last provisioned user account and associated data.
172166
173-
> [!WARNING]
174-
> Deprovisioning using the command above doesn't guarantee the image is cleared of all sensitive information and is suitable for redistribution.
167+
> [!WARNING]
168+
> Deprovisioning using the command above doesn't guarantee the image is cleared of all sensitive information and is suitable for redistribution.
175169
176-
```bash
177-
sudo waagent -force -deprovision+user
178-
sudo rm -f ~/.bash_history
179-
sudo export HISTSIZE=0
180-
```
170+
```bash
171+
sudo waagent -force -deprovision+user
172+
sudo rm -f ~/.bash_history
173+
```
181174

182175
13. Click **Action -> Shut Down** in Hyper-V Manager.
183176

@@ -186,35 +179,30 @@ This article assumes that you've already installed an Ubuntu Linux operating sys
186179
15. To bring a Generation 2 VM on Azure, follow these steps:
187180

188181

189-
1. Change directory to the boot EFI directory:
190-
191-
```bash
192-
cd /boot/efi/EFI
193-
```
182+
16. Change directory to the boot EFI directory:
183+
```bash
184+
cd /boot/efi/EFI
185+
```
194186

195-
2. Copy the ubuntu directory to a new directory named boot:
196-
197-
```bash
198-
sudo cp -r ubuntu/ boot
199-
```
187+
17. Copy the ubuntu directory to a new directory named boot:
188+
```bash
189+
sudo cp -r ubuntu/ boot
190+
```
200191

201-
3. Change directory to the newly created boot directory:
202-
203-
```bash
204-
cd boot
205-
```
192+
18. Change directory to the newly created boot directory:
193+
```bash
194+
cd boot
195+
```
206196

207-
4. Rename the shimx64.efi file:
208-
209-
```bash
210-
sudo mv shimx64.efi bootx64.efi
211-
```
212-
213-
5. Rename the grub.cfg file to bootx64.cfg:
214-
215-
```bash
216-
sudo mv grub.cfg bootx64.cfg
217-
```
197+
19. Rename the shimx64.efi file:
198+
```bash
199+
sudo mv shimx64.efi bootx64.efi
200+
```
201+
202+
20. Rename the grub.cfg file to bootx64.cfg:
203+
```bash
204+
sudo mv grub.cfg bootx64.cfg
205+
```
218206

219207
## Next steps
220208
You're now ready to use your Ubuntu Linux virtual hard disk to create new virtual machines in Azure. If this is the first time that you're uploading the .vhd file to Azure, see [Create a Linux VM from a custom disk](upload-vhd.md#option-1-upload-a-vhd).

0 commit comments

Comments
 (0)