To guarantee that you can successfully start the Virtual Machine after importing the private image, virtio drivers must be compiled in kernel or compiled as kernel module. You must ensure the system has been correctly installed virtio drivers before importing image.
Take CentOS7 series image for example to describe how to confirm that virtio drivers have been correctly installed in current system.
① Run the following commands to check if the server kernel supports virtio drivers:
grep -i virtio /boot/config-$(uname -r)
CONFIG_VIRTIO_BLK
and CONFIG_VIRTIO_NET
is y, it means that drivers have been compiled in kernel and it is unnecessary to execute the following operations, and you can import.CONFIG_VIRTIO_BLK
and CONFIG_VIRTIO_NET
is m, it means that drivers have been compiled as kernel module. Please execute the following operation "②" to confirm whether virtio_blk drivers are included in initramfs (or initrd) files. If not, you need to produce the file again.VIRTIO_BLK
and VIRTIO_NET
in the output information, it means that relevant virtio drivers are not installed in this operating system and you need to compile and install virtio drivers. Please execute the following "③".② Execute the following commands to confirm whether virtio drivers are included in the temporary file system initramfs or initrd (for Ubuntu system, please replace initramfs with initrd):
lsinitrd /boot/initramfs-$(uname -r).img | grep virtio
If initramfs has already included virtio_blk
drivers and virtio.ko
, virtio_pci.ko
and virtio_ring.ko
on which they depend, it is unnecessary to execute the following operations.
If there is no information of virtio in initramfs, you need to repair the temporary file system:
A. CentOS 7/6
cp /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.bak mkinitrd -f --with=virtio_blk --with=virtio_pci /boot/initramfs-$(uname -r).img $(uname -r)
echo -e "virtio_pci\nvirtio_blk" >> /etc/initramfs-tools/modules update-initramfs -u
③ Compile and install virtio drivers:
A. Download kernel installation package
yum install -y ncurses-devel gcc make wget
uname -r
cd /usr/src/ wget https://mirrors.edge.kernel.org/pub/linux/kernel/v3.0/linux-3.10.tar.gz tar -zxvf linux-3.10.tar.gz
ln -s linux-3.10 linux
cd /usr/src/linux
make mrproper
make menuconfig
Select Virtio block driver in Device Drivers-->Block devices
Select Virtio network driver in Device Drivers-->Network device support
make bzImage && make modules && make modules_install
make install
find /lib/modules/"$(uname -r)"/ -name "virtio.*" | grep -E "virtio.*"
① Go to Download iso Format virtio Software Package (take virtio-win-0.1.137.iso for example), various device drivers are included in iso files, such as network interface drivers (NetKVM), Disk drivers (virtsor), etc.
② Copy the virtio-win-0.1.137.iso file to a directory in Windows virtual machines. You can copy ios files to the virtual machines by means of remote connecting sharing folder.
③ Double click iso files and Windows will automatically mount them to DVD devices to read data. The right-side folder in the figure below is contents in iso software package, including various device drivers, e.g. NetKVM is a network interface driver.
④ Find and open the "Device Manager" window in the control panel and you only need to install the following three set drivers:
Open device manager. You will find three devices with yellow exclamation mark indicating no installed drivers, including one SCSI Controller device, one network interface and one PCI simple communication device, as shown in the figure below.
⑤ Install the storage controller drivers first and click to select Update Driver Software. In the pop-up window, click Browse Computer to Find Driver Software and then locate to 2k12R2/amd64/folder (Windows Server 2012R2) in "viostor" directory in DVD driver in the pop-up window. Click OK button and then click Next till this driver is installed according to the commands. If the system notifies of reboot, please select Reboot Later. After the three drivers are installed, consider reboot operation again.
⑥ Install network interface drivers and click to select Update Driver Software. In the pop-up window, click Browse Computer to Find Driver Software and then locate to NetKVM/2k12R2/amd64/folder in DVD driver in the pop-up window. Click OK and complete the installation according to notifications.
⑦ Install serial drivers and click to select Update Driver Software. In the pop-up window, click Browse Computer to Find Driver Software and then locate to vioserial/2k12R2/amd64/folder in DVD driver in the pop-up window. Click OK and complete the installation according to notifications.
⑧ Reboot system.
⑨ Open "Device Manager" and check the version number of the three drivers we installed: In the examples in our documents, the target version number is the figure character string ending with 13700.
⑩ Clean up configuration information. This step is distinctly important. Open the command line window or powershell running window and execute the following command:
c:\windows\system32\Sysprep\sysprep.exe /generalize /oobe /shutdown
It should be specially noted that the system shall be rebooted after uninstallation and installation to guarantee the effect of updated drivers.