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
Copy file name to clipboardExpand all lines: articles/virtual-machines/linux/create-upload-generic.md
+66-66Lines changed: 66 additions & 66 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,20 +58,20 @@ The mechanism for rebuilding the initrd or initramfs image may vary depending on
VHD images on Azure must have a virtual size aligned to 1 MB. Typically, VHDs created using Hyper-V are aligned correctly. If the VHD isn't aligned correctly, you may receive an error message similar to the following when you try to create an image from your VHD.
74
-
```output
74
+
```config
75
75
The VHD http:\//\<mystorageaccount>.blob.core.windows.net/vhds/MyLinuxVM.vhd has an unsupported virtual size of 21475270656 bytes. The size must be a whole number (in MBs).
76
76
```
77
77
In this case, resize the VM using either the Hyper-V Manager console or the [Resize-VHD](/powershell/module/hyper-v/resize-vhd) PowerShell cmdlet. If you aren't running in a Windows environment, we recommend using `qemu-img` to convert (if needed) and resize the VHD.
@@ -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
+
```config
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,46 @@ 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`.
184
183
185
184
**Initramfs**
186
185
187
186
```bash
188
-
cp /boot/initramfs-$(uname -r).img /boot/initramfs-[latest kernel version ].img.bak
189
-
dracut -f -v /boot/initramfs-[latest kernel version ].img [depending on the version of grub]
1. Ensure that the SSH server is installed, and configured to start at boot time. This configuration is usually the default.
202
+
4. Ensure that the SSH server is installed, and configured to start at boot time. This configuration is usually the default.
203
203
204
-
1. Install the Azure Linux Agent.
204
+
5. Install the Azure Linux Agent.
205
205
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
206
207
207
> [!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)**
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)**
209
209
210
210
211
211
Install the Azure Linux Agent, cloud-init and other necessary utilities by running the following command:
@@ -228,14 +228,14 @@ The [Azure Linux Agent](../extensions/agent-linux.md) `waagent` provisions a Lin
228
228
sudo systemctl enable cloud-init.service
229
229
```
230
230
231
-
1. Swap: Do not create swap space on the OS disk.
231
+
6. Swap: Do not create swap space on the OS disk.
232
232
233
233
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
234
235
235
Azure Linux Agent
236
236
Modify the following parameters in /etc/waagent.conf
237
237
238
-
```
238
+
```config
239
239
ResourceDisk.Format=y
240
240
ResourceDisk.Filesystem=ext4
241
241
ResourceDisk.MountPoint=/mnt/resource
@@ -247,9 +247,9 @@ The [Azure Linux Agent](../extensions/agent-linux.md) `waagent` provisions a Lin
247
247
Configure cloud-init to handle the provisioning:
248
248
249
249
```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
250
+
sudo sed -i 's/Provisioning.Agent=auto/Provisioning.Agent=cloud-auto/g' /etc/waagent.conf
251
+
sudo sed -i 's/ResourceDisk.Format=y/ResourceDisk.Format=n/g' /etc/waagent.conf
252
+
sudo sed -i 's/ResourceDisk.EnableSwap=y/ResourceDisk.EnableSwap=n/g' /etc/waagent.conf
253
253
```
254
254
255
255
Configure Cloud-init to create swap.
@@ -262,9 +262,9 @@ The [Azure Linux Agent](../extensions/agent-linux.md) `waagent` provisions a Lin
262
262
263
263
Create cfg file to configure swap using Cloud-init:
@@ -284,43 +284,44 @@ The [Azure Linux Agent](../extensions/agent-linux.md) `waagent` provisions a Lin
284
284
```
285
285
286
286
287
-
9. Configure cloud-init to handle the provisioning:
287
+
7. Configure cloud-init to handle the provisioning:
288
288
1. Configure waagent for cloud-init:
289
289
```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
290
+
sudo sed -i 's/Provisioning.Agent=auto/Provisioning.Agent=cloud-init/g' /etc/waagent.conf
291
+
sudo sed -i 's/ResourceDisk.Format=y/ResourceDisk.Format=n/g' /etc/waagent.conf
292
+
sudo sed -i 's/ResourceDisk.EnableSwap=y/ResourceDisk.EnableSwap=n/g' /etc/waagent.conf
293
293
```
294
294
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.
295
+
295
296
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
327
# 'tee -a /var/log/cloud-init-output.log' so the user can see output
@@ -330,25 +331,24 @@ The [Azure Linux Agent](../extensions/agent-linux.md) `waagent` provisions a Lin
330
331
```
331
332
332
333
333
-
1. Deprovision.
334
+
8. Deprovision.
334
335
> [!CAUTION]
335
336
> 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
337
337
338
Run the following commands to deprovision the virtual machine.
338
339
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
340
+
```bash
341
+
sudo rm -f /var/log/waagent.log
342
+
sudo cloud-init clean
343
+
sudo -force -deprovision+user
344
+
sudo rm -f ~/.bash_history
345
+
sudo export HISTSIZE=0
346
346
```
347
347
348
348
> [!NOTE]
349
349
> 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
350
351
-
1. Shut down the virtual machine and upload the VHD to Azure.
351
+
9. Shut down the virtual machine and upload the VHD to Azure.
352
352
353
353
## Next Steps
354
354
[Create a Linux VM from a custom disk with the Azure CLI](upload-vhd.md).
0 commit comments