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-centos.md
+38-26Lines changed: 38 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ author: srijang
5
5
ms.service: virtual-machines
6
6
ms.collection: linux
7
7
ms.topic: how-to
8
-
ms.date: 11/10/2021
8
+
ms.date: 12/14/2022
9
9
ms.author: srijangupta
10
10
ms.reviewer: mattmcinnes
11
11
---
@@ -21,18 +21,23 @@ Learn to create and upload an Azure virtual hard disk (VHD) that contains a Cent
21
21
22
22
## Prerequisites
23
23
24
-
This article assumes that you have already installed a CentOS (or similar derivative) 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)).
24
+
This article assumes that you've already installed a CentOS (or similar derivative) 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)).
25
25
26
26
**CentOS installation notes**
27
27
28
-
* Please see also [General Linux Installation Notes](create-upload-generic.md#general-linux-installation-notes) for more tips on preparing Linux for Azure.
29
-
* 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. If you are using VirtualBox this means selecting **Fixed size** as opposed to the default dynamically allocated when creating the disk.
30
-
* 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 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.
31
-
***Kernel support for mounting UDF file systems is required.** At first boot on Azure the provisioning configuration is passed to the Linux VM via UDF-formatted media that is attached to the guest. The Azure Linux agent must be able to mount the UDF file system to read its configuration and provision the VM.
32
-
* Linux kernel versions below 2.6.37 do not support NUMA on Hyper-V with larger VM sizes. This issue primarily impacts older distributions using the upstream Red Hat 2.6.32 kernel, and was fixed in RHEL 6.6 (kernel-2.6.32-504). Systems running custom kernels older than 2.6.37, or RHEL-based kernels older than 2.6.32-504 must set the boot parameter `numa=off` on the kernel command-line in grub.conf. For more information see Red Hat [KB 436883](https://access.redhat.com/solutions/436883).
33
-
* Do not configure a swap partition on the OS disk. More information about this can be found in the steps below.
28
+
* For more tips on preparing Linux for Azure, see [General Linux Installation Notes](create-upload-generic.md#general-linux-installation-notes).
29
+
* The VHDX format isn't supported in Azure, only **fixed VHD**. You can convert the disk to VHD format using Hyper-V Manager or the convert-vhd cmdlet. If you're using VirtualBox this means selecting **Fixed size** as opposed to the default dynamically allocated when creating the disk.
30
+
* The vfat kernel module must be enabled in the kernel
31
+
* When installing the Linux system it's *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 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.
32
+
***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 or cloud-init must mount the UDF file system to read its configuration and provision the VM.
33
+
* Linux kernel versions below 2.6.37 don't support NUMA on Hyper-V with larger VM sizes. This issue primarily impacts older distributions using the upstream Red Hat 2.6.32 kernel, and was fixed in RHEL 6.6 (kernel-2.6.32-504). Systems running custom kernels older than 2.6.37, or RHEL-based kernels older than 2.6.32-504 must set the boot parameter `numa=off` on the kernel command-line in grub.conf. For more information see Red Hat [KB 436883](https://access.redhat.com/solutions/436883).
34
+
* don't configure a swap partition on the OS disk. More information about this can be found in the steps below.
34
35
* 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.
35
36
37
+
> [!NOTE]
38
+
> **(_Cloud-init >= 21.2 removes the udf requirement._)** however without the udf module enabled the cdrom will not mount during provisioning preventing custom data from being applied. A workaround for this would be to apply custom data using user data however, unlike custom data user data isn't encrypted. https://cloudinit.readthedocs.io/en/latest/topics/format.html
39
+
40
+
36
41
## CentOS 6.x
37
42
38
43
1. In Hyper-V Manager, select the virtual machine.
@@ -129,7 +134,7 @@ This article assumes that you have already installed a CentOS (or similar deriva
129
134
```
130
135
131
136
> [!Note]
132
-
> The rest of this guide will assume you are using at least the `[openlogic]` repo, which will be used to install the Azure Linux agent below.
137
+
> The rest of this guide will assume you're using at least the `[openlogic]` repo, which will be used to install the Azure Linux agent below.
133
138
134
139
9. Add the following line to /etc/yum.conf:
135
140
@@ -143,7 +148,7 @@ This article assumes that you have already installed a CentOS (or similar deriva
143
148
yum clean all
144
149
```
145
150
146
-
Unless you are creating an image for an older version of CentOS, it is recommended to update all the packages to the latest:
151
+
Unless you're creating an image for an older version of CentOS, it's recommended to update all the packages to the latest:
147
152
148
153
```bash
149
154
sudo yum -y update
@@ -182,20 +187,20 @@ This article assumes that you have already installed a CentOS (or similar deriva
182
187
183
188
This will also ensure all console messages are sent to the first serial port, which can assist Azure support with debugging issues.
184
189
185
-
In addition to the above, it is recommended to *remove* the following parameters:
190
+
In addition to the above, it's recommended to *remove* the following parameters:
186
191
187
192
```console
188
193
rhgb quiet crashkernel=auto
189
194
```
190
195
191
-
Graphical and quiet boot are not useful in a cloud environment where we want all the logs to be sent to the serial port. The `crashkernel` option may be left configured if desired, but note that this parameter will reduce the amount of available memory in the VM by 128MB or more, which may be problematic on the smaller VM sizes.
196
+
Graphical and `quiet boot` are not useful in a cloud environment where we want all the logs to be sent to the serial port. The `crashkernel` option may be left configured if desired, but note that this parameter will reduce the amount of available memory in the VM by 128MB or more, which may be problematic on the smaller VM sizes.
192
197
193
198
> [!Important]
194
199
> CentOS 6.5 and earlier must also set the kernel parameter `numa=off`. See Red Hat [KB 436883](https://access.redhat.com/solutions/436883).
195
200
196
201
14. Ensure that the SSH server is installed and configured to start at boot time. This is usually the default.
197
202
198
-
15. Do not create swap space on the OS disk.
203
+
15. don't create swap space on the OS disk.
199
204
200
205
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:
201
206
@@ -224,7 +229,7 @@ This article assumes that you have already installed a CentOS (or similar deriva
224
229
225
230
Preparing a CentOS 7 virtual machine for Azure is very similar to CentOS 6, however there are several important differences worth noting:
226
231
227
-
* The NetworkManager package no longer conflicts with the Azure Linux agent. This package is installed by default and we recommend that it is not removed.
232
+
* The NetworkManager package no longer conflicts with the Azure Linux agent. This package is installed by default and we recommend that it'sn't removed.
228
233
* GRUB2 is now used as the default bootloader, so the procedure for editing kernel parameters has changed (see below).
229
234
* XFS is now the default file system. The ext4 file system can still be used if desired.
230
235
* Since CentOS 8 Stream and newer no longer include `network.service` by default, you will need to install it manually:
@@ -309,15 +314,15 @@ Preparing a CentOS 7 virtual machine for Azure is very similar to CentOS 6, howe
309
314
```
310
315
311
316
> [!Note]
312
-
> The rest of this guide will assume you are using at least the `[openlogic]` repo, which will be used to install the Azure Linux agent below.
317
+
> The rest of this guide will assume you're using at least the `[openlogic]` repo, which will be used to install the Azure Linux agent below.
313
318
314
319
7. Run the following command to clear the current yum metadata and install any updates:
315
320
316
321
```bash
317
322
sudo yum clean all
318
323
```
319
324
320
-
Unless you are creating an image for an older version of CentOS, it is recommended to update all the packages to the latest:
325
+
Unless you're creating an image for an older version of CentOS, it's recommended to update all the packages to the latest:
321
326
322
327
```bash
323
328
sudo yum -y update
@@ -331,20 +336,26 @@ Preparing a CentOS 7 virtual machine for Azure is very similar to CentOS 6, howe
This will also ensure all console messages are sent to the first serial port, which can assist Azure support with debugging issues. It also turns off the new CentOS 7 naming conventions for NICs. In addition to the above, it is recommended to *remove* the following parameters:
339
+
This will also ensure all console messages are sent to the first serial port, which can assist Azure support with debugging issues. It also turns off the new CentOS 7 naming conventions for NICs. In addition to the above, it's recommended to *remove* the following parameters:
335
340
336
341
```console
337
342
rhgb quiet crashkernel=auto
338
343
```
339
344
340
345
Graphical and quiet boot are not useful in a cloud environment where we want all the logs to be sent to the serial port. The `crashkernel` option may be left configured if desired, but note that this parameter will reduce the amount of available memory in the VM by 128MB or more, which may be problematic on the smaller VM sizes.
341
346
342
-
9. Once you aredone editing `/etc/default/grub` per above, run the following command to rebuild the grub configuration:
347
+
9. Once you're done editing `/etc/default/grub` per above, run the following command to rebuild the grub configuration:
343
348
344
349
```bash
345
350
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
346
351
```
347
352
353
+
> [!NOTE]
354
+
> If uploading an UEFI enabled VM, the command to update grub is `grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg`. Also, the vfat kernel module must be enabled in the kernel otherwise provisioning will fail.
355
+
>
356
+
> Make sure the **'udf'** module is enable. Blocklisting or removing it will cause a provisioning failure. **(_Cloud-init >= 21.2 removes the udf requirement. Read top of document for more detail)**
357
+
358
+
348
359
10. If building the image from **VMware, VirtualBox or KVM:** Ensure the Hyper-V drivers are included in the initramfs:
349
360
350
361
Edit `/etc/dracut.conf`, add content:
@@ -372,10 +383,10 @@ Preparing a CentOS 7 virtual machine for Azure is very similar to CentOS 6, howe
sed -i 's/Provisioning.UseCloudInit=n/Provisioning.UseCloudInit=y/g' /etc/waagent.conf
376
-
sed -i 's/Provisioning.Enabled=y/Provisioning.Enabled=n/g' /etc/waagent.conf
377
-
378
-
386
+
sed -i 's/Provisioning.Agent=auto/Provisioning.Agent=auto/g' /etc/waagent.conf
387
+
sed -i 's/ResourceDisk.Format=y/ResourceDisk.Format=n/g' /etc/waagent.conf
388
+
sed -i 's/ResourceDisk.EnableSwap=y/ResourceDisk.EnableSwap=n/g' /etc/waagent.conf
389
+
379
390
echo "Adding mounts and disk_setup to init stage"
380
391
sed -i '/ - mounts/d' /etc/cloud/cloud.cfg
381
392
sed -i '/ - disk_setup/d' /etc/cloud/cloud.cfg
@@ -408,10 +419,11 @@ Preparing a CentOS 7 virtual machine for Azure is very similar to CentOS 6, howe
408
419
```
409
420
410
421
411
-
13. Swap configuration
412
-
Do not create swap space on the operating system disk.
422
+
13. Swap configuration
423
+
424
+
Don't create swap space on the operating system disk.
413
425
414
-
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:
426
+
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 create the swap file, modify the following parameters in`/etc/waagent.conf` appropriately:
415
427
416
428
```console
417
429
sed -i 's/ResourceDisk.Format=y/ResourceDisk.Format=n/g' /etc/waagent.conf
@@ -445,7 +457,7 @@ Preparing a CentOS 7 virtual machine for Azure is very similar to CentOS 6, howe
445
457
446
458
14. Run the following commands to deprovision the virtual machine and prepare it for provisioning on Azure:
447
459
448
-
**Note:**if you are migrating a specific virtual machine and do not wish to create a generalized image, skip the deprovision step
460
+
**Note:**if you're migrating a specific virtual machine and don't wish to create a generalized image, skip the deprovision step
0 commit comments