To run in Tencent Cloud, a CVM must have a kernel supporting virtio drivers, including the block device driver virtio_blk
and the NIC driver virtio_net
. To ensure that a CVM created with a custom image can start up properly, please check whether your image support virtio drivers in the source server before importing the image. This document uses CentOS as an example to describe how to check if an image supports virtio drivers.
Execute the following command to check whether the current kernel supports virtio drivers:
grep -i virtio /boot/config-$(uname -r)
A response similar to the following will be returned:
CONFIG_VIRTIO_BLK
and CONFIG_VIRTIO_NET
is m
in the response,please go to Step 2.CONFIG_VIRTIO_BLK
and CONFIG_VIRTIO_NET
is y
in the response, which means the OS contains the virtio dirvers, you can import the custom image to Tencent Cloud. For details, see Import Images > Overview.CONFIG_VIRTIO_BLK
and CONFIG_VIRTIO_NET
in the response, it means that images with the OS cannot be imported to Tencent Cloud. Please download and compile kernel.
If the value of the parameters is m
in Step 1, you need to check whether initramfs
or initrd
contains the virtio
drivers. Please execute the corresponding command according to the operating system:
lsinitrd /boot/initramfs-$(uname -r).img | grep virtio
mkdir -p /tmp/initrd && cd /tmp/initrd
zcat /boot/initrd-$(uname -r).img | cpio -idmv
find . -name "virtio*"
lsinitramfs /boot/initrd.img-$(uname -r) | grep virtio
If a result similar to the following is returned:
It means that initramfs
contains the virtio_blk
driver and virtio.ko
, virtio_pci.ko
, and virtio_ring.ko
on which the driver depends. In this case, you can import the custom image to Tencent Cloud. For details, see Import Images > Overview.
If initramfs
or initrd
does not contain the virtio
drivers, please go to Step 3.
If you find that initramfs
or initrd
does not contain the virtio
drivers in [Step 2]](#CheckVirtioForInitramfs), you will need to reconfigure the temporary file system to make sure that initramfs
or initrd
contains the virtio
drivers. Please execute the corresponding command according to the operating system:
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)
cp /boot/initrd-$(uname -r).img /boot/initrd-$(uname -r).img.bak
mkinitrd -f --with=virtio_blk --with=virtio_pci /boot/initrd-$(uname -r).img $(uname -r)
echo -e "virtio_pci\nvirtio_blk" >> /etc/initramfs-tools/modules
update-initramfs -u
yum install -y ncurses-devel gcc make wget
uname -r
A response similar to the following will be returned, indicating the current kernel version is 2.6.32-642.6.2.el6.x86_64.2.6.32-642.6.2.el6.x86_64
version, you should download linux-2.6.32.tar.gz
at https://mirrors.edge.kernel.org/pub/linux/kernel/v2.6/linux-2.6.32.tar.gz
.cd /usr/src/
wget https://mirrors.edge.kernel.org/pub/linux/kernel/v2.6/linux-2.6.32.tar.gz
tar -xzf linux-2.6.32.tar.gz
ln -s linux-2.6.32 linux
cd /usr/src/linux
make mrproper
symvers_path=$(find /usr/src/ -name "Module.symvers")
test -f $symvers_path && cp $symvers_path .
cp /boot/config-$(uname -r) ./.config
make menuconfig
Enter the “Linux Kernel vX.X.XX Configuration” interface as shown below:If you are not taken to the "Linux Kernel vX.X.XX Configuration" interface, please go to [Step 18](# OptionalStep).
“Linux Kernel vX.X.XX Configuration” interface:
- Press “Tab” or “↑” “↓” to move the cursor.
- Press “Enter” to select or execute the item selected by the cursor.
- Press the space bar to select the item selected by the cursor. “*” means compiling to the kernel, and "M" means compiling to a module.
.config
file..config
file.This step is recommended if any of the following two is true:
- The kernel still contains no configuration information related to the virtio drivers after you finish checking.
- When compiling the kernel, you can not enter the kernel configuration interface or save the
.config
file.
make oldconfig
make prepare
make scripts
make
make install
find /lib/modules/"$(uname -r)"/ -name "virtio.*" | grep -E "virtio.*"
grep -E "virtio.*" < /lib/modules/"$(uname -r)"/modules.builtin
If any of the commands returns a list of files such as virtio_blk
,virtio_pci.virtio_console
, it indicates that you have installed the virtio drivers correctly.
Was this page helpful?