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
-Changed the code block from console to bash
-Added the code block output or bash for some empty block codes
- Modified a few lines for the creation of the initramfs and initrd.
-Modified the name os suse to SUSE
-Fix a typo on command line : 213 .. Must be : WALinuxAgent
Copy file name to clipboardExpand all lines: articles/virtual-machines/linux/create-upload-generic.md
+63-65Lines changed: 63 additions & 65 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,7 +31,7 @@ This article focuses on general guidance for running your Linux distribution on
31
31
32
32
4. The maximum size allowed for the VHD is 1,023 GB.
33
33
34
-
5. When installing the Linux system we recommend that you use standard partitions, rather than Logical Volume Manager (LVM) which is the default for many installations. Using standard partitions will avoid LVM name conflicts with cloned VMs, particularly if an OS disk is ever attached to another identical 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.
34
+
5. When installing the Linux system, we recommend that you use standard partitions, rather than Logical Volume Manager (LVM) which is the default for many installations. Using standard partitions will avoid LVM name conflicts with cloned VMs, particularly if an OS disk is ever attached to another identical 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.
35
35
36
36
6. Kernel support for mounting UDF file systems is necessary. At first boot on Azure the provisioning configuration is passed to the Linux VM by using UDF-formatted media that is attached to the guest. The Azure Linux agent must mount the UDF file system to read its configuration and provision the VM.
37
37
@@ -58,14 +58,14 @@ The mechanism for rebuilding the initrd or initramfs image may vary depending on
@@ -82,11 +82,11 @@ In this case, resize the VM using either the Hyper-V Manager console or the [Res
82
82
83
83
1. Resizing the VHD directly using tools such as `qemu-img` or `vbox-manage` may result in an unbootable VHD. We recommend first converting the VHD to a RAW disk image. If the VM image was created as a RAW disk image (the default for some hypervisors such as KVM), then you may skip this step.
84
84
85
-
```
86
-
qemu-img convert -f vpc -O raw MyLinuxVM.vhd MyLinuxVM.raw
85
+
```bash
86
+
sudo qemu-img convert -f vpc -O raw MyLinuxVM.vhd MyLinuxVM.raw
87
87
```
88
88
89
-
1. Calculate the required size of the disk image so that the virtual size is aligned to 1 MB. The following bash shell script uses `qemu-img info` to determine the virtual size of the disk image, and then calculates the size to the next 1 MB.
89
+
2. Calculate the required size of the disk image so that the virtual size is aligned to 1 MB. The following bash shell script uses `qemu-img info` to determine the virtual size of the disk image, and then calculates the size to the next 1 MB.
90
90
91
91
```bash
92
92
rawdisk="MyLinuxVM.raw"
@@ -104,19 +104,19 @@ In this case, resize the VM using either the Hyper-V Manager console or the [Res
104
104
3. Resize the raw disk using `$rounded_size` as set above.
105
105
106
106
```bash
107
-
qemu-img resize MyLinuxVM.raw $rounded_size
107
+
sudo qemu-img resize MyLinuxVM.raw $rounded_size
108
108
```
109
109
110
110
4. Now, convert the RAW disk back to a fixed-size VHD.
111
111
112
112
```bash
113
-
qemu-img convert -f raw -o subformat=fixed,force_size -O vpc MyLinuxVM.raw MyLinuxVM.vhd
@@ -166,11 +166,11 @@ The [Azure Linux Agent](../extensions/agent-linux.md) `waagent` provisions a Lin
166
166
## General Linux System Requirements
167
167
168
168
1. Modify the kernel boot line in GRUB or GRUB2 to include the following parameters, so that all console messages are sent to the first serial port. These messages can assist Azure support with debugging any issues.
We also recommend *removing* the following parameters if they exist.
173
-
```
173
+
```output
174
174
rhgb quiet crashkernel=auto
175
175
```
176
176
Graphical and quiet boot isn't useful in a cloud environment, where we want all logs sent to the serial port. The `crashkernel` option may be left configured if needed, but note that this parameter reduces the amount of available memory in the VM by at least 128 MB, which may be problematic for smaller VM sizes.
@@ -179,46 +179,44 @@ The [Azure Linux Agent](../extensions/agent-linux.md) `waagent` provisions a Lin
179
179
```bash
180
180
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
181
181
```
182
-
1. Add Hyper-V modules both initrd and initramfs instructions (Dracut).
183
-
1. Rebuild `initrd` or `initramfs`.
182
+
3. Add Hyper-V modules both initrd and initramfs instructions using `dracut` or `mkinitramfs`.
1. Ensure that the SSH server is installed, and configured to start at boot time. This configuration is usually the default.
200
+
4. Ensure that the SSH server is installed, and configured to start at boot time. This configuration is usually the default.
203
201
204
-
1. Install the Azure Linux Agent.
202
+
5. Install the Azure Linux Agent.
205
203
The Azure Linux Agent is required forprovisioning a Linux image on Azure. Many distributions provide the agent as an RPM or .deb package (the package is typically called WALinuxAgent or walinuxagent). The agent can also be installed manually by following the stepsin the [Linux Agent Guide](../extensions/agent-linux.md).
206
204
207
205
> [!NOTE]
208
-
> Make sure 'udf' and 'vfat' modules are enable. Blocklisting or removing the udf module will cause a provisioning failure. Blocklisting or removing vfat module will cause both provisioning and boot failures. **(_Cloud-init >= 21.2 removes the udf requirement. Please read top of document for more detail)**
206
+
> Make sure 'udf' and 'vfat' modules are enable. `Blocklisting` or removing the udf module will cause a provisioning failure. `Blocklisting` or removing vfat module will cause both provisioning and boot failures. **(_Cloud-init >= 21.2 removes the udf requirement. Please read top of document for more detail)**
209
207
210
208
211
209
Install the Azure Linux Agent, cloud-init and other necessary utilities by running the following command:
@@ -228,14 +226,14 @@ The [Azure Linux Agent](../extensions/agent-linux.md) `waagent` provisions a Lin
228
226
sudo systemctl enable cloud-init.service
229
227
```
230
228
231
-
1. Swap: Do not create swap space on the OS disk.
229
+
6. Swap: Do not create swap space on the OS disk.
232
230
233
231
The Azure Linux Agent or Cloud-init can be used to configure swap space using the local resource disk. This resource disk is attached to the VM after provisioning on Azure. The local resource disk is a temporary disk, and might be emptied when the VM is deprovisioned. The following blocks show how to configure this swap.
234
232
235
233
Azure Linux Agent
236
234
Modify the following parameters in /etc/waagent.conf
237
235
238
-
```
236
+
```output
239
237
ResourceDisk.Format=y
240
238
ResourceDisk.Filesystem=ext4
241
239
ResourceDisk.MountPoint=/mnt/resource
@@ -247,9 +245,9 @@ The [Azure Linux Agent](../extensions/agent-linux.md) `waagent` provisions a Lin
247
245
Configure cloud-init to handle the provisioning:
248
246
249
247
```bash
250
-
sed -i 's/Provisioning.Agent=auto/Provisioning.Agent=cloud-auto/g' /etc/waagent.conf
251
-
sed -i 's/ResourceDisk.Format=y/ResourceDisk.Format=n/g' /etc/waagent.conf
252
-
sed -i 's/ResourceDisk.EnableSwap=y/ResourceDisk.EnableSwap=n/g' /etc/waagent.conf
248
+
sudo sed -i 's/Provisioning.Agent=auto/Provisioning.Agent=cloud-auto/g' /etc/waagent.conf
249
+
sudo sed -i 's/ResourceDisk.Format=y/ResourceDisk.Format=n/g' /etc/waagent.conf
250
+
sudo sed -i 's/ResourceDisk.EnableSwap=y/ResourceDisk.EnableSwap=n/g' /etc/waagent.conf
253
251
```
254
252
255
253
Configure Cloud-init to create swap.
@@ -262,9 +260,9 @@ The [Azure Linux Agent](../extensions/agent-linux.md) `waagent` provisions a Lin
262
260
263
261
Create cfg file to configure swap using Cloud-init:
@@ -284,43 +282,44 @@ The [Azure Linux Agent](../extensions/agent-linux.md) `waagent` provisions a Lin
284
282
```
285
283
286
284
287
-
9. Configure cloud-init to handle the provisioning:
285
+
7. Configure cloud-init to handle the provisioning:
288
286
1. Configure waagent for cloud-init:
289
287
```bash
290
-
sed -i 's/Provisioning.Agent=auto/Provisioning.Agent=cloud-init/g' /etc/waagent.conf
291
-
sed -i 's/ResourceDisk.Format=y/ResourceDisk.Format=n/g' /etc/waagent.conf
292
-
sed -i 's/ResourceDisk.EnableSwap=y/ResourceDisk.EnableSwap=n/g' /etc/waagent.conf
288
+
sudo sed -i 's/Provisioning.Agent=auto/Provisioning.Agent=cloud-init/g' /etc/waagent.conf
289
+
sudo sed -i 's/ResourceDisk.Format=y/ResourceDisk.Format=n/g' /etc/waagent.conf
290
+
sudo sed -i 's/ResourceDisk.EnableSwap=y/ResourceDisk.EnableSwap=n/g' /etc/waagent.conf
293
291
```
294
292
If you are migrating a specific virtual machine and do not wish to create a generalized image, set`Provisioning.Agent=disabled`in the `/etc/waagent.conf` config.
293
+
295
294
1. Configure mounts:
296
-
```
297
-
echo "Adding mounts and disk_setup to init stage"
298
-
sed -i '/ - mounts/d' /etc/cloud/cloud.cfg
299
-
sed -i '/ - disk_setup/d' /etc/cloud/cloud.cfg
300
-
sed -i '/cloud_init_modules/a\\ - mounts' /etc/cloud/cloud.cfg
301
-
sed -i '/cloud_init_modules/a\\ - disk_setup' /etc/cloud/cloud.cfg
302
-
2. Configure Azure datasource:
303
-
```
304
-
echo "Allow only Azure datasource, disable fetching network setting via IMDS"
# This tells cloud-init to redirect its stdout and stderr to
326
325
# 'tee -a /var/log/cloud-init-output.log' so the user can see output
@@ -330,25 +329,24 @@ The [Azure Linux Agent](../extensions/agent-linux.md) `waagent` provisions a Lin
330
329
```
331
330
332
331
333
-
1. Deprovision.
332
+
8. Deprovision.
334
333
> [!CAUTION]
335
334
> If you are migrating a specific virtual machine and do not wish to create a generalized image, skip the deprovision step. Running the command waagent -force -deprovision+user will render the source machine unusable, this step is intended only to create a generalized image.
336
335
337
336
Run the following commands to deprovision the virtual machine.
338
337
339
-
```
340
-
# sudo rm -f /var/log/waagent.log
341
-
# sudo cloud-init clean
342
-
# waagent -force -deprovision+user
343
-
# rm -f ~/.bash_history
344
-
# export HISTSIZE=0
345
-
# logout
338
+
```bash
339
+
sudo rm -f /var/log/waagent.log
340
+
sudo cloud-init clean
341
+
sudo -force -deprovision+user
342
+
sudo rm -f ~/.bash_history
343
+
sudo export HISTSIZE=0
346
344
```
347
345
348
346
> [!NOTE]
349
347
> On Virtualbox you may see the following error after running `waagent -force -deprovision` that says `[Errno 5] Input/output error`. This error message is not critical and can be ignored.
350
348
351
-
1. Shut down the virtual machine and upload the VHD to Azure.
349
+
9. Shut down the virtual machine and upload the VHD to Azure.
352
350
353
351
## Next Steps
354
352
[Create a Linux VM from a custom disk with the Azure CLI](upload-vhd.md).
0 commit comments