Skip to content

Commit 94c64fb

Browse files
Merge pull request #232409 from msaenzbosupport/patch-3
[DOC-a-THON] Updating Ubuntu upload VHD
2 parents c6a2480 + 45dd0f3 commit 94c64fb

File tree

1 file changed

+37
-33
lines changed

1 file changed

+37
-33
lines changed

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

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@ This article assumes that you've already installed an Ubuntu Linux operating sys
3131
* All VHDs on Azure must have a virtual size aligned to 1MB. When converting from a raw disk to VHD you must ensure that the raw disk size is a multiple of 1MB before conversion. See [Linux Installation Notes](create-upload-generic.md#general-linux-installation-notes) for more information.
3232

3333
## Manual steps
34+
3435
> [!NOTE]
3536
> Before attempting to create your own custom Ubuntu image for Azure, please consider using the pre-built and tested images from [https://cloud-images.ubuntu.com/](https://cloud-images.ubuntu.com/) instead.
36-
>
37-
>
37+
>
38+
3839

3940
1. In the center pane of Hyper-V Manager, select the virtual machine.
4041

@@ -44,13 +45,13 @@ This article assumes that you've already installed an Ubuntu Linux operating sys
4445

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

47-
```console
48+
```bash
4849
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
4950
```
5051

5152
Ubuntu 18.04 and Ubuntu 20.04:
5253

53-
```console
54+
```bash
5455
sudo sed -i 's/http:\/\/archive\.ubuntu\.com\/ubuntu\//http:\/\/azure\.archive\.ubuntu\.com\/ubuntu\//g' /etc/apt/sources.list
5556
sudo sed -i 's/http:\/\/[a-z][a-z]\.archive\.ubuntu\.com\/ubuntu\//http:\/\/azure\.archive\.ubuntu\.com\/ubuntu\//g' /etc/apt/sources.list
5657
sudo apt-get update
@@ -60,17 +61,19 @@ This article assumes that you've already installed an Ubuntu Linux operating sys
6061

6162
Ubuntu 18.04 and Ubuntu 20.04:
6263

63-
```console
64+
```bash
6465
sudo apt update
6566
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
66-
(recommended) # sudo apt full-upgrade
67-
68-
sudo reboot
6967
```
68+
Recommended:
69+
```bash
70+
sudo apt full-upgrade
71+
sudo reboot
72+
```
7073

7174
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:
7275

73-
```text
76+
```output
7477
GRUB_CMDLINE_LINUX_DEFAULT="console=tty1 console=ttyS0,115200n8 earlyprintk=ttyS0,115200 rootdelay=300 quiet splash"
7578
```
7679

@@ -80,7 +83,7 @@ This article assumes that you've already installed an Ubuntu Linux operating sys
8083

8184
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.
8285

83-
```console
86+
```bash
8487
sudo apt update
8588
sudo apt install cloud-init gdisk netplan.io walinuxagent && systemctl stop walinuxagent
8689
```
@@ -90,16 +93,16 @@ This article assumes that you've already installed an Ubuntu Linux operating sys
9093

9194
8. Remove cloud-init default configs and leftover `netplan` artifacts that may conflict with cloud-init provisioning on Azure:
9295

93-
```console
94-
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-
rm -f /etc/cloud/ds-identify.cfg
96-
rm -f /etc/netplan/*.yaml
96+
```bash
97+
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
98+
sudo rm -f /etc/cloud/ds-identify.cfg
99+
sudo rm -f /etc/netplan/*.yaml
97100
```
98101

99102
9. Configure cloud-init to provision the system using the Azure datasource:
100103

101104
```bash
102-
cat > /etc/cloud/cloud.cfg.d/90_dpkg.cfg << EOF
105+
sudo cat > /etc/cloud/cloud.cfg.d/90_dpkg.cfg << EOF
103106
datasource_list: [ Azure ]
104107
EOF
105108
@@ -131,13 +134,15 @@ This article assumes that you've already installed an Ubuntu Linux operating sys
131134
132135
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.
133136
134-
```console
135-
sed -i 's/Provisioning.Enabled=y/Provisioning.Enabled=n/g' /etc/waagent.conf
136-
sed -i 's/Provisioning.UseCloudInit=n/Provisioning.UseCloudInit=y/g' /etc/waagent.conf
137-
sed -i 's/ResourceDisk.Format=y/ResourceDisk.Format=n/g' /etc/waagent.conf
138-
sed -i 's/ResourceDisk.EnableSwap=y/ResourceDisk.EnableSwap=n/g' /etc/waagent.conf
137+
```bash
138+
sudo sed -i 's/Provisioning.Enabled=y/Provisioning.Enabled=n/g' /etc/waagent.conf
139+
sudo sed -i 's/Provisioning.UseCloudInit=n/Provisioning.UseCloudInit=y/g' /etc/waagent.conf
140+
sudo sed -i 's/ResourceDisk.Format=y/ResourceDisk.Format=n/g' /etc/waagent.conf
141+
sudo sed -i 's/ResourceDisk.EnableSwap=y/ResourceDisk.EnableSwap=n/g' /etc/waagent.conf
142+
```
139143
140-
cat >> /etc/waagent.conf << EOF
144+
```bash
145+
sudo cat >> /etc/waagent.conf << EOF
141146
# For Azure Linux agent version >= 2.2.45, this is the option to configure,
142147
# enable, or disable the provisioning behavior of the Linux agent.
143148
# Accepted values are auto (default), waagent, cloud-init, or disabled.
@@ -149,7 +154,7 @@ This article assumes that you've already installed an Ubuntu Linux operating sys
149154
150155
11. Clean cloud-init and Azure Linux agent runtime artifacts and logs:
151156
152-
```console
157+
```bash
153158
sudo cloud-init clean --logs --seed
154159
sudo rm -rf /var/lib/cloud/
155160
sudo systemctl stop walinuxagent.service
@@ -165,11 +170,10 @@ This article assumes that you've already installed an Ubuntu Linux operating sys
165170
> [!WARNING]
166171
> Deprovisioning using the command above does not guarantee that the image is cleared of all sensitive information and is suitable for redistribution.
167172
168-
```console
173+
```bash
169174
sudo waagent -force -deprovision+user
170-
rm -f ~/.bash_history
171-
export HISTSIZE=0
172-
logout
175+
sudo rm -f ~/.bash_history
176+
sudo export HISTSIZE=0
173177
```
174178
175179
13. Click **Action -> Shut Down** in Hyper-V Manager.
@@ -181,31 +185,31 @@ This article assumes that you've already installed an Ubuntu Linux operating sys
181185
182186
1. Change directory to the boot EFI directory:
183187
184-
```console
185-
cd /boot/efi/EFI
188+
```bash
189+
sudo cd /boot/efi/EFI
186190
```
187191
188192
2. Copy the ubuntu directory to a new directory named boot:
189193
190-
```console
194+
```bash
191195
sudo cp -r ubuntu/ boot
192196
```
193197
194198
3. Change directory to the newly created boot directory:
195199
196-
```console
197-
cd boot
200+
```bash
201+
sudo cd boot
198202
```
199203
200204
4. Rename the shimx64.efi file:
201205
202-
```console
206+
```bash
203207
sudo mv shimx64.efi bootx64.efi
204208
```
205209
206210
5. Rename the grub.cfg file to bootx64.cfg:
207211
208-
```console
212+
```bash
209213
sudo mv grub.cfg bootx64.cfg
210214
```
211215

0 commit comments

Comments
 (0)