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.
26
+
27
+
* Please see [General Linux Installation Notes](create-upload-generic.md#general-linux-installation-notes) for more tips on preparing Linux images for Azure.
23
28
* 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.
29
+
* When installing the Linux operating system it is recommended that you use standard partitions rather than logical volume manager (LVM) managed partitions, which is 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
30
* 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
31
* 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.
27
32
28
33
## Use SUSE Studio
34
+
29
35
[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.
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
83
+
8. Edit the "/etc/default/grub" file to ensure console logs are sent to the serial port by adding the following line:
75
84
76
85
```config-grub
77
86
console=ttyS0 earlyprintk=ttyS0
78
87
```
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
-
88
+
89
+
Next, apply this change by running the following command:
90
+
91
+
```console
92
+
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
93
+
```
94
+
95
+
This will ensure all console messages are sent to the first serial port, which can assist Azure support with debugging issues.
96
+
97
+
9. Ensure the "/etc/fstab" file references the disk using its UUID (by-uuid)
98
+
83
99
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:
107
+
108
+
11. It is recommended to edit the "/etc/sysconfig/network/dhcp" file and change the `DHCLIENT_SET_HOSTNAME` parameter to the following:
91
109
92
110
```config
93
111
DHCLIENT_SET_HOSTNAME="no"
94
112
```
95
113
96
-
12. In "/etc/sudoers", comment out or remove the following lines if they exist:
114
+
12. In the "/etc/sudoers" file, comment out or remove the following lines if they exist:
97
115
98
116
```text
99
117
Defaults targetpw # ask for the password of the target user i.e. root
@@ -103,17 +121,19 @@ As an alternative to building your own VHD, SUSE also publishes BYOS (Bring Your
103
121
13. Ensure that the SSH server is installed and configured to start at boot time. This is usually the default.
104
122
105
123
14. Swap configuration
106
-
124
+
107
125
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
+
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 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
128
111
129
```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
130
+
sed -i 's/ResourceDisk.Format=y/ResourceDisk.Format=n/g' /etc/waagent.conf
131
+
sed -i 's/ResourceDisk.EnableSwap=y/ResourceDisk.EnableSwap=n/g' /etc/waagent.conf
114
132
```
115
133
116
-
If you want mount, format and create swap you can either:
134
+
Please see the [Linux agent configuration](/azure/virtual-machines/extensions/agent-linux#configuration) documentation for more information on the waagent.conf configuration options.
135
+
136
+
If you want to mount, format and create a swap partition you can either:
117
137
* Pass this in as a cloud-init config every time you create a VM.
118
138
* Use a cloud-init directive baked into the image that will do this every time the VM is created:
119
139
@@ -141,24 +161,27 @@ As an alternative to building your own VHD, SUSE also publishes BYOS (Bring Your
141
161
15. Run the following commands to deprovision the virtual machine and prepare it for provisioning on Azure:
142
162
143
163
```console
144
-
# sudo rm -rf /var/lib/waagent/
145
-
# sudo rm -f /var/log/waagent.log
164
+
sudo -i
165
+
rm -rf /var/lib/waagent/
166
+
rm -f /var/log/waagent.log
146
167
147
-
# waagent -force -deprovision+user
148
-
# rm -f ~/.bash_history
168
+
waagent -force -deprovision+user
169
+
rm -f ~/.bash_history
149
170
150
171
151
-
# export HISTSIZE=0
172
+
export HISTSIZE=0
152
173
153
-
# logout
174
+
logout
154
175
```
155
176
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
177
157
178
---
179
+
158
180
## Prepare openSUSE 15.2+
181
+
159
182
1. In the center pane of Hyper-V Manager, select the virtual machine.
160
183
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):
184
+
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 +192,33 @@ As an alternative to building your own VHD, SUSE also publishes BYOS (Bring Your
169
192
If the command returns "No repositories defined..." then use the following commands to add these repos:
170
193
171
194
```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
195
+
sudo zypper ar -f http://download.opensuse.org/repositories/Cloud:Tools/openSUSE_15.2 Cloud:Tools_15.2
196
+
sudo zypper ar -f https://download.opensuse.org/distribution/15.2/repo/oss openSUSE_15.2_OSS
197
+
sudo zypper ar -f http://download.opensuse.org/update/15.2 openSUSE_15.2_Updates
175
198
```
176
199
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:
200
+
You can then verify the repositories have been added by running the command '`zypper lr`' again. If one of the relevant update repositories is not enabled, enable it with following command:
178
201
179
202
```console
180
-
# sudo zypper mr -e [NUMBER OF REPOSITORY]
203
+
sudo zypper mr -e [NUMBER OF REPOSITORY]
181
204
```
182
205
183
206
4. Update the kernel to the latest available version:
184
207
185
208
```console
186
-
# sudo zypper up kernel-default
209
+
sudo zypper up kernel-default
187
210
```
188
211
189
-
Or to update the system with all the latest patches:
212
+
Or to update the operating system with all the latest patches:
190
213
191
214
```console
192
-
# sudo zypper update
215
+
sudo zypper update
193
216
```
194
217
195
218
5. Install the Azure Linux Agent.
196
219
197
220
```console
198
-
# sudo zypper install WALinuxAgent
221
+
sudo zypper install WALinuxAgent
199
222
```
200
223
201
224
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:
@@ -210,13 +233,13 @@ As an alternative to building your own VHD, SUSE also publishes BYOS (Bring Your
210
233
libata.atapi_enabled=0 reserve=0x1f0,0x8
211
234
```
212
235
213
-
7. It is recommended to edit the file "/etc/sysconfig/network/dhcp" and change the `DHCLIENT_SET_HOSTNAME` parameter to the following:
236
+
7. It is recommended to edit the "/etc/sysconfig/network/dhcp" file and change the `DHCLIENT_SET_HOSTNAME` parameter to the following:
214
237
215
238
```config
216
239
DHCLIENT_SET_HOSTNAME="no"
217
240
```
218
241
219
-
8. **Important:** In "/etc/sudoers", comment out or remove the following lines if they exist:
242
+
8. **Important:** In the "/etc/sudoers" file, comment out or remove the following lines if they exist:
220
243
221
244
```text
222
245
Defaults targetpw # ask for the password of the target user i.e. root
@@ -226,7 +249,7 @@ As an alternative to building your own VHD, SUSE also publishes BYOS (Bring Your
226
249
9. Ensure that the SSH server is installed and configured to start at boot time. This is usually the default.
227
250
10. Do not create swap space on the OS disk.
228
251
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:
252
+
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
253
231
254
```config-conf
232
255
ResourceDisk.Format=y
@@ -239,18 +262,19 @@ As an alternative to building your own VHD, SUSE also publishes BYOS (Bring Your
239
262
11. Run the following commands to deprovision the virtual machine and prepare it for provisioning on Azure:
240
263
241
264
```console
242
-
# sudo waagent -force -deprovision
243
-
# export HISTSIZE=0
244
-
# logout
265
+
sudo waagent -force -deprovision
266
+
export HISTSIZE=0
267
+
logout
245
268
```
246
269
247
270
12. Ensure the Azure Linux Agent runs at startup:
248
271
249
272
```console
250
-
# sudo systemctl enable waagent.service
273
+
sudo systemctl enable waagent.service
251
274
```
252
275
253
276
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
277
255
278
## Next steps
279
+
256
280
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