Skip to content

Commit abb2d82

Browse files
Merge pull request #232376 from msaenzbosupport/patch-2
[Doc-a-Thon] Updating SUSE VHD upload doc
2 parents 092b685 + d5906c7 commit abb2d82

File tree

1 file changed

+53
-62
lines changed

1 file changed

+53
-62
lines changed

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

Lines changed: 53 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -50,42 +50,39 @@ As an alternative to building your own VHD, SUSE also publishes BYOS (Bring Your
5050
3. Register your SUSE Linux Enterprise system to allow it to download updates and install packages.
5151
4. Update the system with the latest patches:
5252

53-
```console
53+
```bash
5454
sudo zypper update
5555
```
5656

5757
5. Install Azure Linux Agent and cloud-init
5858

59-
```console
60-
SUSEConnect -p sle-module-public-cloud/15.2/x86_64 (SLES 15 SP2)
59+
```bash
60+
sudo SUSEConnect -p sle-module-public-cloud/15.2/x86_64 (SLES 15 SP2)
6161
sudo zypper refresh
6262
sudo zypper install python-azure-agent
6363
sudo zypper install cloud-init
6464
```
6565

6666
6. Enable waagent & cloud-init to start on boot
6767

68-
```console
68+
```bash
6969
sudo -i
70-
chkconfig waagent on
71-
systemctl enable cloud-init-local.service
72-
systemctl enable cloud-init.service
73-
systemctl enable cloud-config.service
74-
systemctl enable cloud-final.service
75-
systemctl daemon-reload
76-
cloud-init clean
77-
exit
70+
sudo chkconfig waagent on
71+
sudo systemctl enable cloud-init-local.service
72+
sudo systemctl enable cloud-init.service
73+
sudo systemctl enable cloud-config.service
74+
sudo systemctl enable cloud-final.service
75+
sudo systemctl daemon-reload
76+
sudo cloud-init clean
7877
```
7978

8079
7. Update waagent and cloud-init configuration
8180

82-
```console
83-
sed -i 's/Provisioning.UseCloudInit=n/Provisioning.UseCloudInit=auto/g' /etc/waagent.conf
84-
sed -i 's/Provisioning.Enabled=y/Provisioning.Enabled=n/g' /etc/waagent.conf
85-
86-
sh -c 'printf "datasource:\n Azure:" > /etc/cloud/cloud.cfg.d/91-azure_datasource.cfg'
87-
sh -c 'printf "reporting:\n logging:\n type: log\n telemetry:\n type: hyperv" > /etc/cloud/cloud.cfg.d/10-azure-kvp.cfg'
88-
exit
81+
```bash
82+
sudo sed -i 's/Provisioning.UseCloudInit=n/Provisioning.UseCloudInit=auto/g' /etc/waagent.conf
83+
sudo sed -i 's/Provisioning.Enabled=y/Provisioning.Enabled=n/g' /etc/waagent.conf
84+
sudo sh -c 'printf "datasource:\n Azure:" > /etc/cloud/cloud.cfg.d/91-azure_datasource.cfg'
85+
sudo sh -c 'printf "reporting:\n logging:\n type: log\n telemetry:\n type: hyperv" > /etc/cloud/cloud.cfg.d/10-azure-kvp.cfg'
8986
```
9087

9188
8. Edit the "/etc/default/grub" file to ensure console logs are sent to the serial port by adding the following line:
@@ -96,7 +93,7 @@ As an alternative to building your own VHD, SUSE also publishes BYOS (Bring Your
9693

9794
Next, apply this change by running the following command:
9895

99-
```console
96+
```bash
10097
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
10198
```
10299

@@ -106,11 +103,10 @@ As an alternative to building your own VHD, SUSE also publishes BYOS (Bring Your
106103

107104
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:
108105

109-
```console
106+
```bash
110107
sudo -i
111-
ln -s /dev/null /etc/udev/rules.d/75-persistent-net-generator.rules
112-
rm -f /etc/udev/rules.d/70-persistent-net.rules
113-
exit
108+
sudo ln -s /dev/null /etc/udev/rules.d/75-persistent-net-generator.rules
109+
sudo rm -f /etc/udev/rules.d/70-persistent-net.rules
114110
```
115111

116112
11. It's recommended to edit the "/etc/sysconfig/network/dhcp" file and change the `DHCLIENT_SET_HOSTNAME` parameter to the following:
@@ -121,7 +117,7 @@ As an alternative to building your own VHD, SUSE also publishes BYOS (Bring Your
121117
122118
12. In the "/etc/sudoers" file, comment out or remove the following lines if they exist:
123119
124-
```text
120+
```output
125121
Defaults targetpw # ask for the password of the target user i.e. root
126122
ALL ALL=(ALL) ALL # WARNING! Only use this setting together with 'Defaults targetpw'!
127123
```
@@ -134,11 +130,10 @@ As an alternative to building your own VHD, SUSE also publishes BYOS (Bring Your
134130

135131
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:
136132

137-
```console
133+
```bash
138134
sudo -i
139-
sed -i 's/ResourceDisk.Format=y/ResourceDisk.Format=n/g' /etc/waagent.conf
140-
sed -i 's/ResourceDisk.EnableSwap=y/ResourceDisk.EnableSwap=n/g' /etc/waagent.conf
141-
exit
135+
sudo sed -i 's/ResourceDisk.Format=y/ResourceDisk.Format=n/g' /etc/waagent.conf
136+
sudo sed -i 's/ResourceDisk.EnableSwap=y/ResourceDisk.EnableSwap=n/g' /etc/waagent.conf
142137
```
143138

144139
For more information on the waagent.conf configuration options, see the [Linux agent configuration](../extensions/agent-linux.md#configuration) documentation.
@@ -147,9 +142,9 @@ As an alternative to building your own VHD, SUSE also publishes BYOS (Bring Your
147142
* Pass this configuration in as a cloud-init config every time you create a VM.
148143
* Use a cloud-init directive baked into the image that configures swap space every time the VM is created:
149144

150-
```console
145+
```bash
151146
sudo -i
152-
echo 'DefaultEnvironment="CLOUD_CFG=/etc/cloud/cloud.cfg.d/00-azure-swap.cfg"' >> /etc/systemd/system.conf
147+
sudo echo 'DefaultEnvironment="CLOUD_CFG=/etc/cloud/cloud.cfg.d/00-azure-swap.cfg"' >> /etc/systemd/system.conf
153148
cat > /etc/cloud/cloud.cfg.d/00-azure-swap.cfg << EOF
154149
#cloud-config
155150
# Generated by Azure cloud image build
@@ -167,25 +162,23 @@ As an alternative to building your own VHD, SUSE also publishes BYOS (Bring Your
167162
- ["ephemeral0.1", "/mnt"]
168163
- ["ephemeral0.2", "none", "swap", "sw,nofail,x-systemd.requires=cloud-init.service,x-systemd.device-timeout=2", "0", "0"]
169164
EOF
170-
exit
171165
```
172166
> [!NOTE]
173167
> Make sure the **'udf'** module is enabled. Blocklisting or removing it will cause a provisioning failure. **(_Cloud-init >= 21.2 removes the udf requirement. Please read top of document for more detail)**
174168
175169
176170
15. Run the following commands to deprovision the virtual machine and prepare it for provisioning on Azure:
177171
178-
```console
172+
> [!NOTE]
173+
> If you're migrating a specific virtual machine and don't wish to create a generalized image, skip the deprovision step
174+
175+
```bash
179176
sudo rm -f /var/log/waagent.log
180177
sudo cloud-init clean
181-
182-
waagent -force -deprovision+user
183-
rm -f ~/.bash_history
184-
185-
export HISTSIZE=0
186-
187-
logout
188-
```
178+
sudo waagent -force -deprovision+user
179+
sudo rm -f ~/.bash_history
180+
sudo export HISTSIZE=0
181+
```
189182
190183
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).
191184
@@ -205,33 +198,33 @@ As an alternative to building your own VHD, SUSE also publishes BYOS (Bring Your
205198
206199
If the command returns "No repositories defined..." then use the following commands to add these repos:
207200
208-
```console
201+
```bash
209202
sudo zypper ar -f http://download.opensuse.org/repositories/Cloud:Tools/openSUSE_15.2 Cloud:Tools_15.2
210203
sudo zypper ar -f https://download.opensuse.org/distribution/15.2/repo/oss openSUSE_15.2_OSS
211204
sudo zypper ar -f http://download.opensuse.org/update/15.2 openSUSE_15.2_Updates
212205
```
213206
214207
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:
215208
216-
```console
209+
```bash
217210
sudo zypper mr -e [NUMBER OF REPOSITORY]
218211
```
219212
220213
4. Update the kernel to the latest available version:
221214
222-
```console
215+
```bash
223216
sudo zypper up kernel-default
224217
```
225218
226219
Or to update the operating system with all the latest patches:
227220
228-
```console
221+
```bash
229222
sudo zypper update
230223
```
231224
232225
5. Install the Azure Linux Agent.
233226
234-
```console
227+
```bash
235228
sudo zypper install WALinuxAgent
236229
```
237230
@@ -255,7 +248,7 @@ As an alternative to building your own VHD, SUSE also publishes BYOS (Bring Your
255248
256249
8. **Important:** In the "/etc/sudoers" file, comment out or remove the following lines if they exist:
257250
258-
```text
251+
```output
259252
Defaults targetpw # ask for the password of the target user i.e. root
260253
ALL ALL=(ALL) ALL # WARNING! Only use this together with 'Defaults targetpw'!
261254
```
@@ -275,29 +268,27 @@ As an alternative to building your own VHD, SUSE also publishes BYOS (Bring Your
275268
276269
11. Ensure the Azure Linux Agent runs at startup:
277270
278-
```console
271+
```bash
279272
sudo systemctl enable waagent.service
280273
```
281274
282275
12. Run the following commands to deprovision the virtual machine and prepare it for provisioning on Azure:
283276
284-
```console
285-
rm -f ~/.bash_history # Remove current user history
286-
277+
> [!NOTE]
278+
> If you're migrating a specific virtual machine and don't wish to create a generalized image, skip the deprovision step
279+
280+
```bash
281+
sudo rm -f ~/.bash_history # Remove current user history
287282
sudo -i
288-
rm -rf /var/lib/waagent/
289-
rm -f /var/log/waagent.log
290-
291-
waagent -force -deprovision+user
292-
rm -f ~/.bash_history # Remove root user history
293-
294-
export HISTSIZE=0
295-
296-
logout
297-
```
283+
sudo rm -rf /var/lib/waagent/
284+
sudo rm -f /var/log/waagent.log
285+
sudo waagent -force -deprovision+user
286+
sudo rm -f ~/.bash_history # Remove root user history
287+
sudo export HISTSIZE=0
288+
```
298289
299290
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).
300291
301292
## Next steps
302293
303-
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).
294+
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)