Migrating an Image of RHEL7 OS

The following explains the steps required for migrating an image to a IaaS environment when the OS of the virtual server that is operating in the migration source virtual environment is RHEL7.

About this task

Perform the following steps in the virtual environment and on the OS of the virtual server from which you are migrating the image.
Important:
  • Each of the following procedures provides an example of the command operation. The operation method may vary slightly, depending on the user's environment. Perform each operation according to the user's environment at the responsibility and decision of the user.
  • Use the console of the virtual environment for operation. Do not connect from outside, such as by using remote desktop, because doing so affects the network settings.

    Example: Start and operate the virtual machine console from VMware vSphere Client.

  • Be sure to make a backup before you change the settings of the virtual environment from which you are migrating so that you can restore it.

Procedure

  1. Uninstallation of VMware Tools

    If VMware Tools is installed on the virtual server that you intend to migrate, uninstall it.

    # vmware-uninstall-tools.pl
  2. Enabling NetworkManager

    Enable NetworkManager.

    # systemctl enable NetworkManager 
    # systemctl start NetworkManager
  3. Changing the network interface name

    Change the name of the network interface so that the settings for the network are set correctly in the environment after migration.

    1. Save /etc/default/grub.

      # cp -p /etc/default/grub /etc/default/grub.bak
    2. Edit /etc/default/grub.

      # vi /etc/default/grub

      Change the value of Add GRUB_CMDLINE_LINUX as follows.

      Before: GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet" 
      After: GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet net.ifnames=0 biosdevname=0"
    3. Apply the changes to /boot/grub2/grub.cfg.

      # grub2-mkconfig -o /boot/grub2/grub.cfg
    4. Restart the OS.

      # reboot
    5. Check that the network interface "eth0" is displayed.

      # ip addr show
    6. Save the settings file for the network interface.

      # cp -p /etc/sysconfig/network-scripts/ifcfg-eno16780032 
      /etc/sysconfig/network-scripts/org.ifcfg-eno16780032

      * The file name (ifcfg-eno16780032) above is an example.

      * Place "org." at the beginning of a file name to be saved.

    7. Change the file name of the settings file for the network interface.

      # mv /etc/sysconfig/network-scripts/ifcfg-eno16780032 
      /etc/sysconfig/network-scripts/ifcfg-eth0
    8. Edit the settings file for the network interface.

      # vi /etc/sysconfig/network-scripts/ifcfg-eth0

      Change it as follows:

      NAME=eth0 
      DEVICE=eth0

      Delete the following line if it exists.

      HWADDR=00:0c:29:e6:f2:e9

      * The above values are examples.

    9. Restart the OS.

      # reboot
    10. Check that the changes are applied to the network interface "eth0."

      # ip addr show
  4. Setting of the output destination of the boot log

    Change the GRUB setting so that the Kernel can write the boot logs to the ttyS0 device.

    1. Edit /etc/default/grub.

      # vi /etc/default/grub

      Delete "rhgb quiet" from "GRUB_CMDLINE_LINUX," and add "console=tty0 console=ttyS0,115200."

      Before: GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet net.ifnames=0 biosdevname=0" 
      After: GRUB_CMDLINE_LINUX="crashkernel=auto console=tty0 console=ttyS0,115200 net.ifnames=0 biosdevname=0"

      Append or change the definition as shown below:

      GRUB_TERMINAL="serial console" 
      GRUB_CMDLINE_LINUX_DEFAULT="console=ttyS0 modprobe.blacklist=floppy" 
      GRUB_SAVEDEFAULT=true 
      GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"
    2. Apply the changes in /etc/default/grub to /boot/grub2/grub.cfg.

      # grub2-mkconfig -o /boot/grub2/grub.cfg
    3. Restart the OS.

      # reboot
  5. Assigning a Subscription

    If you have not assigned a subscription to a virtual server, do the following:

    1. Register the server to the subscription service.

      After you have run the following command, enter the user name and password of your Red Hat account, then register the system to the subscription service.

      # subscription-manager register
    2. Check for a subscription that can be assigned.

      Check for a subscription that can be assigned which has been registered to the subscription service. After running the command shown below, take a note of the Pool ID of the subscription to be assigned.

      # subscription-manager list --available | less
    3. Assign a subscription.

      Specify the Pool ID that you took a note of in step 2, and assign a subscription to the virtual server.

      # subscription-manager subscribe --pool=<Pool ID>
  6. Installation of an SSH server

    Install an SSH server by following the procedure below.

    # yum -y install openssh-server 
    # systemctl enable sshd.service 
    # systemctl start sshd.service
    Tip: Configure the SSH service settings as necessary.
  7. Installation of cloud-init

    Install cloud-init.

    # yum -y install cloud-init --enablerepo=rhel-7-server-rh-common-rpms
  8. Unregistration of the subscription service

    Unregister the system from the subscription service.

    # subscription-manager unregister
  9. Configuring cloud.cfg

    Configure the settings of /etc/cloud/cloud.cfg.

    Configure the operational settings of cloud-init in /etc/cloud/cloud.cfg. For details on the settings, refer to the support site of cloud-init.

  10. Setting of network (DHCP connection)
    Tip: To connect a virtual server via a network using DHCP after importing the image, configure the settings shown below. When the fixed IP address is set, the same IP address is used for startup after importing the image.
    1. Change the network setting to DHCP.

      # nmcli connection modify eth0 ipv4.method auto 
      # nmcli connection modify eth0 ipv4.addresses "" ipv4.gateway ""
    2. Restart the network interface.

      # nmcli connection down eth0 
      # nmcli connection up eth0
    3. Check that the network setting is applied to "eth0."

      # cat /etc/sysconfig/network-scripts/ifcfg-eth0

      Check the following:

      • "BOOTPROTO=dhcp" is set
      • "IPADDR=" does not exist
      • "PREFIX=" does not exist
      • "GATEWAY=" does not exist
  11. Enabling of the virtio driver

    Replace initramfs with the one in which the virtio driver required for the OS start after the migration is embedded.

    1. Make a backup of initramfs.

      # cd /boot 
      # mv initramfs-3.10.0-327.el7.x86_64.img initramfs-3.10.0-327.el7.x86_64.img.bak
      * The above file name "initramfs-3.10.0-327.el7.x86_64.img" is an example.
    2. Create initramfs in which the virtio driver is embedded.

      # dracut --add-drivers 'virtio virtio_ring virtio_blk virtio_net virtio_pci'
    3. Make sure that initramfs was created successfully.

      # ls -l initramfs-3.10.0-327.el7.x86_64.img
  12. Disabling Zeroconf

    Disable Zeroconf so that the migrated virtual machine can acquire metadata.

    # vi /etc/sysconfig/network

    Add the following line.

    NOZEROCONF=yes
  13. Disabling of the firewall
    # systemctl stop firewalld 
    # systemctl disable firewalld
  14. Shutting down the OS

    Shut down the OS.

    # shutdown -h now