Prerequisite
Prerequisite
initramfs or initrd.Procedure
Run vi /etc/dracut.conf to open the /etc/dracut.conf file.
Press i to switch to the insert mode, and then edit as follows to add VirtIO drivers to the add_drivers item. You can adjust the command format according to the actual system requirements.
[root@localhost ~]# vi /etc/dracut.conf
# additional kernel modules to the default
add_drivers+="virtio_blk virtio_scsi virtio_net virtio_pci virtio_ring virtio" Note:
Press Esc, enter :wq, and then press Enter. The system will save the change and exit the /etc/dracut.conf file.
Run the following command to regenerate initrd:
dracut -f /boot/initramfs-`uname -r`.imgNote:
The symbols on both sides of
uname -rin the command are backquotes (`).
If the initial root filesystem is not the default initramfs, run the following command instead:
dracut -f <name>Replace <name> with the actual initramfs or initrd file name, which can be acquired from the grub.cfg file. You can find the grub.cfg file in the path /boot/grub/grub.cfg, /boot/grub2/grub.cfg or /boot/grub/grub.conf, depending on different operating systems.
Check whether the VirtIO driver modules have been added successfully.
If the initial root filesystem is initramfs, run the following command:
lsinitrd /boot/initramfs-`uname -r`.img | grep virtioIf the initial root filesystem is initrd, run the following command:
lsinitrd /boot/initrd-`uname -r` | grep virtioTaking the initramfs filesystem as an example, the output will be:
[root@localhost ~]# lsinitrd /boot/initramfs-`uname -r`.img | grep virtio
-rwxr--r-- 1 root root 23448 Nov 1 10:58 lib/modules/2.6.32-573.8.1.el6.x86_64/kernel/drivers/block/virtio_blk.ko
-rwxr--r-- 1 root root 50704 Nov 1 10:58 lib/modules/2.6.32-573.8.1.el6.x86_64/kernel/drivers/net/virtio_net.ko
-rwxr--r-- 1 root root 28424 Nov 1 10:58 lib/modules/2.6.32-573.8.1.el6.x86_64/kernel/drivers/scsi/virtio_scsi.ko
drwxr-xr-x 2 root root 0 Nov 1 10:58 lib/modules/2.6.32-573.8.1.el6.x86_64/kernel/drivers/virtio
-rwxr--r-- 1 root root 14544 Nov 1 10:58 lib/modules/2.6.32-573.8.1.el6.x86_64/kernel/drivers/virtio/virtio.ko
-rwxr--r-- 1 root root 21040 Nov 1 10:58 lib/modules/2.6.32-573.8.1.el6.x86_64/kernel/drivers/virtio/virtio_pci.ko
-rwxr--r-- 1 root root 18016 Nov 1 10:58 lib/modules/2.6.32-573.8.1.el6.x86_64/kernel/drivers/virtio/virtio_ring.ko Note that the above output is only an example. If there are virtio_net, virtio_blk and virtio_scsi modules in the output, then all VirtIO driver modules have been added successfully.
Shut down the virtual machine, and set both its bus type and NIC mode to VIRTIO, and then reboot it. Once finished, try accessing the operating system. If the access is successful, then all the VirtIO drivers have been installed.
Prerequisite
The operating system should meet the following requirements:
Procedure
Run vi /etc/initramfs-tools/modules to open the /etc/initramfs-tools/modules file.
Press i to switch to the insert mode, and edit as follows to add VirtIO drivers. You can adjust the command format according to the actual system requirements.
[root@localhost ~]#vi /etc/initramfs-tools/modules
……
# Examples:
#
# raid1
# sd_mOd
virtio_blk
virtio_scsi
virtio_net
virtio_pci
virtio_ring
virtioPress Esc, enter :wq, and then press Enter. The system will save the change and exit the /etc/initramfs-tools/modules file.
Run update-initramfs -u to regenerate initrd.
Run the following command to check whether VirtIO driver modules have been added successfully:
lsinitramfs /boot/initrd.img-`uname -r` |grep virtioNote:
The symbols on both sides of
uname -rin the command are backquotes (`).
If successful, the output will be:
[root@localhost ~]# lsinitramfs /boot/initrd.img-`uname -r` |grep virtio
-rwxr--r-- 1 root root 19248 Jun 22 2012 lib/modules/2.6.32-279.el6.x86_64/kernel/drivers/scsi/virtio_scsi.ko
-rwxr--r-- 1 root root 23856 Jun 22 2012 lib/modules/2.6.32-279.el6.x86_64/kernel/drivers/block/virtio_blk.ko
drwxr-xr-x 2 root root 0 Jul 12 14:53 lib/modules/2.6.32-279.el6.x86_64/kernel/drivers/virtio
-rwxr--r-- 1 root root 15848 Jun 22 2012 lib/modules/2.6.32-279.el6.x86_64/kernel/drivers/virtio/virtio_ring.ko
-rwxr--r-- 1 root root 20008 Jun 22 2012 lib/modules/2.6.32-279.el6.x86_64/kernel/drivers/virtio/virtio_pci.ko
-rwxr--r-- 1 root root 12272 Jun 22 2012 lib/modules/2.6.32-279.el6.x86_64/kernel/drivers/virtio/virtio.ko
-rwxr--r-- 1 root root 38208 Jun 22 2012 lib/modules/2.6.32-279.el6.x86_64/kernel/drivers/net/virtio_net.koNote that the above output is only an example. If there are virtio_net, virtio_blk and virtio_scsi modules in the output, then all VirtIO driver modules have been added successfully.
Shut down the virtual machine, and set both its bus type and NIC mode to VIRTIO, and then reboot it. Once finished, try accessing the operating system. If the access is successful, then all the VirtIO drivers have been installed.
Prerequisite
initramfs or initrd.Run vi /etc/sysconfig/kernel to open the /etc/sysconfig/kernel file.
Press i to switch to the insert mode, and edit as follows to add VirtIO drivers to INITRD_MODULES item. You can adjust the command format according to the actual system requirements. Once finished, save the change and exit the file.
[root@localhost ~]# vi /etc/sysconfig/kernel
# (like drivers for scsi-controllers, for lvm or reiserfs)
#
INITRD_MODULES="ata_piix ata_generic virtio_blk virtio_scsi virtio_net virtio_pci virtio_ring virtio"Press Esc, enter :wq, and then press Enter. The system will save the change and exit the /etc/sysconfig/kernel file.
Run mkinitrd to regenerate initrd.
Note:
If the initial root filesystem is not the default
initramfsorinitrd, run thedracut -f <Actual name of the initramfs or initrd file>command instead. You can find themenu.lstorgrub.cfgfile in the path/boot/grub/menu.lst,/boot/grub/grub.cfg, or/boot/grub2/grub.cfg.
The following is an example initrd file of SUSE 11 SP4:
default 0
timeout 10
gfxmenu (hd0,0)/boot/message
title sles11sp4_001_[_VMX_]
root (hd0,0)
kernel /boot/linux.vmx vga=0x314 splash=silent console=ttyS0,115200n8 console=tty0 net.ifnames=0 NON_PERSISTENT_DEVICE_NAMES=1 showopts
initrd /boot/initrd.vmx
title Failsafe_sles11sp4_001_[_VMX_]
root (hd0,0)
kernel /boot/linux.vmx vga=0x314 splash=silent ide=nodma apm=off noresume edd=off powersaved=off nohz=off highres=off processsor.max+cstate=1 nomodeset x11failsafe console=ttyS0,115200n8 console=tty0 net.ifnames=0 NON_PERSISTENT_DEVICE_NAMES=1 showopts
initrd /boot/initrd.vmxReplace the /boot/initrd.vmx in the initrd line with the initrd file actually used, that is, you should run dracut -f /boot/initrd.vmx. If the initrd file does not contain the /boot directory, such as /initramfs-xxx, you need to add the /boot directory when you run the command, that is, you should run dracut -f /boot/initramfs-xxx.
Check whether the initial root filesystem has added the VirtIO driver modules successfully.
If the initial root filesystem is initramfs, run the following command:
lsinitrd /boot/initramfs-`uname -r`.img | grep virtioNote:
The symbols on both sides of
uname -rin the command are backquotes (`).
If the initial root filesystem is initrd, run the following command:
lsinitrd /boot/initrd-`uname -r` | grep virtioTaking the initrd filesystem as an example, the output will be:
[root@localhost ~]# lsinitrd /boot/initrd-`uname -r` | grep virtio
-rwxr--r-- 1 root root 19248 Jun 22 2012 lib/modules/2.6.32-279.el6.x86_64/kernel/drivers/scsi/virtio_scsi.ko
-rwxr--r-- 1 root root 23856 Jun 22 2012 lib/modules/2.6.32-279.el6.x86_64/kernel/drivers/block/virtio_blk.ko
drwxr-xr-x 2 root root 0 Jul 12 14:53 lib/modules/2.6.32-279.el6.x86_64/kernel/drivers/virtio
-rwxr--r-- 1 root root 15848 Jun 22 2012 lib/modules/2.6.32-279.el6.x86_64/kernel/drivers/virtio/virtio_ring.ko
-rwxr--r-- 1 root root 20008 Jun 22 2012 lib/modules/2.6.32-279.el6.x86_64/kernel/drivers/virtio/virtio_pci.ko
-rwxr--r-- 1 root root 12272 Jun 22 2012 lib/modules/2.6.32-279.el6.x86_64/kernel/drivers/virtio/virtio.ko
-rwxr--r-- 1 root root 38208 Jun 22 2012 lib/modules/2.6.32-279.el6.x86_64/kernel/drivers/net/virtio_net.koNote that the above output is only an example. If there are virtio_net, virtio_blk and virtio_scsi modules in the output, then all VirtIO driver modules have been added successfully.
Shut down the virtual machine, and set both its bus type and NIC mode to VIRTIO, and then reboot it. Once finished, try accessing the operating system. If the access is successful, then all the VirtIO drivers have been installed.
Run vi /etc/dracut.conf to open the /etc/dracut.conf file.
Press i to switch to the insert mode, and edit as follows to add VirtIO drivers to add_drivers. You can adjust the command format according to the actual system requirements.
[root@localhost ~]# vi /etc/dracut.conf
# additional kernel modules to the default
add_drivers+="ata_piix ata_generic virtio_blk virtio_scsi virtio_net virtio_pci virtio_ring virtio"Press Esc, enter :wq, and then press Enter. The system will save the change and exit the /etc/dracut.conf file.
Run the following command to regenerate initrd.
dracut -f /boot/initramfs-`uname -r`.imgNote:
The symbols on both sides of
uname -rin the command are backquotes (`).
If the initial root filesystem is not the default initramfs, run the following command instead:
dracut -f <name>Replace <name> with the actual initramfs or initrd file name, which can be acquired from the grub.cfg file. You can find the grub.cfg file in the path /boot/grub/grub.cfg, /boot/grub2/grub.cfg or /boot/grub/grub.conf, depending on different operating systems.
Check whether the initial root filesystem has added the VirtIO driver modules successfully.
If the initial root filesystem is initramfs, run the following command:
lsinitrd /boot/initramfs-`uname -r`.img | grep virtioIf the initial root filesystem is initrd, run the following command:
lsinitrd /boot/initrd-`uname -r` | grep virtioTaking the initrd filesystem as an example, the output will be:
[root@localhost ~]# lsinitrd /boot/initrd-`uname -r` | grep virtio
-rw-r--r-- 1 root root 29335 Oct 26 2016 lib/modules/4.4.21-69-default/kernel/drivers/block/virtio_blk.ko
-rw-r--r-- 1 root root 57007 Oct 26 2016 lib/modules/4.4.21-69-default/kernel/drivers/net/virtio_net.ko
-rw-r--r-- 1 root root 32415 Oct 26 2016 lib/modules/4.4.21-69-default/kernel/drivers/scsi/virtio_scsi.ko
drwxr-xr-x 2 root root 0 Sep 28 10:21 lib/modules/4.4.21-69-default/kernel/drivers/virtio
-rw-r--r-- 1 root root 19623 Oct 26 2016 lib/modules/4.4.21-69-default/kernel/drivers/virtio/virtio.ko
-rw-r--r-- 1 root root 38943 Oct 26 2016 lib/modules/4.4.21-69-default/kernel/drivers/virtio/virtio_pci.ko
-rw-r--r-- 1 root root 24431 Oct 26 2016 lib/modules/4.4.21-69-default/kernel/drivers/virtio/virtio_ring.koNote that the above output is only an example. If there are virtio_net, virtio_blk and virtio_scsi modules in the output, then all VirtIO driver modules have been added successfully.
Shut down the virtual machine, and set both its bus type and NIC mode to VIRTIO, and then reboot it. Once finished, try accessing the operating system. If the access is successful, then all the VirtIO drivers have been installed.
Run vi /etc/dracut.conf to open the /etc/dracut.conf file.
Press i to switch to the insert mode, and edit as follows to add VirtIO drivers to add_drivers. You can adjust the command format according to the actual system requirements.
[root@localhost ~]# vi /etc/dracut.conf
# additional kernel modules to the default
add_drivers+="ata_piix ata_generic virtio_blk virtio_scsi virtio_net virtio_pci virtio_ring virtio"Press Esc, enter :wq, and then press Enter. The system will save the change and exit the /etc/dracut.conf file.
Run the following command to regenerate initrd.
dracut -f /boot/initramfs-`uname -r`.imgNote:
The symbols on both sides of
uname -rin the command are backquotes (`).
If the initial root filesystem is not the default initramfs, run the following command instead:
dracut -f <name>Replace <name> with the actual initramfs or initrd file name, which can be acquired from the grub.cfg file. You can find the grub.cfg file in the path /boot/grub/grub.cfg, /boot/grub2/grub.cfg or /boot/grub/grub.conf, depending on different operating systems.
Check whether the initial root filesystem has added the VirtIO driver modules successfully.
If the initial root filesystem is initramfs, run the following command:
lsinitrd /boot/initramfs-`uname -r`.img | grep virtioIf the initial root filesystem is initrd, run the following command:
lsinitrd /boot/initrd-`uname -r` | grep virtioTaking the initrd filesystem as an example, the output will be:
[root@localhost ~]# lsinitrd /boot/initrd-`uname -r` | grep virtio
-rw-r--r-- 1 root root 29335 Oct 26 2016 lib/modules/4.4.21-69-default/kernel/drivers/block/virtio_blk.ko
-rw-r--r-- 1 root root 57007 Oct 26 2016 lib/modules/4.4.21-69-default/kernel/drivers/net/virtio_net.ko
-rw-r--r-- 1 root root 32415 Oct 26 2016 lib/modules/4.4.21-69-default/kernel/drivers/scsi/virtio_scsi.ko
drwxr-xr-x 2 root root 0 Sep 28 10:21 lib/modules/4.4.21-69-default/kernel/drivers/virtio
-rw-r--r-- 1 root root 19623 Oct 26 2016 lib/modules/4.4.21-69-default/kernel/drivers/virtio/virtio.ko
-rw-r--r-- 1 root root 38943 Oct 26 2016 lib/modules/4.4.21-69-default/kernel/drivers/virtio/virtio_pci.ko
-rw-r--r-- 1 root root 24431 Oct 26 2016 lib/modules/4.4.21-69-default/kernel/drivers/virtio/virtio_ring.koNote that the above output is only an example. If there are virtio_net, virtio_blk and virtio_scsi modules in the output, then all VirtIO driver modules have been added successfully.
Shut down the virtual machine, and set both its bus type and NIC mode to VIRTIO, and then reboot it. Once finished, try accessing the operating system. If the access is successful, then all the VirtIO drivers have been installed.