Skip to content

Commit ea0a536

Browse files
Initial commit, multiple editorial fixes
1 parent a11df4d commit ea0a536

File tree

2 files changed

+82
-58
lines changed

2 files changed

+82
-58
lines changed

articles/virtual-machines/linux/run-scripts-in-vm.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ms.service: virtual-machines
66
ms.collection: linux
77
author: bobbytreed
88
ms.author: robreed
9-
ms.date: 05/02/2018
9+
ms.date: 12/08/2022
1010
ms.topic: how-to
1111

1212
---

articles/virtual-machines/linux/suse-create-upload-vhd.md

Lines changed: 81 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ms.subservice: imaging
77
ms.collection: linux
88
ms.workload: infrastructure-services
99
ms.topic: how-to
10-
ms.date: 12/01/2020
10+
ms.date: 12/08/2022
1111
ms.author: srijangupta
1212
ms.reviewer: mattmcinnes
1313

@@ -16,84 +16,102 @@ ms.reviewer: mattmcinnes
1616

1717
**Applies to:** :heavy_check_mark: Linux VMs :heavy_check_mark: Flexible scale sets **Applies to:** :heavy_check_mark: Uniform scale sets
1818

19+
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+
1923
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)).
2024

2125
## 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.
2328
* 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.
2530
* 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.
2631
* 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.
2732

2833
## Use SUSE Studio
34+
2935
[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.
3036

3137
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).
3238

3339
## Prepare SUSE Linux Enterprise Server for Azure
40+
3441
1. In the center pane of Hyper-V Manager, select the virtual machine.
3542
2. Click **Connect** to open the window for the virtual machine.
3643
3. Register your SUSE Linux Enterprise system to allow it to download updates and install packages.
3744
4. Update the system with the latest patches:
3845

3946
```console
40-
# sudo zypper update
47+
sudo zypper update
4148
```
4249
4350
5. Install Azure Linux Agent and cloud-init
4451

4552
```console
46-
# SUSEConnect -p sle-module-public-cloud/15.2/x86_64 (SLES 15 SP2)
47-
# sudo zypper refresh
48-
# sudo zypper install python-azure-agent
49-
# sudo zypper install cloud-init
53+
SUSEConnect -p sle-module-public-cloud/15.2/x86_64 (SLES 15 SP2)
54+
sudo zypper refresh
55+
sudo zypper install python-azure-agent
56+
sudo zypper install cloud-init
5057
```
5158

5259
6. Enable waagent & cloud-init to start on boot
5360

5461
```console
55-
# sudo chkconfig waagent on
56-
# systemctl enable cloud-init-local.service
57-
# systemctl enable cloud-init.service
58-
# systemctl enable cloud-config.service
59-
# systemctl enable cloud-final.service
60-
# systemctl daemon-reload
61-
# cloud-init clean
62+
sudo -i
63+
chkconfig waagent on
64+
systemctl enable cloud-init-local.service
65+
systemctl enable cloud-init.service
66+
systemctl enable cloud-config.service
67+
systemctl enable cloud-final.service
68+
systemctl daemon-reload
69+
cloud-init clean
70+
exit
6271
```
6372

6473
7. Update waagent and cloud-init configuration
6574

6675
```console
67-
# sed -i 's/Provisioning.UseCloudInit=n/Provisioning.UseCloudInit=y/g' /etc/waagent.conf
68-
# sed -i 's/Provisioning.Enabled=y/Provisioning.Enabled=n/g' /etc/waagent.conf
76+
sed -i 's/Provisioning.UseCloudInit=n/Provisioning.UseCloudInit=y/g' /etc/waagent.conf
77+
sed -i 's/Provisioning.Enabled=y/Provisioning.Enabled=n/g' /etc/waagent.conf
6978

70-
# sudo sh -c 'printf "datasource:\n Azure:" > /etc/cloud/cloud.cfg.d/91-azure_datasource.cfg'
71-
# sudo sh -c 'printf "reporting:\n logging:\n type: log\n telemetry:\n type: hyperv" > /etc/cloud/cloud.cfg.d/10-azure-kvp.cfg'
79+
sudo sh -c 'printf "datasource:\n Azure:" > /etc/cloud/cloud.cfg.d/91-azure_datasource.cfg'
80+
sudo sh -c 'printf "reporting:\n logging:\n type: log\n telemetry:\n type: hyperv" > /etc/cloud/cloud.cfg.d/10-azure-kvp.cfg'
7281
```
7382

74-
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:
7584

7685
```config-grub
7786
console=ttyS0 earlyprintk=ttyS0
7887
```
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+
8399
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:
84100

85101
```console
86-
# sudo ln -s /dev/null /etc/udev/rules.d/75-persistent-net-generator.rules
87-
# sudo rm -f /etc/udev/rules.d/70-persistent-net.rules
102+
sudo -i
103+
ln -s /dev/null /etc/udev/rules.d/75-persistent-net-generator.rules
104+
rm -f /etc/udev/rules.d/70-persistent-net.rules
105+
exit
88106
```
89-
90-
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:
91109

92110
```config
93111
DHCLIENT_SET_HOSTNAME="no"
94112
```
95113

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:
97115

98116
```text
99117
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
103121
13. Ensure that the SSH server is installed and configured to start at boot time. This is usually the default.
104122

105123
14. Swap configuration
106-
124+
107125
Do not create swap space on the operating system disk.
108126

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:
110128

111129
```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
114132
```
115133

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:
117137
* Pass this in as a cloud-init config every time you create a VM.
118138
* Use a cloud-init directive baked into the image that will do this every time the VM is created:
119139

@@ -141,24 +161,27 @@ As an alternative to building your own VHD, SUSE also publishes BYOS (Bring Your
141161
15. Run the following commands to deprovision the virtual machine and prepare it for provisioning on Azure:
142162

143163
```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
146167

147-
# waagent -force -deprovision+user
148-
# rm -f ~/.bash_history
168+
waagent -force -deprovision+user
169+
rm -f ~/.bash_history
149170
150171

151-
# export HISTSIZE=0
172+
export HISTSIZE=0
152173

153-
# logout
174+
logout
154175
```
155176
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).
156177

157178
---
179+
158180
## Prepare openSUSE 15.2+
181+
159182
1. In the center pane of Hyper-V Manager, select the virtual machine.
160183
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):
162185

163186
| # | Alias | Name | Enabled | Refresh
164187
| - | :-------------------- | :-------------------- | :------ | :------
@@ -169,33 +192,33 @@ As an alternative to building your own VHD, SUSE also publishes BYOS (Bring Your
169192
If the command returns "No repositories defined..." then use the following commands to add these repos:
170193

171194
```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
175198
```
176199

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:
178201

179202
```console
180-
# sudo zypper mr -e [NUMBER OF REPOSITORY]
203+
sudo zypper mr -e [NUMBER OF REPOSITORY]
181204
```
182205

183206
4. Update the kernel to the latest available version:
184207

185208
```console
186-
# sudo zypper up kernel-default
209+
sudo zypper up kernel-default
187210
```
188211

189-
Or to update the system with all the latest patches:
212+
Or to update the operating system with all the latest patches:
190213

191214
```console
192-
# sudo zypper update
215+
sudo zypper update
193216
```
194217

195218
5. Install the Azure Linux Agent.
196219

197220
```console
198-
# sudo zypper install WALinuxAgent
221+
sudo zypper install WALinuxAgent
199222
```
200223

201224
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
210233
libata.atapi_enabled=0 reserve=0x1f0,0x8
211234
```
212235

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:
214237

215238
```config
216239
DHCLIENT_SET_HOSTNAME="no"
217240
```
218241

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:
220243

221244
```text
222245
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
226249
9. Ensure that the SSH server is installed and configured to start at boot time. This is usually the default.
227250
10. Do not create swap space on the OS disk.
228251

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:
230253

231254
```config-conf
232255
ResourceDisk.Format=y
@@ -239,18 +262,19 @@ As an alternative to building your own VHD, SUSE also publishes BYOS (Bring Your
239262
11. Run the following commands to deprovision the virtual machine and prepare it for provisioning on Azure:
240263

241264
```console
242-
# sudo waagent -force -deprovision
243-
# export HISTSIZE=0
244-
# logout
265+
sudo waagent -force -deprovision
266+
export HISTSIZE=0
267+
logout
245268
```
246269

247270
12. Ensure the Azure Linux Agent runs at startup:
248271

249272
```console
250-
# sudo systemctl enable waagent.service
273+
sudo systemctl enable waagent.service
251274
```
252275

253276
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).
254277

255278
## Next steps
279+
256280
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

Comments
 (0)