You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
45
46
46
47
Before editing `/etc/apt/sources.list`, it's recommended to make a backup:
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
+
```
61
60
62
61
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:
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:
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.
84
78
85
79
6. Ensure that the SSH server is installed and configured to start at boot time. This is usually the default.
86
80
87
81
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.
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
+
```
137
131
138
132
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.
139
133
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
+
```
157
151
158
152
11. Clean cloud-init and Azure Linux agent runtime artifacts and logs:
159
153
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
+
```
167
161
168
162
12. Run the following commands to deprovision the virtual machine and prepare it for provisioning on Azure:
169
163
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.
172
166
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.
175
169
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
+
```
181
174
182
175
13. Click **Action -> Shut Down** in Hyper-V Manager.
183
176
@@ -186,35 +179,30 @@ This article assumes that you've already installed an Ubuntu Linux operating sys
186
179
15. To bring a Generation 2 VM on Azure, follow these steps:
187
180
188
181
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
+
```
194
186
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
+
```
200
191
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
+
```
206
196
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
+
```
218
206
219
207
## Next steps
220
208
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