• Bare Metal Server

bms
  1. Help Center
  2. Bare Metal Server
  3. Private Image Creation Guide (BMS)
  4. Creating a Linux Image
  5. Configuring the VM Environment

Configuring the VM Environment

Configure the network environment for the VM so that it can connect to the Internet and installation packages can be uploaded to it.

Prerequisites

  • The host can connect to the Internet.
  • You have connected to the host using a remote desktop tool such as VNC Viewer.
  • The required installation package has been uploaded to the host.

Procedure

  1. Install Vim, dkms package, linux--headers-3.16.0-4-common, and linux-headers-3.16.0-4-amd64 (this step is required only for Debian 8.6).
    1. Install Vim.
      1. Configure the apt source.

        Run the vi /etc/apt/sources.list command and add the following content to the file:

        deb http://mirrors.ustc.edu.cn/debian jessie main contrib non-free
        deb-src http://mirrors.ustc.edu.cn/debian jessie main contrib non-free
        deb http://mirrors.ustc.edu.cn/debian jessie-proposed-updates main contrib non-free
        deb-src http://mirrors.ustc.edu.cn/debian jessie-proposed-updates main contrib non-free
        deb http://mirrors.ustc.edu.cn/debian jessie-updates main contrib non-free
        deb-src http://mirrors.ustc.edu.cn/debian jessie-updates main contrib non-free

        Enter :wq! to save the file and run the apt update command.

      2. Run the apt-get install vim command to install Vim.
    2. Install the dkms package.

      Run the apt-get install dkms command.

    3. Install the linux--headers-3.16.0-4-common package.

      Run the apt-get install linux--headers-3.16.0-4-common command.

    4. Install the linux-headers-3.16.0-4-amd64 package.

      Run the apt-get install linux-headers-3.16.0-4-amd64 command.

    5. Delete the configuration items of the /etc/network/interfaces file.

      Run the vi /etc/network/interfaces command. If there is a configuration of eth0, delete the last two rows of configuration items.

      ...
      # The loopback network interface
      auto lo
      iface lo inet loopback
      
      # The primary network interface
      # The following are the configuration items that need to be deleted:
      allow-hotplug eth0
      iface eth0 inet dhcp

      Enter :wq! to save the file.

  2. Configure the VM network.

    Configure an available IP address for the VM so that it can communicate with the host.

    1. Run the following command on the VM to query the NIC name:

      ifconfig -a

    2. Run the following command to check whether the NIC has obtained the IP address:

      ifconfig

      Information similar to the following is displayed (xxx indicates the IP address automatically obtained and XX indicates the MAC address):

      eth0     Link encap:Ethernet  HWaddr XX:XX:XX:XX:XX:XX
      inet addr:xxx.xxx.xxx.xxx  Bcast:xxx.xxx.x.xxx Mask:xxx.xxx.xxx.xxx
    3. If the NIC has not obtained the IP address, run the following command to enable the NIC to dynamically obtain the IP address (otherwise, skip this step):

      ifup NIC name

      An example is as follows:

      ifup eth0

      Information similar to the following is displayed:

      Determining IP information for eth0... done

      You can also run the following command:

      ifconfig eth0 up

      No information is displayed.

  3. Set the time parameter to prevent the BMS provision timeouts.
    • For Red Hat 7, EulerOS 2.2, EulerOS 2.3, CentOS 7, Ubuntu 16.04, SUSE 12 SP2, SUSE 12 SP3, and Debian 8.6 run the following command:

      vi /etc/systemd/system.conf

      Remove the number sign (#) before the DefaultTimeoutStartSec and DefaultTimeoutStopSec and change the time to 300s. The modified configuration file is as follows:

      #TimeSlackNSec=
      #DefaultTimerAccuracySec=1min
      #DefaultStandardOutput=journal
      #DefaultStandardError=inherit
      DefaultTimeoutStartSec=300s
      DefaultTimeoutStopSec=300s
      #DefaultRestartSec=100ms
      #DefaultStartLimitInterval=10s
      #DefaultStartLimitBurst=5
      #DefaultEnvironment=
      #DefaultCPUAccounting=no
      #DefaultBlockIOAccounting=no
  4. Disable the VM firewall (the firewall prevents remote login using SSH and must be disabled).
    • Run the following commands to disable the firewall of a Red Hat 7.0, Red Hat 7.2, Red Hat 7.3, Red Hat 7.4, Oracle Linux 7, EulerOS 2.2, EulerOS 2.3, CentOS 7.2, CentOS 7.3, CentOS 7.4, or CentOS 7.4 for ARM VM:

      systemctl disable firewalld.service

      systemctl stop firewalld.service

      Run the systemctl status firewalld.service command to query the status of the service.

    • Run the following commands to disable the firewall of a Red Hat 6.7, Red Hat 6.8, Red Hat 6.9, CentOS 6.8, CentOS 6.9, Oracle Linux 6.8, or Oracle Linux 6.9 VM:

      chkconfig iptables off

      service iptables stop

      Run the service iptables status command to query the status of the service.

      [root@localhost ~]# service iptables status
      iptables: Firewall is not running.
    • Run the following commands to disable the firewall of a SUSE 12 VM:

      systemctl disable SuSEfirewall2.service

      systemctl stop SuSEfirewall2.service

      Query the status of the service: service SuSEfirewall2 status

    • Run the following command to disable the firewall of a SUSE 11 VM:

      rcSuSEfirewall2 stop

      Run the yast command and perform the following operations:

      Choose Security and Users Firewall. Check whether Disable Firewall Automatic Starting is displayed. If yes, click Cancel and then Quit. If no, click NextFinish, and then Quit.

    • Ubuntu 16.04, Ubuntu 14.04, or Debian 8.6 has no firewall management service enabled by default, and you can download the firewall management software ufw at https://packages.ubuntu.com/.

      The deb package is as follows (the version number is only for reference):

      ufw_0.35-0ubuntu2_all.deb

      Run the following command to disable the firewall:

      ufw disable

  5. For XenServer 7.1, you need to configure the DNS server.
    1. Run the vi /etc/resolv.conf command to change the ip following nameserver to 8.8.8.8. You can set the IP address of the DNS server as needed.
    2. Run the systemctl status ntpd.service command to check the status of the ntpd service. If the ntpd service is not set to automatically start upon system startup, run the systemctl enable ntpd.service command to set it.
  6. Upgrade the wicked component (only required for SUSE 12 SP1).
    1. Run the rpm -ivh --nodeps --force *rpm command to install the wicked software package forcibly.
    2. Check the wicked software packages that have been installed.
      linux-locc:/home/fsp/Desktop # rpm -qa | grep wick
      wicked-service-0.6.28-1.1.x86_64
      libwicked-0-6-0.6.28-1.1.x86_64
      libwicked-0-6-0.6.40-28.6.1.x86_64
      wicked-0.6.28-1.1.x86_64
      wicked-service-0.6.40-28.6.1.x86_64
      wicked-0.6.40-28.6.1.x86_64
    3. Uninstall wicked software packages of old versions.
      linux-locc:/home/fsp/Desktop # rpm -e wicked-service-0.6.28-1.1.x86_64
      linux-locc:/home/fsp/Desktop # rpm -e libwicked-0-6-0.6.28-1.1.x86_64
      linux-locc:/home/fsp/Desktop # rpm -e wicked-0.6.28-1.1.x86_64
  7. Disable the network management tool of the VM (the network management tool may conflict with the network-config configuration and must be disabled). Skip this step for SUSE 11 SP4, Ubuntu 16.04 and Ubuntu 14.04.
    • Run the following commands to disable the network management service of a Red Hat 7, Oracle Linux 7, Debian 8.6, EulerOS 2.2, EulerOS 2.3, CentOS 7.2, CentOS 7.3, CentOS 7.4 VM, or CentOS 7.4 for ARM:

      systemctl disable NetworkManager.service

      systemctl stop NetworkManager.service

      Query the status of the service: service NetworkManager.service status

      [root@localhost ~]# service NetworkManager.service status
      edirecting to /bin/systemctl status NetworkManager.service
       NetworkManager.service - Network Manager
        Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service disabled; vendor preset: enabled)
        Active: inactive (dead) since Mon 2017-11-13 19:06:18 CST; 1 min 17s ago

      For EulerOS 2.2 and EulerOS 2.3, disable the following services if they are running:

      Systemctl disable euleros-security

      Systemctl disable NetworkManager-wait-online

    • Run the following commands in turn to disable the network management service of a Red Hat 6.7, Red Hat 6.8, Red Hat 6.9, CentOS 6.8, CentOS 6.9, Oracle Linux 6.8 or Oracle Linux 6.9 VM:
      NOTE:

      If you choose to install the desktop when creating a Red Hat 6.7, Red Hat 6.8, Red Hat 6.9, CentOS 6.8, CentOS 6.9, Oracle Linux 6.8 or Oracle Linux 6.9 VM, you need to run the following command to disable the network service. Otherwise, do not run these commands.

      service NetworkManager stop

      chkconfig NetworkManager off

    • Run the following commands to disable the network management service of a SUSE 12 VM:

      systemctl disable wicked

      systemctl stop wicked

  8. (Optional) Delete the VM local user.

    When installing the VM, you need to create a local user. After the installation is complete, you can delete the local user by running the following command:

    userdel -rf xxx

    xxx is the name of the local user. The user is deleted successfully if the /home directory does not contain the folder of the user.

    NOTE:

    If the user is not deleted, restart the VM, log in to it as user root, and run the command again.

  9. (Optional) Modify DHCP configuration items.
    NOTE:

    This operation is required for SUSE Linux. For other OSs, skip this step.

    1. Open the command-line interface and run the su - root command to switch to user root.
    2. Run the vi /etc/sysconfig/network/dhcp command to open the target configuration file using the vi editor.
    3. Enter ?DHCLIENT_PRIMARY_DEVICE and press Enter to locate the configuration item.

      Press i to enter editing mode and set the value of this configuration item to yes to enable DHCP to obtain the default gateway during start.

      Press Esc to exit editing mode.

      NOTE:

      If the configuration file does not contain the DHCLIENT_PRIMARY_DEVICE configuration item, ignore it.

    4. Enter ?DHCLIENT_SET_HOSTNAME and press Enter to locate the configuration item.

      Press i to enter editing mode and set the value of this configuration item to no to prevent DHCP from modifying the hostname.

      Press Esc to exit the editing mode.

    5. Enter ?DHCLIENT_USE_LAST_LEASE and press Enter to locate the configuration item.

      Press i to enter editing mode and set the value of this configuration item to no to enable DHCP to obtain IP addresses continuously.

      Press Esc to exit the editing mode.

    6. Enter ?DHCLIENT6_MODE and press Enter to locate the configuration item.

      Press i to enter editing mode and set the value of this configuration item to managed to enable DHCP to obtain IP addresses continuously.

      Press Esc to exit the editing mode.

    7. Enter :wq and press Enter to save the change and exit.
  10. (Optional) For Ubuntu 14.04 or Debian 8.6, you need to set the timeout parameter for the GRUB configuration file to prevent failure to access the system due to abnormal server power-off.
    1. Use the vi editor to open /etc/default/grub and add GRUB_RECORDFAIL_TIMEOUT=10 after GRUB_CMDLINE_LINUX.
      GRUB_DEFAULT=0
      #GRUB_HIDDEN_TIMEOUT=0
      GRUB_HIDDEN_TIMEOUT_QUIET=true
      GRUB_TIMEOUT=2
      GRUB_DISTRIBUTOR='lsb_release -i -s 2> /dev/null || echo Debian'
      GRUB_CMDLINE_LINUX_DEFAULT=""
      GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0"
      GRUB_RECORDFAIL_TIMEOUT=10
    2. Run the following command to update the configuration:

      grub-mkconfig -o /boot/grub/grub.cfg

  11. Upload the required software package to the VM.
    • Method 1: If the VM can communicate with the host, run the scp command to upload the software package to the VM.

      This method is recommended. You can query how to use it by running the scp -help command. An example command is as follows (the following file name is an example):

      scp fsp@xxx.xxx.xxx.xxx:/home/fsp/network-config-1.0-1.x86_64.rpm /home

      NOTE:

      In the command, fsp is the username, xxx.xxx.xxx.xxx is the host IP address, home/fsp is a customized directory, network-config-1.0-1.x86_64.rpm is the name of the file uploaded to the host, and /home is the VM directory.

    • Method 2: If the VM can communicate with the host and you can log in to the VM using Xshell, you can upload the package to the VM using xftp.
    • Method 3: If the VM cannot communicate with the host, use the virtual CD-ROM drive to mount the software package.

      Step 1: Create an ISO file on the host.

      • Run the mkdir /root/software command to create a directory.
      • Place the network-config and SDI card driver software packages in the created directory.
      • Run the cd /root command and then the mkisofs -L -R -J -T -V system-sp2 -o defindsoftware.iso /root/software command.
      • Run the ll command. defindsoftware.iso shown in the command output is the generated ISO image file.

      Step 2: Use virt-manager to mount the ISO image.

      1. On the VM, choose View > Details.
      2. Click IDE CDROM 1 and click Connect in the right area. If a disk has been mounted, click Disconnect.

      3. Click Browse Local and select /root in which the ISO image is created.
      4. Double-click the created ISO image defindsoftware.iso and click OK in the displayed dialog box.

      5. Choose View Console and select the VM that is being operated.
      6. Run the lsblk command to check whether the ISO image is mounted, such as to /run/media/suse/system-sp2.
      7. Run the cd /run/media/suse/system-sp2 command to copy the files in the directory to another directory, such as /home. If the mount point has no file directory, you need to run the mount /dev/sr0 /home command to mount the ISO image file to the /home directory (for example).