All Documents
Current Document

Content is empty

If you don't find the content you expect, please try another search term

Documentation

How can I configure fstab and grub to support virtio?

Last updated:2021-07-16 11:18:19

You need to modify the disk information in /etc/fstab and grub configuration files to support virtio inside the image. To modify the information, change the part that contains /dev/sdaX to /dev/vdaX, where X refers to 1, 2, 3....

The following example shows how to configure Ubuntu 16.04:

  1. Run "sudo vim /etc/fstab". It is found that in current system configuration, the root partition corresponds to "/dev/sdaX" (where X refers to 1, 2, 3...), which must also be changed to "/dev/vdaX" (where X refers to 1, 2, 3...).

    Before the change:

    image.png

    After the change:

    2.png

  2. Run "sudo vim /boot/grub/grub.cfg". The file path varies depending on the system type and grub version. Generally, the file path is /boot/grub2/grub.cfg in CentOS 7 and /boot/grub/grub.conf in CentOS 6. In /boot/grub/grub.cfg configuration, the right value of "root=" is "/dev/sdaX", where X refers to 1, 2, 3.... The value "/dev/sdaX" may exist in multiple grub entries, and all of them need to be changed to "/dev/vdaX", where X refers to 1, 2, 3....

    Before the change:

    image.png

    After the change:

    4.png

  3. Update the grub configuration. Run the command "grub-mkconfig -o /boot/grub/grub.cfg". Note: The command executed and the output file depend on the system type and grub version.

  4. (Optional) Verify the configuration. In the KVM environment, execute "reboot". Note that you may not access the system in a non-KVM environment. After you enter the system, run "cat /proc/cmdline" to check whether the change takes effect. If yes, the "root=/dev/vda1" field will appear.
On this page
Pure ModeNormal Mode

Pure Mode

Click to preview the document content in full screen
Feedback