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
In some cases, you may want to use customized SUSE or openSUSE Leap Linux VMs in your Azure environment and be able to build these types of VMs through automation. This article demonstrates how to create and upload a custom Azure virtual hard disk (VHD) that contains a SUSE Linux operating system.
20
+
21
+
## Prerequisites
22
+
19
23
This article assumes that you have already installed a SUSE or openSUSE Leap 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)).
20
24
21
25
## SLES / openSUSE Leap installation notes
22
-
* Please see also [General Linux Installation Notes](create-upload-generic.md#general-linux-installation-notes) for more tips on preparing Linux for Azure.
23
-
* The VHDX format is not supported in Azure, only **fixed VHD**. You can convert the disk to VHD format using Hyper-V Manager or the convert-vhd cmdlet.
24
-
* When installing the Linux system it is recommended that you use standard partitions rather than LVM (often the default for many installations). This will avoid LVM name conflicts with cloned VMs, particularly if an OS disk ever needs to be attached to another VM for troubleshooting. [LVM](/previous-versions/azure/virtual-machines/linux/configure-lvm) or [RAID](/previous-versions/azure/virtual-machines/linux/configure-raid) may be used on data disks if preferred.
25
-
* Do not configure a swap partition on the OS disk. The Linux agent can be configured to create a swap file on the temporary resource disk. More information about this can be found in the steps below.
26
-
* 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.
26
+
27
+
* For more tips on preparing Linux images for Azure, see [General Linux Installation Notes](create-upload-generic.md#general-linux-installation-notes)
28
+
* The VHDX format isn't supported in Azure, only **fixed VHD**. You can convert the disk to VHD format using Hyper-V Manager or the convert-vhd cmdlet.
29
+
* When installing the Linux operating system, use standard partitions rather than logical volume manager (LVM) managed partitions, which is often the default for many installations. Using standard partitions will avoid LVM name conflicts with cloned VMs, particularly if an OS disk ever needs to be attached to another VM for troubleshooting. [LVM](/previous-versions/azure/virtual-machines/linux/configure-lvm) or [RAID](/previous-versions/azure/virtual-machines/linux/configure-raid) may be used on data disks if preferred.
30
+
* Don't configure a swap partition on the OS disk. The Linux agent can be configured to create a swap file on the temporary resource disk. More information about configuring swap space can be found in the steps below.
31
+
* All VHDs on Azure must have a virtual size aligned to 1 MB. When converting from a raw disk to VHD, you must ensure that the raw disk size is a multiple of 1 MB before conversion. See [Linux Installation Notes](create-upload-generic.md#general-linux-installation-notes) for more information.
27
32
28
33
## Use SUSE Studio
29
-
[SUSE Studio](https://studioexpress.opensuse.org/) can easily create and manage your SLES and openSUSE Leap images for Azure and Hyper-V. This is the recommended approach for customizing your own SLES and openSUSE Leap images.
34
+
35
+
[SUSE Studio](https://studioexpress.opensuse.org/) can easily create and manage your SLES and openSUSE Leap images for Azure and Hyper-V. SUSE Studio is the recommended approach for customizing your own SLES and openSUSE Leap images.
30
36
31
37
As an alternative to building your own VHD, SUSE also publishes BYOS (Bring Your Own Subscription) images for SLES at [VM Depot](https://www.microsoft.com/research/wp-content/uploads/2016/04/using-and-contributing-vms-to-vm-depot.pdf).
32
38
33
39
## Prepare SUSE Linux Enterprise Server for Azure
40
+
34
41
1. In the center pane of Hyper-V Manager, select the virtual machine.
35
42
2. Click **Connect** to open the window for the virtual machine.
36
43
3. Register your SUSE Linux Enterprise system to allow it to download updates and install packages.
8. Edit /etc/default/grub file to ensure console logs are sent to serial port and then update the main configuration file with grub2-mkconfig -o /boot/grub2/grub.cfg
85
+
8. Edit the "/etc/default/grub" file to ensure console logs are sent to the serial port by adding the following line:
75
86
76
87
```config-grub
77
88
console=ttyS0 earlyprintk=ttyS0
78
89
```
79
-
This will ensure all console messages are sent to the first serial port, which can assist Azure support with debugging issues.
80
-
81
-
9. Ensure /etc/fstab file reference the disk using its UUID (by-uuid)
82
-
90
+
91
+
Next, apply this change by running the following command:
92
+
93
+
```console
94
+
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
95
+
```
96
+
97
+
This configuration will ensure all console messages are sent to the first serial port, which can assist Azure support with debugging issues.
98
+
99
+
9. Ensure the "/etc/fstab" file references the disk using its UUID (by-uuid)
100
+
83
101
10. Modify udev rules to avoid generating static rules for the Ethernet interface(s). These rules can cause problems when cloning a virtual machine in Microsoft Azure or Hyper-V:
11. It is recommended to edit the file "/etc/sysconfig/network/dhcp" and change the `DHCLIENT_SET_HOSTNAME` parameter to the following:
109
+
110
+
11. It's recommended to edit the "/etc/sysconfig/network/dhcp" file and change the `DHCLIENT_SET_HOSTNAME` parameter to the following:
91
111
92
112
```config
93
113
DHCLIENT_SET_HOSTNAME="no"
94
114
```
95
115
96
-
12. In "/etc/sudoers", comment out or remove the following lines if they exist:
116
+
12. In the "/etc/sudoers" file, comment out or remove the following lines if they exist:
97
117
98
118
```text
99
119
Defaults targetpw # ask for the password of the target user i.e. root
100
-
ALL ALL=(ALL) ALL # WARNING! Only use this together with 'Defaults targetpw'!
120
+
ALL ALL=(ALL) ALL # WARNING! Only use this setting together with 'Defaults targetpw'!
101
121
```
102
122
103
-
13. Ensure that the SSH server is installed and configured to start at boot time. This is usually the default.
123
+
13. Ensure that the SSH server is installed and configured to start at boot time.
104
124
105
125
14. Swap configuration
106
-
107
-
Do not create swap space on the operating system disk.
108
126
109
-
Previously, the Azure Linux Agent was used automatically configure swap space by using the local resource disk that is attached to the virtual machine after the virtual machine is provisioned on Azure. However this is now handled by cloud-init, you **must not** use the Linux Agent to format the resource disk create the swap file, modify the following parameters in `/etc/waagent.conf` appropriately:
127
+
Don't create swap space on the operating system disk.
128
+
129
+
Previously, the Azure Linux Agent was used to automatically configure swap space by using the local resource disk that is attached to the virtual machine after the virtual machine is provisioned on Azure. However this step is now handled by cloud-init, you **must not** use the Linux Agent to format the resource disk or create the swap file. Use these commands to modify `/etc/waagent.conf` appropriately:
110
130
111
131
```console
112
-
# sed -i 's/ResourceDisk.Format=y/ResourceDisk.Format=n/g' /etc/waagent.conf
113
-
# sed -i 's/ResourceDisk.EnableSwap=y/ResourceDisk.EnableSwap=n/g' /etc/waagent.conf
132
+
sudo -i
133
+
sed -i 's/ResourceDisk.Format=y/ResourceDisk.Format=n/g' /etc/waagent.conf
134
+
sed -i 's/ResourceDisk.EnableSwap=y/ResourceDisk.EnableSwap=n/g' /etc/waagent.conf
135
+
exit
114
136
```
115
137
116
-
If you want mount, format and create swap you can either:
117
-
* Pass this in as a cloud-init config every time you create a VM.
118
-
* Use a cloud-init directive baked into the image that will do this every time the VM is created:
138
+
For more information on the waagent.conf configuration options, see the [Linux agent configuration](/azure/virtual-machines/extensions/agent-linux#configuration) documentation.
139
+
140
+
If you want to mount, format and create a swap partition you can either:
141
+
* Pass this configuration in as a cloud-init config every time you create a VM.
142
+
* Use a cloud-init directive baked into the image that configures swap space every time the VM is created:
15. Run the following commands to deprovision the virtual machine and prepare it for provisioning on Azure:
142
168
143
169
```console
144
-
# sudo rm -rf /var/lib/waagent/
145
-
# sudo rm -f /var/log/waagent.log
170
+
rm -f ~/.bash_history # Remove current user history
146
171
147
-
# waagent -force -deprovision+user
148
-
# rm -f ~/.bash_history
149
-
172
+
sudo -i
173
+
rm -rf /var/lib/waagent/
174
+
rm -f /var/log/waagent.log
150
175
151
-
# export HISTSIZE=0
176
+
waagent -force -deprovision+user
177
+
rm -f ~/.bash_history # Remove root user history
178
+
179
+
export HISTSIZE=0
152
180
153
-
# logout
181
+
logout
154
182
```
155
183
16. Click **Action -> Shut Down** in Hyper-V Manager. Your Linux VHD is now ready to be [**uploaded to Azure**](./upload-vhd.md#option-1-upload-a-vhd).
156
184
157
185
---
186
+
158
187
## Prepare openSUSE 15.2+
188
+
159
189
1. In the center pane of Hyper-V Manager, select the virtual machine.
160
190
2. Click **Connect** to open the window for the virtual machine.
161
-
3. On the shell, run the command '`zypper lr`'. If this command returns output similar to the following, then the repositories are configured as expected--no adjustments are necessary (note that version numbers may vary):
191
+
3. In a terminal, run the command '`zypper lr`'. If this command returns output similar to the following, then the repositories are configured as expected and no adjustments are necessary (note that version numbers may vary):
@@ -169,33 +199,33 @@ As an alternative to building your own VHD, SUSE also publishes BYOS (Bring Your
169
199
If the command returns "No repositories defined..." then use the following commands to add these repos:
170
200
171
201
```console
172
-
# sudo zypper ar -f http://download.opensuse.org/repositories/Cloud:Tools/openSUSE_15.2 Cloud:Tools_15.2
173
-
# sudo zypper ar -f https://download.opensuse.org/distribution/15.2/repo/oss openSUSE_15.2_OSS
174
-
# sudo zypper ar -f http://download.opensuse.org/update/15.2 openSUSE_15.2_Updates
202
+
sudo zypper ar -f http://download.opensuse.org/repositories/Cloud:Tools/openSUSE_15.2 Cloud:Tools_15.2
203
+
sudo zypper ar -f https://download.opensuse.org/distribution/15.2/repo/oss openSUSE_15.2_OSS
204
+
sudo zypper ar -f http://download.opensuse.org/update/15.2 openSUSE_15.2_Updates
175
205
```
176
206
177
-
You can then verify the repositories have been added by running the command '`zypper lr`' again. In case one of the relevant update repositories is not enabled, enable it with following command:
207
+
You can then verify the repositories have been added by running the command '`zypper lr`' again. If one of the relevant update repositories isn't enabled, enable it with following command:
178
208
179
209
```console
180
-
# sudo zypper mr -e [NUMBER OF REPOSITORY]
210
+
sudo zypper mr -e [NUMBER OF REPOSITORY]
181
211
```
182
212
183
213
4. Update the kernel to the latest available version:
184
214
185
215
```console
186
-
# sudo zypper up kernel-default
216
+
sudo zypper up kernel-default
187
217
```
188
218
189
-
Or to update the system with all the latest patches:
219
+
Or to update the operating system with all the latest patches:
190
220
191
221
```console
192
-
# sudo zypper update
222
+
sudo zypper update
193
223
```
194
224
195
225
5. Install the Azure Linux Agent.
196
226
197
227
```console
198
-
# sudo zypper install WALinuxAgent
228
+
sudo zypper install WALinuxAgent
199
229
```
200
230
201
231
6. Modify the kernel boot line in your grub configuration to include additional kernel parameters for Azure. To do this, open "/boot/grub/menu.lst" in a text editor and ensure that the default kernel includes the following parameters:
@@ -204,53 +234,63 @@ As an alternative to building your own VHD, SUSE also publishes BYOS (Bring Your
204
234
console=ttyS0 earlyprintk=ttyS0
205
235
```
206
236
207
-
This will ensure all console messages are sent to the first serial port, which can assist Azure support with debugging issues. In addition, remove the following parameters from the kernel boot line if they exist:
237
+
This option will ensure all console messages are sent to the first serial port, which can assist Azure support with debugging issues. In addition, remove the following parameters from the kernel boot line if they exist:
208
238
209
239
```config-grub
210
240
libata.atapi_enabled=0 reserve=0x1f0,0x8
211
241
```
212
242
213
-
7. It is recommended to edit the file "/etc/sysconfig/network/dhcp" and change the `DHCLIENT_SET_HOSTNAME` parameter to the following:
243
+
7. It's recommended to edit the "/etc/sysconfig/network/dhcp" file and change the `DHCLIENT_SET_HOSTNAME` parameter to the following setting:
214
244
215
245
```config
216
246
DHCLIENT_SET_HOSTNAME="no"
217
247
```
218
248
219
-
8. **Important:** In "/etc/sudoers", comment out or remove the following lines if they exist:
249
+
8. **Important:** In the "/etc/sudoers" file, comment out or remove the following lines if they exist:
220
250
221
251
```text
222
252
Defaults targetpw # ask for the password of the target user i.e. root
223
253
ALL ALL=(ALL) ALL # WARNING! Only use this together with 'Defaults targetpw'!
224
254
```
225
255
226
-
9. Ensure that the SSH server is installed and configured to start at boot time. This is usually the default.
227
-
10. Do not create swap space on the OS disk.
256
+
9. Ensure that the SSH server is installed and configured to start at boot time.
257
+
10. Don't create swap space on the OS disk.
228
258
229
-
The Azure Linux Agent can automatically configure swap space using the local resource disk that is attached to the VM after provisioning on Azure. Note that the local resource disk is a *temporary* disk, and might be emptied when the VM is deprovisioned. After installing the Azure Linux Agent (see previous step), modify the following parameters in /etc/waagent.conf appropriately:
259
+
The Azure Linux Agent can automatically configure swap space using the local resource disk that is attached to the VM after provisioning on Azure. Note that the local resource disk is a *temporary* disk, and might be emptied when the VM is deprovisioned. After installing the Azure Linux Agent (see previous step), modify the following parameters in the "/etc/waagent.conf" as follows:
230
260
231
261
```config-conf
232
262
ResourceDisk.Format=y
233
263
ResourceDisk.Filesystem=ext4
234
264
ResourceDisk.MountPoint=/mnt/resource
235
265
ResourceDisk.EnableSwap=y
236
-
ResourceDisk.SwapSizeMB=2048 ## NOTE: set this to whatever you need it to be.
266
+
ResourceDisk.SwapSizeMB=2048 ## NOTE: set the size to whatever you need it to be.
237
267
```
238
268
239
-
11. Run the following commands to deprovision the virtual machine and prepare it for provisioning on Azure:
269
+
11. Ensure the Azure Linux Agent runs at startup:
240
270
241
271
```console
242
-
# sudo waagent -force -deprovision
243
-
# export HISTSIZE=0
244
-
# logout
272
+
sudo systemctl enable waagent.service
245
273
```
246
274
247
-
12. Ensure the Azure Linux Agent runs at startup:
275
+
12. Run the following commands to deprovision the virtual machine and prepare it for provisioning on Azure:
248
276
249
277
```console
250
-
# sudo systemctl enable waagent.service
278
+
rm -f ~/.bash_history # Remove current user history
279
+
280
+
sudo -i
281
+
rm -rf /var/lib/waagent/
282
+
rm -f /var/log/waagent.log
283
+
284
+
waagent -force -deprovision+user
285
+
rm -f ~/.bash_history # Remove root user history
286
+
287
+
export HISTSIZE=0
288
+
289
+
logout
251
290
```
252
291
253
292
13. Click **Action -> Shut Down** in Hyper-V Manager. Your Linux VHD is now ready to be [**uploaded to Azure**](./upload-vhd.md#option-1-upload-a-vhd).
254
293
255
294
## Next steps
295
+
256
296
You're now ready to use your SUSE 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