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
- Install Vim, dkms package, linux--headers-xxx-common, and linux-headers-xxx-amd64 (this step is required only for Debian).
- Install Vim.
- Configure the apt source.
Run the vi /etc/apt/sources.list command to add the apt source. The content to be added varies depending on the Debian version. For example, the content to be added for Debian 8.6 is as follows:
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.
- Run the apt-get install vim command to install Vim.
- Configure the apt source.
- Run the apt-get install dkms command to install the dkms package.
- Run the apt-get install linux--headers-xxx-common command to install the linux--headers-xxx-common package.
xxx indicates the kernel version. For example, for Debain 8.6 whose kernel version is 3.16.0-4, run the apt-get install linux--headers-3.16.0-4-common command.
- Run the apt-get install linux-headers-xxx-amd64 command to install the linux-headers-xxx-amd64 package.
xxx indicates the kernel version. For example, for Debain 8.6 whose kernel version is 3.16.0-4, run the apt-get install linux-headers-3.16.0-4-amd64 command.
- 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.
- Install Vim.
- Configure the VM network.
Configure an available IP address for the VM so that it can communicate with the host.
- Run the following command on the VM to query the NIC name:
- Run the following command to check whether the NIC has obtained the IP address:
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
- 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):
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.
- Set the time parameter to prevent the BMS provision timeouts.
- For Red Hat 7, EulerOS, CentOS 7, Oracle Linux 7, Ubuntu 16.04, SUSE 12 SP2, SUSE 12 SP3, and Debian run the following command:
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
- For Red Hat 7, EulerOS, CentOS 7, Oracle Linux 7, Ubuntu 16.04, SUSE 12 SP2, SUSE 12 SP3, and Debian run the following command:
- 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, or CentOS 7 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:
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:
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 Next, Finish, and then Quit.
- Ubuntu 16.04, Ubuntu 14.04, or Debian 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
- 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, or CentOS 7 VM:
- For XenServer 7.1, you need to configure the DNS server.
- 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.
- 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.
- Upgrade the wicked component (only required for SUSE 12 SP1).
- Run the rpm -ivh --nodeps --force *rpm command to install the wicked software package forcibly.
- 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
- 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
- Disable the network management tool of the VM (the network management tool may conflict with the network-config configuration and must be disabled).
You do not need to perform this step for the VMs running SUSE 11 SP4, Ubuntu 16.04, or Ubuntu 14.04. Also, you do not need to perform this step for the VMs with SDI 3.0 cards (integrating storage with networking) or SDI 2.2 iNICs because such VMs use NetworkManager to manage networks.
- Run the following commands to disable the network management service of a Red Hat 7, Oracle Linux 7, Debian, EulerOS, or CentOS 7 VM:
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, 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:
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 stop wicked
- Run the following commands to disable the network management service of a Red Hat 7, Oracle Linux 7, Debian, EulerOS, or CentOS 7 VM:
- (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.
If the user is not deleted, restart the VM, log in to it as user root, and run the command again.
- (Optional) Modify DHCP configuration items.
This operation is required for SUSE Linux. For other OSs, skip this step.
- Open the command-line interface and run the su - root command to switch to user root.
- Run the vi /etc/sysconfig/network/dhcp command to open the target configuration file using the vi editor.
- 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.
If the configuration file does not contain the DHCLIENT_PRIMARY_DEVICE configuration item, ignore it.
- 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.
- 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.
- 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.
- Enter :wq and press Enter to save the change and exit.
- (Optional) For Ubuntu 14.04 or Debian, 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.
- 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
- Run the following command to update the configuration:
- Use the vi editor to open /etc/default/grub and add GRUB_RECORDFAIL_TIMEOUT=10 after GRUB_CMDLINE_LINUX.
- 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
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 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.
- On the VM, choose View > Details.
- Click IDE CDROM 1 and click Connect in the right area. If a disk has been mounted, click Disconnect.

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

- Choose View > Console and select the VM that is being operated.
- Run the lsblk command to check whether the ISO image is mounted, such as to /run/media/suse/system-sp2.
- 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).
- Method 1: If the VM can communicate with the host, run the scp command to upload the software package to the VM.
Last Article: Modifying the Boot File (UEFI Boot Mode)
Next Article: Installing Cloud-Init
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.