Skip to content

Commit 7f5b78c

Browse files
authored
Update suse-create-upload-vhd.md
updated file to resolve conflicts
1 parent 2ddb2a0 commit 7f5b78c

File tree

1 file changed

+114
-118
lines changed

1 file changed

+114
-118
lines changed

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

Lines changed: 114 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -48,136 +48,132 @@ As an alternative to building your own VHD, SUSE also publishes BYOS (Bring Your
4848

4949
If your software hypervisor is not Hyper-V, other modules need to be added into the initramfs to successfully boot in Azure
5050

51-
Edit the "/etc/dracut.conf" file and add the following line to the file:
51+
Edit the "/etc/dracut.conf" file and add the following line to the file then executeh the ```dracut```command to rebuild the initramfs file:
5252

53-
```config
54-
add_drivers+=" hv_vmbus hv_netvsc hv_storvsc "
55-
```
56-
57-
Once the configuration file has been saved, run the following command to update the intramfs of the host:
53+
```config
54+
add_drivers+=" hv_vmbus hv_netvsc hv_storvsc "
55+
```
5856

59-
```bash
60-
sudo dracut --verbose --force
61-
```
57+
```bash
58+
sudo dracut --verbose --force
59+
```
6260

6361
2. Setup the Serial Console.
6462

65-
In order to successfully work with the serial console, it's required to set up several variables in the "/etc/defaults/grub" file.
63+
In order to successfully work with the serial console, it's required to set up several variables in the "/etc/defaults/grub" file and recreate the grub on the server.
6664

67-
```config
68-
# Add console=ttyS0 and earlyprintk=ttS0 to the variable
69-
# remove "splash=silent" and "quiet" options.
70-
GRUB_CMDLINE_LINUX_DEFAULT="audit=1 no-scroll fbcon=scrollback:0 mitigations=auto security=apparmor crashkernel=228M,high crashkernel=72M,low console=ttyS0 earlyprintk=ttyS0"
65+
```config
66+
# Add console=ttyS0 and earlyprintk=ttS0 to the variable
67+
# remove "splash=silent" and "quiet" options.
68+
GRUB_CMDLINE_LINUX_DEFAULT="audit=1 no-scroll fbcon=scrollback:0 mitigations=auto security=apparmor crashkernel=228M,high crashkernel=72M,low console=ttyS0 earlyprintk=ttyS0"
7169
72-
# Add "console serial" to GRUB_TERMINAL
73-
GRUB_TERMINAL="console serial"
70+
# Add "console serial" to GRUB_TERMINAL
71+
GRUB_TERMINAL="console serial"
7472
75-
# Set the GRUB_SERIAL_COMMAND variable
73+
# Set the GRUB_SERIAL_COMMAND variable
7674
77-
GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"
78-
```
79-
80-
Next recreate the grub:
75+
GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"
76+
```
8177

82-
```shell
83-
/usr/sbin/grub2-mkconfig -o /boot/grub2/grub.cfg
84-
```
78+
```shell
79+
/usr/sbin/grub2-mkconfig -o /boot/grub2/grub.cfg
80+
```
8581

8682
3. Register your SUSE Linux Enterprise system to allow it to download updates and install packages.
8783

8884
4. Update the system with the latest patches:
8985

90-
```bash
91-
sudo zypper update
92-
```
86+
```bash
87+
sudo zypper update
88+
```
9389

9490
5. Install Azure Linux Agent and cloud-init
9591

96-
```bash
97-
sudo SUSEConnect -p sle-module-public-cloud/15.2/x86_64 (SLES 15 SP2)
98-
sudo zypper refresh
99-
sudo zypper install python-azure-agent
100-
sudo zypper install cloud-init
101-
```
92+
```bash
93+
sudo SUSEConnect -p sle-module-public-cloud/15.2/x86_64 (SLES 15 SP2)
94+
sudo zypper refresh
95+
sudo zypper install python-azure-agent
96+
sudo zypper install cloud-init
97+
```
10298

10399
6. Enable waagent & cloud-init to start on boot
104100

105-
```bash
106-
sudo systemctl enable waagent
107-
sudo systemctl enable cloud-init-local.service
108-
sudo systemctl enable cloud-init.service
109-
sudo systemctl enable cloud-config.service
110-
sudo systemctl enable cloud-final.service
111-
sudo systemctl daemon-reload
112-
sudo cloud-init clean
113-
```
101+
```bash
102+
sudo systemctl enable waagent
103+
sudo systemctl enable cloud-init-local.service
104+
sudo systemctl enable cloud-init.service
105+
sudo systemctl enable cloud-config.service
106+
sudo systemctl enable cloud-final.service
107+
sudo systemctl daemon-reload
108+
sudo cloud-init clean
109+
```
114110

115111
7. Update the cloud-init configuration
116112

117-
```bash
118-
cat <<EOF | sudo /etc/cloud/cloud.cfg.d/91-azure_datasource.cfg
119-
datasource_list: [ Azure ]
120-
datasource:
121-
Azure:
122-
apply_network_config: False
113+
```bash
114+
cat <<EOF | sudo /etc/cloud/cloud.cfg.d/91-azure_datasource.cfg
115+
datasource_list: [ Azure ]
116+
datasource:
117+
Azure:
118+
apply_network_config: False
123119
124-
EOF
125-
```
120+
EOF
121+
```
126122

127-
```bash
128-
sudo cat <<EOF | sudo tee /etc/cloud/cloud.cfg.d/05_logging.cfg
129-
# This tells cloud-init to redirect its stdout and stderr to
130-
# 'tee -a /var/log/cloud-init-output.log' so the user can see output
131-
# there without needing to look on the console.
132-
output: {all: '| tee -a /var/log/cloud-init-output.log'}
133-
EOF
134-
135-
# Make sure mounts and disk_setup are in the init stage:
136-
echo "Adding mounts and disk_setup to init stage"
137-
sudo sed -i '/ - mounts/d' /etc/cloud/cloud.cfg
138-
sudo sed -i '/ - disk_setup/d' /etc/cloud/cloud.cfg
139-
sudo sed -i '/cloud_init_modules/a\\ - mounts' /etc/cloud/cloud.cfg
140-
sudo sed -i '/cloud_init_modules/a\\ - disk_setup' /etc/cloud/cloud.cfg
141-
```
123+
```bash
124+
sudo cat <<EOF | sudo tee /etc/cloud/cloud.cfg.d/05_logging.cfg
125+
# This tells cloud-init to redirect its stdout and stderr to
126+
# 'tee -a /var/log/cloud-init-output.log' so the user can see output
127+
# there without needing to look on the console.
128+
output: {all: '| tee -a /var/log/cloud-init-output.log'}
129+
EOF
130+
131+
# Make sure mounts and disk_setup are in the init stage:
132+
echo "Adding mounts and disk_setup to init stage"
133+
sudo sed -i '/ - mounts/d' /etc/cloud/cloud.cfg
134+
sudo sed -i '/ - disk_setup/d' /etc/cloud/cloud.cfg
135+
sudo sed -i '/cloud_init_modules/a\\ - mounts' /etc/cloud/cloud.cfg
136+
sudo sed -i '/cloud_init_modules/a\\ - disk_setup' /etc/cloud/cloud.cfg
137+
```
142138

143139
8. If you want to mount, format, and create a swap partition you can either:
144140
* Pass this configuration in as a cloud-init config every time you create a VM.
145141
* Use a cloud-init directive baked into the image that configures swap space every time the VM is created:
146142

147143

148-
```bash
149-
cat <<EOF | sudo tee -a /etc/systemd/system.conf
150-
'DefaultEnvironment="CLOUD_CFG=/etc/cloud/cloud.cfg.d/00-azure-swap.cfg"'
151-
EOF
152-
153-
cat <<EOF | sudo tee /etc/cloud/cloud.cfg.d/00-azure-swap.cfg
154-
#cloud-config
155-
# Generated by Azure cloud image build
156-
disk_setup:
157-
ephemeral0:
158-
table_type: mbr
159-
layout: [66, [33, 82]]
160-
overwrite: True
161-
fs_setup:
162-
- device: ephemeral0.1
163-
filesystem: ext4
164-
- device: ephemeral0.2
165-
filesystem: swap
166-
mounts:
167-
- ["ephemeral0.1", "/mnt"]
168-
- ["ephemeral0.2", "none", "swap", "sw,nofail,x-systemd.requires=cloud-init.service,x-systemd.device-timeout=2", "0", "0"]
169-
EOF
170-
```
144+
```bash
145+
cat <<EOF | sudo tee -a /etc/systemd/system.conf
146+
'DefaultEnvironment="CLOUD_CFG=/etc/cloud/cloud.cfg.d/00-azure-swap.cfg"'
147+
EOF
148+
149+
cat <<EOF | sudo tee /etc/cloud/cloud.cfg.d/00-azure-swap.cfg
150+
#cloud-config
151+
# Generated by Azure cloud image build
152+
disk_setup:
153+
ephemeral0:
154+
table_type: mbr
155+
layout: [66, [33, 82]]
156+
overwrite: True
157+
fs_setup:
158+
- device: ephemeral0.1
159+
filesystem: ext4
160+
- device: ephemeral0.2
161+
filesystem: swap
162+
mounts:
163+
- ["ephemeral0.1", "/mnt"]
164+
- ["ephemeral0.2", "none", "swap", "sw,nofail,x-systemd.requires=cloud-init.service,x-systemd.device-timeout=2", "0", "0"]
165+
EOF
166+
```
171167

172168
9. 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:
173169

174170

175-
```bash
176-
sudo sed -i 's/Provisioning.UseCloudInit=n/Provisioning.UseCloudInit=auto/g' /etc/waagent.conf
177-
sudo sed -i 's/Provisioning.Enabled=y/Provisioning.Enabled=n/g' /etc/waagent.conf
178-
sudo sed -i 's/ResourceDisk.Format=y/ResourceDisk.Format=n/g' /etc/waagent.conf
179-
sudo sed -i 's/ResourceDisk.EnableSwap=y/ResourceDisk.EnableSwap=n/g' /etc/waagent.conf
180-
```
171+
```bash
172+
sudo sed -i 's/Provisioning.UseCloudInit=n/Provisioning.UseCloudInit=auto/g' /etc/waagent.conf
173+
sudo sed -i 's/Provisioning.Enabled=y/Provisioning.Enabled=n/g' /etc/waagent.conf
174+
sudo sed -i 's/ResourceDisk.Format=y/ResourceDisk.Format=n/g' /etc/waagent.conf
175+
sudo sed -i 's/ResourceDisk.EnableSwap=y/ResourceDisk.EnableSwap=n/g' /etc/waagent.conf
176+
```
181177

182178
> [!NOTE]
183179
> Make sure the **'udf'** module is enabled. Removing/disabling them will cause a provisioning/boot failure. **(_Cloud-init >= 21.2 removes the udf requirement. Please read top of document for more detail)**
@@ -186,49 +182,49 @@ As an alternative to building your own VHD, SUSE also publishes BYOS (Bring Your
186182

187183
11. Remove udev rules and network adapter configuration files 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:
188184

189-
```bash
190-
sudo rm -f /etc/udev/rules.d/70-persistent-net.rules
191-
sudo rm -f /etc/udev/rules.d/85-persistent-net-cloud-init.rules
192-
sudo rm -f /etc/sysconfig/network/ifcfg-eth*
193-
```
185+
```bash
186+
sudo rm -f /etc/udev/rules.d/70-persistent-net.rules
187+
sudo rm -f /etc/udev/rules.d/85-persistent-net-cloud-init.rules
188+
sudo rm -f /etc/sysconfig/network/ifcfg-eth*
189+
```
194190

195191
12. It's recommended to edit the "/etc/sysconfig/network/dhcp" file and change the `DHCLIENT_SET_HOSTNAME` parameter to the following:
196192

197-
```config
198-
DHCLIENT_SET_HOSTNAME="no"
199-
```
193+
```config
194+
DHCLIENT_SET_HOSTNAME="no"
195+
```
200196

201197
13. In the "/etc/sudoers" file, comment out or remove the following lines if they exist:
202198

203-
```output
204-
Defaults targetpw # ask for the password of the target user i.e. root
205-
ALL ALL=(ALL) ALL # WARNING! Only use this setting together with 'Defaults targetpw'!
206-
```
199+
```output
200+
Defaults targetpw # ask for the password of the target user i.e. root
201+
ALL ALL=(ALL) ALL # WARNING! Only use this setting together with 'Defaults targetpw'!
202+
```
207203

208204

209205
14. Ensure that the SSH server is installed and configured to start at boot time.
210206

211-
```bash
212-
sudo systemctl enable sshd
213-
```
207+
```bash
208+
sudo systemctl enable sshd
209+
```
214210

215211
15. Make sure to clean cloud-init stage;
216212

217-
```bash
218-
sudo cloud-init clean --seed --logs
219-
```
213+
```bash
214+
sudo cloud-init clean --seed --logs
215+
```
220216

221217
16. Run the following commands to deprovision the virtual machine and prepare it for provisioning on Azure:
222218

223219
>[!NOTE]
224220
> If you're migrating a specific virtual machine and don't wish to create a generalized image, skip the deprovision step
225221
226-
```bash
227-
sudo rm -f /var/log/waagent.log
228-
sudo waagent -force -deprovision+user
229-
sudo export HISTSIZE=0
230-
sudo rm -f ~/.bash_history
231-
```
222+
```bash
223+
sudo rm -f /var/log/waagent.log
224+
sudo waagent -force -deprovision+user
225+
sudo export HISTSIZE=0
226+
sudo rm -f ~/.bash_history
227+
```
232228

233229
---
234230

0 commit comments

Comments
 (0)