Skip to content

Commit bb58f94

Browse files
Merge pull request #221504 from cynthn/219355
219355 - Srijan
2 parents 08f0304 + 2bc9ad9 commit bb58f94

File tree

1 file changed

+38
-26
lines changed

1 file changed

+38
-26
lines changed

articles/virtual-machines/linux/create-upload-centos.md

Lines changed: 38 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ author: srijang
55
ms.service: virtual-machines
66
ms.collection: linux
77
ms.topic: how-to
8-
ms.date: 11/10/2021
8+
ms.date: 12/14/2022
99
ms.author: srijangupta
1010
ms.reviewer: mattmcinnes
1111
---
@@ -21,18 +21,23 @@ Learn to create and upload an Azure virtual hard disk (VHD) that contains a Cent
2121

2222
## Prerequisites
2323

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)).
2525

2626
**CentOS installation notes**
2727

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.
3435
* 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.
3536

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+
3641
## CentOS 6.x
3742

3843
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
129134
```
130135

131136
> [!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.
133138
134139
9. Add the following line to /etc/yum.conf:
135140
@@ -143,7 +148,7 @@ This article assumes that you have already installed a CentOS (or similar deriva
143148
yum clean all
144149
```
145150
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:
147152
148153
```bash
149154
sudo yum -y update
@@ -182,20 +187,20 @@ This article assumes that you have already installed a CentOS (or similar deriva
182187
183188
This will also ensure all console messages are sent to the first serial port, which can assist Azure support with debugging issues.
184189
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:
186191
187192
```console
188193
rhgb quiet crashkernel=auto
189194
```
190195
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.
192197
193198
> [!Important]
194199
> CentOS 6.5 and earlier must also set the kernel parameter `numa=off`. See Red Hat [KB 436883](https://access.redhat.com/solutions/436883).
195200
196201
14. Ensure that the SSH server is installed and configured to start at boot time. This is usually the default.
197202
198-
15. Do not create swap space on the OS disk.
203+
15. don't create swap space on the OS disk.
199204
200205
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:
201206
@@ -224,7 +229,7 @@ This article assumes that you have already installed a CentOS (or similar deriva
224229
225230
Preparing a CentOS 7 virtual machine for Azure is very similar to CentOS 6, however there are several important differences worth noting:
226231
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.
228233
* GRUB2 is now used as the default bootloader, so the procedure for editing kernel parameters has changed (see below).
229234
* XFS is now the default file system. The ext4 file system can still be used if desired.
230235
* 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
309314
```
310315
311316
> [!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.
313318
314319
7. Run the following command to clear the current yum metadata and install any updates:
315320
316321
```bash
317322
sudo yum clean all
318323
```
319324
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:
321326
322327
```bash
323328
sudo yum -y update
@@ -331,20 +336,26 @@ Preparing a CentOS 7 virtual machine for Azure is very similar to CentOS 6, howe
331336
GRUB_CMDLINE_LINUX="rootdelay=300 console=ttyS0 earlyprintk=ttyS0 net.ifnames=0"
332337
```
333338
334-
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:
335340
336341
```console
337342
rhgb quiet crashkernel=auto
338343
```
339344
340345
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.
341346
342-
9. Once you are done 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:
343348
344349
```bash
345350
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
346351
```
347352
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+
348359
10. If building the image from **VMware, VirtualBox or KVM:** Ensure the Hyper-V drivers are included in the initramfs:
349360
350361
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
372383
yum install -y cloud-init cloud-utils-growpart gdisk hyperv-daemons
373384
374385
# Configure waagent for cloud-init
375-
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+
379390
echo "Adding mounts and disk_setup to init stage"
380391
sed -i '/ - mounts/d' /etc/cloud/cloud.cfg
381392
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
408419
```
409420
410421
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.
413425
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:
415427
416428
```console
417429
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
445457
446458
14. Run the following commands to deprovision the virtual machine and prepare it for provisioning on Azure:
447459
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
449461
450462
```console
451463
# sudo rm -f /var/log/waagent.log

0 commit comments

Comments
 (0)