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
+72-65Lines changed: 72 additions & 65 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,20 +26,23 @@ This article assumes that you've already installed a CentOS (or similar derivati
26
26
**CentOS installation notes**
27
27
28
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.
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
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.
31
+
* When installing the Linux system it's **recommended** that you use standard partitions rather than LVM (often the default for many installations). This avoids 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
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.
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.
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 Centos 2.6.32 kernel, and was fixed in Centos 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.
35
+
* All VHDs on Azure must have a virtual size aligned to 1 MB. When converting from a raw disk to VHD, you must ensure that the raw disk size is a multiple of 1 MB before conversion. See [Linux Installation Notes](create-upload-generic.md#general-linux-installation-notes) for more information.
36
36
37
37
> [!NOTE]
38
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
39
40
40
41
41
## CentOS 6.x
42
42
43
+
> [!IMPORTANT]
44
+
>Please note that CentOS 6 has reached its End Of Life (EOL) and is no longer supported by the CentOS community. This means that no further updates or security patches will be released for this version, leaving it vulnerable to potential security risks. We strongly recommend upgrading to a more recent version of CentOS to ensure the safety and stability of your system. Please consult with your IT department or system administrator for further assistance.
45
+
43
46
1. In Hyper-V Manager, select the virtual machine.
44
47
45
48
2. Click **Connect** to open a console window for the virtual machine.
@@ -52,14 +55,14 @@ This article assumes that you've already installed a CentOS (or similar derivati
52
55
53
56
4. Create or edit the file `/etc/sysconfig/network` and add the following text:
54
57
55
-
```console
58
+
```output
56
59
NETWORKING=yes
57
60
HOSTNAME=localhost.localdomain
58
61
```
59
62
60
63
5. Create or edit the file `/etc/sysconfig/network-scripts/ifcfg-eth0` and add the following text:
61
64
62
-
```console
65
+
```output
63
66
DEVICE=eth0
64
67
ONBOOT=yes
65
68
BOOTPROTO=dhcp
@@ -76,15 +79,15 @@ This article assumes that you've already installed a CentOS (or similar derivati
7. Ensure the network service will start at boot time by running the following command:
82
+
7. Ensure the network service starts at boot time by running the following command:
80
83
81
84
```bash
82
85
sudo chkconfig network on
83
86
```
84
87
85
-
8. If you would like to use the OpenLogic mirrors that are hosted within the Azure datacenters, then replace the `/etc/yum.repos.d/CentOS-Base.repo` file with the following repositories. This will also add the **[openlogic]** repository that includes additional packages such as the Azure Linux agent:
88
+
8. If you would like to use the OpenLogic mirrors that are hosted within the Azure datacenters, then replace the `/etc/yum.repos.d/CentOS-Base.repo` file with the following repositories. This will also add the **[openlogic]** repository that includes extra packages such as the Azure Linux agent:
@@ -138,14 +141,14 @@ This article assumes that you've already installed a CentOS (or similar derivati
138
141
139
142
9. Add the following line to /etc/yum.conf:
140
143
141
-
```console
144
+
```output
142
145
http_caching=packages
143
146
```
144
147
145
148
10. Run the following command to clear the current yum metadata and update the system with the latest packages:
146
149
147
150
```bash
148
-
yum clean all
151
+
sudo yum clean all
149
152
```
150
153
151
154
Unless you're creating an image for an older version of CentOS, it's recommended to update all the packages to the latest:
@@ -177,34 +180,34 @@ This article assumes that you've already installed a CentOS (or similar derivati
177
180
```
178
181
179
182
180
-
The WALinuxAgent package will remove the NetworkManager and NetworkManager-gnome packages if they were not already removed as described in step 3.
183
+
The WALinuxAgent package removes the NetworkManager and NetworkManager-gnome packages if they were not already removed as described in step 3.
181
184
182
185
13. Modify the kernel boot line in your grub configuration to include additional kernel parameters forAzure. To do this, open `/boot/grub/menu.lst`in a text editor and ensure that the default kernel includes the following parameters:
183
186
184
-
```console
187
+
```output
185
188
console=ttyS0 earlyprintk=ttyS0 rootdelay=300
186
189
```
187
190
188
191
This will also ensure all console messages are sent to the first serial port, which can assist Azure support with debugging issues.
189
192
190
193
In addition to the above, it's recommended to *remove* the following parameters:
191
194
192
-
```console
195
+
```output
193
196
rhgb quiet crashkernel=auto
194
197
```
195
198
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.
199
+
Graphical and `quiet boot` aren't 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 128 MB or more, which may be problematic on the smaller VM sizes.
197
200
198
201
> [!Important]
199
202
> CentOS 6.5 and earlier must also set the kernel parameter `numa=off`. See Red Hat [KB 436883](https://access.redhat.com/solutions/436883).
200
203
201
204
14. Ensure that the SSH server is installed and configured to start at boot time. This is usually the default.
202
205
203
-
15. don't create swap space on the OS disk.
206
+
15. Don't create swap space on the OS disk.
204
207
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 thelocal 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:
208
+
The Azure Linux Agent can automatically configure swap space using the local resource disk that 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. After installing the Azure Linux Agent (see previous step), modify the following parameters in `/etc/waagent.conf` appropriately:
206
209
207
-
```console
210
+
```output
208
211
ResourceDisk.Format=y
209
212
ResourceDisk.Filesystem=ext4
210
213
ResourceDisk.MountPoint=/mnt/resource
@@ -214,11 +217,13 @@ This article assumes that you've already installed a CentOS (or similar derivati
214
217
215
218
16. Run the following commands to deprovision the virtual machine and prepare it for provisioning on Azure:
216
219
217
-
```bash
218
-
sudo waagent -force -deprovision+user
219
-
export HISTSIZE=0
220
-
logout
221
-
```
220
+
```bash
221
+
sudo waagent -force -deprovision+user
222
+
sudo export HISTSIZE=0
223
+
```
224
+
> [!NOTE]
225
+
> If you are migrating a specific virtual machine and do not wish to create a generalized image, skip the deprovision step.
226
+
222
227
223
228
17. Click **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).
224
229
@@ -227,14 +232,14 @@ This article assumes that you've already installed a CentOS (or similar derivati
227
232
228
233
**Changes in CentOS 7 (and similar derivatives)**
229
234
230
-
Preparing a CentOS 7 virtual machine for Azure is very similar to CentOS 6, however there are several important differences worth noting:
235
+
Preparing a CentOS 7 virtual machine for Azure is similar to CentOS 6, however there are several important differences worth noting:
231
236
232
237
* 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.
233
238
* GRUB2 is now used as the default bootloader, so the procedure for editing kernel parameters has changed (see below).
234
239
* XFS is now the default file system. The ext4 file system can still be used if desired.
235
-
* Since CentOS 8 Stream and newer no longer include `network.service` by default, you will need to install it manually:
240
+
* Since CentOS 8 Stream and newer no longer include `network.service` by default, you need to install it manually:
236
241
237
-
```console
242
+
```bash
238
243
sudo yum install network-scripts
239
244
sudo systemctl enable network.service
240
245
```
@@ -247,14 +252,14 @@ Preparing a CentOS 7 virtual machine for Azure is very similar to CentOS 6, howe
247
252
248
253
3. Create or edit the file `/etc/sysconfig/network` and add the following text:
249
254
250
-
```console
255
+
```output
251
256
NETWORKING=yes
252
257
HOSTNAME=localhost.localdomain
253
258
```
254
259
255
260
4. Create or edit the file `/etc/sysconfig/network-scripts/ifcfg-eth0` and add the following text:
256
261
257
-
```console
262
+
```output
258
263
DEVICE=eth0
259
264
ONBOOT=yes
260
265
BOOTPROTO=dhcp
@@ -273,7 +278,7 @@ Preparing a CentOS 7 virtual machine for Azure is very similar to CentOS 6, howe
273
278
274
279
6. If you would like to use the OpenLogic mirrors that are hosted within the Azure datacenters, then replace the `/etc/yum.repos.d/CentOS-Base.repo` file with the following repositories. This will also add the **[openlogic]** repository that includes packages for the Azure Linux agent:
275
280
276
-
```console
281
+
```output
277
282
[openlogic]
278
283
name=CentOS-$releasever - openlogic packages for $basearch
@@ -332,17 +337,17 @@ Preparing a CentOS 7 virtual machine for Azure is very similar to CentOS 6, howe
332
337
333
338
8. Modify the kernel boot line in your grub configuration to include additional kernel parameters forAzure. To do this, open `/etc/default/grub`in a text editor and edit the `GRUB_CMDLINE_LINUX` parameter, for example:
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:
340
345
341
-
```console
346
+
```output
342
347
rhgb quiet crashkernel=auto
343
348
```
344
349
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.
350
+
Graphical and quiet boot isn't 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 128 MB or more, which may be problematic on the smaller VM sizes.
346
351
347
352
9. Once you're done editing `/etc/default/grub` per above, run the following command to rebuild the grub configuration:
348
353
@@ -360,7 +365,7 @@ Preparing a CentOS 7 virtual machine for Azure is very similar to CentOS 6, howe
360
365
361
366
Edit `/etc/dracut.conf`, add content:
362
367
363
-
```console
368
+
```output
364
369
add_drivers+=" hv_vmbus hv_netvsc hv_storvsc "
365
370
```
366
371
@@ -379,22 +384,25 @@ Preparing a CentOS 7 virtual machine for Azure is very similar to CentOS 6, howe
@@ -415,7 +423,6 @@ Preparing a CentOS 7 virtual machine for Azure is very similar to CentOS 6, howe
415
423
# there without needing to look on the console.
416
424
output: {all: '| tee -a /var/log/cloud-init-output.log'}
417
425
EOF
418
-
419
426
```
420
427
421
428
@@ -425,18 +432,18 @@ Preparing a CentOS 7 virtual machine for Azure is very similar to CentOS 6, howe
425
432
426
433
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:
427
434
428
-
```console
429
-
sed -i 's/ResourceDisk.Format=y/ResourceDisk.Format=n/g' /etc/waagent.conf
430
-
sed -i 's/ResourceDisk.EnableSwap=y/ResourceDisk.EnableSwap=n/g' /etc/waagent.conf
435
+
```bash
436
+
sudo sed -i 's/ResourceDisk.Format=y/ResourceDisk.Format=n/g' /etc/waagent.conf
437
+
sudo sed -i 's/ResourceDisk.EnableSwap=y/ResourceDisk.EnableSwap=n/g' /etc/waagent.conf
431
438
```
432
439
433
440
If you want mount, format and create swap you can either:
434
441
* Pass this in as a cloud-init config every time you create a VM
435
442
* Use a cloud-init directive baked into the image that will do this every time the VM is created:
0 commit comments