Migrating an Image of CentOS 7

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 CentOS 7.

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. Installing cloud-init

    Install cloud-init by following the procedure below.

    1. Obtaining cloud-init

      Obtain the cloud-init module provided by FUJITSU from the service desk. Use the latest package that is provided.

    2. Installing cloud-init

      # yum -y install --enablerepo=* --disablerepo=c7-media 
       /var/tmp/cloud-init-0.7.5-10.el7.FJ.20160406.noarch.rpm cloud-utils
      Tip: Replace the name of the storage destination of the cloud-init module and the file name with the names that are in use in your environment.
    3. Checking of cloud-init

      Check if cloud-init provided by Fujitsu is installed successfully.

      # rpm -qi cloud-init

      The following shows a display example that appears when cloud-init provided by Fujitsu is installed successfully.

      # rpm -qi cloud-init 
      Name        : cloud-init 
                <--omitted-->
      Packager    : FUJITSU LIMITED 
      Vendor      : FUJITSU LIMITED 
                <--omitted-->

      If cloud-init provided by Fujitsu is not installed, reinstall it, and then check whether the installation was successful.

      # rpm -e cloud-init 
      # rpm -q cloud-init 
      # rm -rf /var/lib/cloud 
      # rpm -ivh /var/tmp/cloud-init-0.7.5-10.el7.FJ.20160406.noarch.rpm 
      # rpm -qi cloud-init
  3. Setting of the output destination of the boot log

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

    1. Save /etc/default/grub.

      # cp -p /etc/default/grub /etc/default/grub.bak
    2. Edit /etc/default/grub and add the definition that enables the Kernel to write boot logs to the ttyS0 device to grub.

      # vi /etc/default/grub

      Append or change the definition as shown below:

      GRUB_TERMINAL="serial console" 
      GRUB_CMDLINE_LINUX_DEFAULT="console=ttyS0" 
      GRUB_SAVEDEFAULT=true 
      GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"

      Change the value of GRUB_CMDLINE_LINUX as follows.

      Before: GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet" 
      After: GRUB_CMDLINE_LINUX="crashkernel=auto console=tty0 console=ttyS0,115200"
    3. Apply the changes to /boot/grub2/grub.cfg.

      # grub2-mkconfig -o /boot/grub2/grub.cfg
  4. 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. Enable NetworkManager.

      # yum -y install NetworkManager 
      # systemctl enable NetworkManager 
      # systemctl start NetworkManager
    2. Modify the setting of /etc/sysconfig/network-scripts/ifcfg-<network interface name> as follows.

      ONBOOT=yes 
      BOOTPROTO=dhcp
    3. Restart the network.

      # systemctl restart NetworkManager
  5. Changing the network interface name
    1. Copy the network interface configuration from /etc/sysconfig/network-scripts/ifcfg-<network interface name>.

      # cd /etc/sysconfig/network-scripts 
      # cp ifcfg-eno16780032 ifcfg-eth0

      * The source file name (ifcfg-eno16780032) is an example and varies depending on the environment.

    2. Change the configuration name and the device name in the network interface configuration that you duplicated.

      Change the values in Ifcfg-eth0 to "NAME=eth0" and "DEVICE=eth0."

      * You can also write them in the format of "NAME="eth0"" and "DEVICE="eth0"."

    3. Edit /etc/default/grub.

      # vi /etc/default/grub

      Change the value of GRUB_CMDLINE_LINUX as follows.

      Before: GRUB_CMDLINE_LINUX="crashkernel=auto console=tty0 console=ttyS0,115200" 
      After: GRUB_CMDLINE_LINUX="crashkernel=auto console=tty0 console=ttyS0,115200 net.ifnames=0"
    4. Apply the changes in /etc/default/grub to /boot/grub2/grub.cfg.

      # grub2-mkconfig -o /boot/grub2/grub.cfg
  6. Deletion of the MAC address
    1. Delete the information specific to the network interface from /etc/sysconfig/network-scripts/ifcfg-eth0.

      Delete the lines with "UUID=" and "HWADDR=."

    2. Restart the OS.

      # reboot
  7. Disabling Zeroconf

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

    # vi /etc/sysconfig/network

    Add the following line.

    NOZEROCONF=yes
  8. Disabling of the firewall
    # systemctl stop firewalld 
    # systemctl disable firewalld
  9. 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
  10. 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.

  11. Shutting down the OS

    Shut down the OS.

    # shutdown -h now