Skip to content

Commit 9e1604f

Browse files
committed
edit pass: linux-article-batch1
1 parent f1fc969 commit 9e1604f

File tree

1 file changed

+47
-45
lines changed

1 file changed

+47
-45
lines changed

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

Lines changed: 47 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,8 @@ This article assumes that you already installed a CentOS (or similar derivative)
225225
sudo export HISTSIZE=0
226226
```
227227

228-
> [!NOTE]
229-
> If you're migrating a specific VM and don't want to create a generalized image, skip the deprovision step.
228+
> [!NOTE]
229+
> If you're migrating a specific VM and don't want to create a generalized image, skip the deprovision step.
230230

231231
1. Select **Action** > **Shut Down** in Hyper-V Manager. Your Linux VHD is now ready to be [uploaded to Azure](./upload-vhd.md#option-1-upload-a-vhd).
232232

@@ -241,7 +241,7 @@ Preparing a CentOS 7 VM for Azure is similar to CentOS 6. Several significant di
241241
* The `NetworkManager` package no longer conflicts with the Azure Linux agent. This package is installed by default and we recommend that you don't remove it.
242242
* GRUB2 is now used as the default bootloader, so the procedure for editing kernel parameters has changed. (See the "Configuration steps" section.)
243243
* XFS is now the default file system. The ext4 file system can still be used if you want.
244-
* Since CentOS 8 Stream and newer no longer include `network.service` by default, you need to install it manually:
244+
* Because CentOS 8 Stream and newer no longer include `network.service` by default, you need to install it manually:
245245

246246
```bash
247247
sudo yum install network-scripts
@@ -362,21 +362,21 @@ Preparing a CentOS 7 VM for Azure is similar to CentOS 6. Several significant di
362362
> [!NOTE]
363363
> If you're uploading a 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 fails.
364364
>
365-
> Make sure the udf module is enabled. Removing or disabling it will cause a provisioning or boot failure. *(_Cloud-init >= 21.2 removes the udf requirement. For more information, read the top of document.)*
365+
> Make sure the udf module is enabled. Removing or disabling it will cause a provisioning or boot failure. *(_Cloud-init >= 21.2 removes the udf requirement. For more information, read the top of the document.)*
366366
367-
1. If you're building the image from VMware, VirtualBox, or KVM: Ensure that the Hyper-V drivers are included in the initramfs:
367+
1. If you're building the image from VMware, VirtualBox, or KVM, ensure that the Hyper-V drivers are included in the initramfs:
368368

369-
Edit `/etc/dracut.conf`, add content:
369+
1. Edit `/etc/dracut.conf` and add content:
370370

371-
```config
372-
add_drivers+=" hv_vmbus hv_netvsc hv_storvsc "
373-
```
371+
```config
372+
add_drivers+=" hv_vmbus hv_netvsc hv_storvsc "
373+
```
374374

375-
Rebuild the initramfs:
375+
1. Rebuild the initramfs:
376376

377-
```bash
378-
sudo dracut -f -v
379-
```
377+
```bash
378+
sudo dracut -f -v
379+
```
380380

381381
1. Install the Azure Linux agent and dependencies for Azure VM extensions:
382382

@@ -390,21 +390,23 @@ Preparing a CentOS 7 VM for Azure is similar to CentOS 6. Several significant di
390390
```bash
391391
sudo yum install -y cloud-init cloud-utils-growpart gdisk hyperv-daemons
392392
```
393-
393+
394394
1. Configure `waagent` for cloud-init:
395395

396396
```bash
397397
sudo sed -i 's/Provisioning.Agent=auto/Provisioning.Agent=auto/g' /etc/waagent.conf
398398
sudo sed -i 's/ResourceDisk.Format=y/ResourceDisk.Format=n/g' /etc/waagent.conf
399399
sudo sed -i 's/ResourceDisk.EnableSwap=y/ResourceDisk.EnableSwap=n/g' /etc/waagent.conf
400400
```
401+
401402
```bash
402403
sudo echo "Adding mounts and disk_setup to init stage"
403404
sudo sed -i '/ - mounts/d' /etc/cloud/cloud.cfg
404405
sudo sed -i '/ - disk_setup/d' /etc/cloud/cloud.cfg
405406
sudo sed -i '/cloud_init_modules/a\\ - mounts' /etc/cloud/cloud.cfg
406407
sudo sed -i '/cloud_init_modules/a\\ - disk_setup' /etc/cloud/cloud.cfg
407408
```
409+
408410
```bash
409411
sudo echo "Allow only Azure datasource, disable fetching network setting via IMDS"
410412
sudo cat > /etc/cloud/cloud.cfg.d/91-azure_datasource.cfg <<EOF
@@ -430,43 +432,43 @@ Preparing a CentOS 7 VM for Azure is similar to CentOS 6. Several significant di
430432
EOF
431433
```
432434
433-
1. Swap configuration.
434-
435-
Don't create swap space on the OS disk.
436-
437-
Previously, the Azure Linux agent was used to automatically configure swap space by using the local resource disk that's attached to the VM after the VM is provisioned on Azure. However, cloud-init now handles this step. You *must not* use the Linux agent to format the resource disk to create the swap file. Modify the following parameters in `/etc/waagent.conf` appropriately:
438-
439-
```bash
440-
sudo sed -i 's/ResourceDisk.Format=y/ResourceDisk.Format=n/g' /etc/waagent.conf
441-
sudo sed -i 's/ResourceDisk.EnableSwap=y/ResourceDisk.EnableSwap=n/g' /etc/waagent.conf
442-
```
435+
1. Swap configuration:
443436
444-
If you want to mount, format, and create the swap file, you can either:
437+
1. Don't create swap space on the OS disk.
445438
446-
* Pass this command in as a cloud-init config every time you create a VM.
447-
* Use a cloud-init directive baked into the image to do this step every time the VM is created:
439+
Previously, the Azure Linux agent was used to automatically configure swap space by using the local resource disk that's attached to the VM after the VM is provisioned on Azure. However, cloud-init now handles this step. You *must not* use the Linux agent to format the resource disk to create the swap file. Modify the following parameters in `/etc/waagent.conf` appropriately:
448440
449441
```bash
450-
sudo echo 'DefaultEnvironment="CLOUD_CFG=/etc/cloud/cloud.cfg.d/00-azure-swap.cfg"' >> /etc/systemd/system.conf
451-
sudo cat > /etc/cloud/cloud.cfg.d/00-azure-swap.cfg << EOF
452-
#cloud-config
453-
# Generated by Azure cloud image build
454-
disk_setup:
455-
ephemeral0:
456-
table_type: mbr
457-
layout: [66, [33, 82]]
458-
overwrite: True
459-
fs_setup:
460-
- device: ephemeral0.1
461-
filesystem: ext4
462-
- device: ephemeral0.2
463-
filesystem: swap
464-
mounts:
465-
- ["ephemeral0.1", "/mnt"]
466-
- ["ephemeral0.2", "none", "swap", "sw,nofail,x-systemd.requires=cloud-init.service,x-systemd.device-timeout=2", "0", "0"]
467-
EOF
442+
sudo sed -i 's/ResourceDisk.Format=y/ResourceDisk.Format=n/g' /etc/waagent.conf
443+
sudo sed -i 's/ResourceDisk.EnableSwap=y/ResourceDisk.EnableSwap=n/g' /etc/waagent.conf
468444
```
469445
446+
1. If you want to mount, format, and create the swap file, you can either:
447+
448+
* Pass this command in as a cloud-init config every time you create a VM.
449+
* Use a cloud-init directive baked into the image to do this step every time the VM is created:
450+
451+
```bash
452+
sudo echo 'DefaultEnvironment="CLOUD_CFG=/etc/cloud/cloud.cfg.d/00-azure-swap.cfg"' >> /etc/systemd/system.conf
453+
sudo cat > /etc/cloud/cloud.cfg.d/00-azure-swap.cfg << EOF
454+
#cloud-config
455+
# Generated by Azure cloud image build
456+
disk_setup:
457+
ephemeral0:
458+
table_type: mbr
459+
layout: [66, [33, 82]]
460+
overwrite: True
461+
fs_setup:
462+
- device: ephemeral0.1
463+
filesystem: ext4
464+
- device: ephemeral0.2
465+
filesystem: swap
466+
mounts:
467+
- ["ephemeral0.1", "/mnt"]
468+
- ["ephemeral0.2", "none", "swap", "sw,nofail,x-systemd.requires=cloud-init.service,x-systemd.device-timeout=2", "0", "0"]
469+
EOF
470+
```
471+
470472
1. Run the following commands to deprovision the VM and prepare it for provisioning on Azure.
471473
472474
> [!NOTE]

0 commit comments

Comments
 (0)