All Products
Search
Document Center

2. Make a RHEL image

Last Updated: Jan 23, 2019

This section describes how to migrate a physical host from an offline IDC or migrate a virtual machine from a classic virtualization platform to Alibaba Cloud.

Option 1: Migrate your physical server to Alibaba Cloud (P2V)

If you use Cloud Migration tool to migrate the operating system image of a physical server to Alibaba Cloud, see Migrate to ECS by using Cloud Migration tool. After the image is imported to ECS, you can create RHEL instances from the imported image. If you use this option, skip the rest of this article.

Option 2: Migrate your virtual machine to Alibaba Cloud (V2V)

This section describes how to create an Alibaba cloud supported virtual machine Image on your local physical server.

Note: If you already have a virtual machine running on a RHEL7 server which meet the requirement mentioned in step 1, you can move to step 3 and skip step 2.

1. Prepare one physical Red Hat Enterprise Linux 7 server

Log on to the physical RHEL7 server, and confirm all the packages listed in the following table are installed on your RHEL server. You can run yum info [package] to see whether a specific package is installed or not.

Package Repository Description
libvirt rhel-7-server-rpms An open-source API, daemon, and management tool for managing platform virtualization.
virt-manager rhel-7-server-rpms A desktop virtual machine manager.
libguestfs rhel-7-server-rpms A set of tools for accessing and modifying virtual machine (VM) disk images.
libguestfs-tools rhel-7-server-rpms A set of system administration tools for virtual machines, including Guestfish.
qemu-img rhel-7-server-rpms A tool to convert virtual machine disk image files from one format to another.

2. Create a virtual machine

If you already have a virtual machine running on a RHEL7 server which meet the requirement mentioned in step 1, you can move to step 3 and skip this step 2.2.2.

  1. Download the latest “Red Hat Enterprise Linux 7.5 Update KVM Guest Image” or “Red Hat Enterprise Linux 7.4 Update KVM Guest Image” from the Red Hat download page.

    Note: Even though RHEL 7.4 is supported on Alibaba Cloud, we recommend that you download RHEL 7.5.

  2. Save the image to the RHEL server prepared in the section Prepare a physical Red Hat Enterprise Linux 7 server.

  3. Move the image to the /var/lib/libvirt/images directory.

  4. On the Virtual Machine Manager window, click the iCON icon to create a new virtual machine.

    VMM

  5. Follow the Create a new virtual machine wizard to complete the configurations:

    1. Select Import existing disk image to install the guest operating system, and click Forward.

      NewVM

    2. Browse the /var/lib/libvirt/images directory and select the qcow2 KVM Guest Image.

      GuestImage

    3. Set the memory and CPU cores for the new virtual machine.

      NewVMMemory

    4. Review the configurations of the new virtual machine, specify a name, and select Customize configuration before install, then click Finish.

      CustomizeBeforeInstall

    5. In the left-side pane of the custom configuration dialog box, click NIC, and select virtio as the Device model.

    6. Click Begin Installation.

      The new virtual machine creation begins. During the process, the virtual machine console appears and boots to a logon prompt.

    7. When the logon prompt appears, shut down the virtual machine.

  6. Run virt-customize to set a password for the root user of the virtual machine. For example:

    1. # virt-customize -a /var/lib/libvirt/images/rhel-server-7.5-x86_64-kvm.qcow2 --root-password password:redhat!
    2. [ 0.0] Examining the guest ...
    3. [ 103.0] Setting a random seed
    4. [ 103.0] Setting passwords
    5. [ 112.0] Finishing off
  7. Start the RHEL virtual machine and log on as root.

Once you log on to the virtual machine, go to configure the guest operating system.

3. Configure the guest operating system

Make sure the guest operating system of the RHEL virtual machine meets all the requirements listed in the Limitations section.

Verify the configurations of the guest operating system

Item Requirements
/etc/shadow /etc/shadow is not locked by running the chattr command.
qemu-ga qemu-ga is uninstalled.
network Network Manager is disabled or uninstalled, and network service is enabled.
ssh The SSH service is enabled, and PermitRootLogin is not set.
firewall Firewalls are disabled.
file system xfs, ext3, or ext4 is used. Do not use ext4 with 64-bit feature.
passwd passwd is installed.
Partitions MBR is used for partitioning.
Logical Volume Manager (LVM) Logical Volume Manager (LVM) is not used.
/lib Only relative paths can be used for the /lib and /lib64.
cloud-init The guest operating system must have cloud-init installed.
Note: The cloud-init automatically disables username and password authentication when you install it. To activate the authentication again, modify the cloud-init configuration file /etc/cloud/cloud.cfg according to step 5 of the Install cloud-init section.

Configure the ntp.conf file

Follow these steps to configure the ntp.conf file, which is in the /etc/ntp.conf directory:

  1. Run the following command to back up the ntp.conf file as ntp.conf.bk.

    1. cp /etc/ntp.conf /etc/ntp.conf.bk
  2. Edit the /etc/ntp.conf file and replace its content with the following lines.

    1. driftfile /var/lib/ntp/drift
    2. pidfile /var/run/ntpd.pid
    3. logfile /var/log/ntp.log
    4. # Access Control Support
    5. restrict default kod nomodify notrap nopeer noquery
    6. restrict -6 default kod nomodify notrap nopeer noquery
    7. restrict 127.0.0.1
    8. restrict 192.168.0.0 mask 255.255.0.0 nomodify notrap nopeer noquery
    9. restrict 172.16.0.0 mask 255.240.0.0 nomodify notrap nopeer noquery
    10. restrict 100.64.0.0 mask 255.192.0.0 nomodify notrap nopeer noquery
    11. restrict 10.0.0.0 mask 255.0.0.0 nomodify notrap nopeer noquery
    12. # local clock
    13. server 127.127.1.0
    14. fudge 127.127.1.0 stratum 10
    15. restrict ntp1.aliyun.com nomodify notrap nopeer noquery
    16. restrict ntp1.cloud.aliyuncs.com nomodify notrap nopeer noquery
    17. restrict ntp10.cloud.aliyuncs.com nomodify notrap nopeer noquery
    18. restrict ntp11.cloud.aliyuncs.com nomodify notrap nopeer noquery
    19. restrict ntp12.cloud.aliyuncs.com nomodify notrap nopeer noquery
    20. restrict ntp2.aliyun.com nomodify notrap nopeer noquery
    21. restrict ntp2.cloud.aliyuncs.com nomodify notrap nopeer noquery
    22. restrict ntp3.aliyun.com nomodify notrap nopeer noquery
    23. restrict ntp3.cloud.aliyuncs.com nomodify notrap nopeer noquery
    24. restrict ntp4.aliyun.com nomodify notrap nopeer noquery
    25. restrict ntp4.cloud.aliyuncs.com nomodify notrap nopeer noquery
    26. restrict ntp5.aliyun.com nomodify notrap nopeer noquery
    27. restrict ntp5.cloud.aliyuncs.com nomodify notrap nopeer noquery
    28. restrict ntp6.aliyun.com nomodify notrap nopeer noquery
    29. restrict ntp6.cloud.aliyuncs.com nomodify notrap nopeer noquery
    30. restrict ntp7.cloud.aliyuncs.com nomodify notrap nopeer noquery
    31. restrict ntp8.cloud.aliyuncs.com nomodify notrap nopeer noquery
    32. restrict ntp9.cloud.aliyuncs.com nomodify notrap nopeer noquery
    33. server ntp1.aliyun.com iburst minpoll 4 maxpoll 10
    34. server ntp1.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
    35. server ntp10.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
    36. server ntp11.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
    37. server ntp12.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
    38. server ntp2.aliyun.com iburst minpoll 4 maxpoll 10
    39. server ntp2.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
    40. server ntp3.aliyun.com iburst minpoll 4 maxpoll 10
    41. server ntp3.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
    42. server ntp4.aliyun.com iburst minpoll 4 maxpoll 10
    43. server ntp4.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
    44. server ntp5.aliyun.com iburst minpoll 4 maxpoll 10
    45. server ntp5.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
    46. server ntp6.aliyun.com iburst minpoll 4 maxpoll 10
    47. server ntp6.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
    48. server ntp7.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
    49. server ntp8.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
    50. server ntp9.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10

4. Create a virtual image

Follow these steps to create a virtual machine image:

  1. On the RHEL virtual machine menu, select View > Snapshots.

  2. Click the + icon and create a snapshot.

    Once the snapshot is taken, the virtual machine image is created. The virtual machine image is in the qcow2 format.

Next step

Convert image to one of the supported formats