Boot from virtio block device: Difference between revisions

From KVM
(initramfs)
m (added categories)
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
== Introduction ==
= Introduction =
Virtio block device is a para-virtualized device for kvm guest. It is different from normal emulated hard drive, because it is simply faster. This small how-to is about how to make a disk para-virtualized and boot from it.
Virtio block device is a para-virtualized device for kvm guest. It is different from normal emulated hard drive, because it is simply faster. This small how-to is about how to make a disk para-virtualized and boot from it.


= Linux =
== Steps ==
== Steps ==


Line 9: Line 10:
# in guest os, change /boot/grub/menu.list from "root=/dev/sda1" to "root=/dev/vda1", if you are using UUID, then no need to do this step.
# in guest os, change /boot/grub/menu.list from "root=/dev/sda1" to "root=/dev/vda1", if you are using UUID, then no need to do this step.
# enable para-virtualization by changing "-hda <your_disk_image" to "-drive file=<your_disk_image>,if=virtio,boot=on"
# enable para-virtualization by changing "-hda <your_disk_image" to "-drive file=<your_disk_image>,if=virtio,boot=on"
note: current debian lenny default kernel (2.6.26-2-amd64) will '''not''' give any output when running "dmesg | grep virtio"


== Error 18 ==
== Error 18 ==
Line 31: Line 34:
where vda1 is your boot partition
where vda1 is your boot partition


== updating the initramfs with the virtio driver ==
== Updating the guest initramfs with the virtio driver ==
If you are using debian then you may want to update your initramfs with the virtio driver as explained in [[Using VirtIO NIC]]
If you are hosting a debian guest then you may want to update its initramfs with the virtio driver as explained in [[Using VirtIO NIC]]
 
= Windows XP =
Windows driver installation is a bit tricky.
* In your guest, download the [[WindowsGuestDrivers/Download_Drivers|Windows driver]]
* Stop the machine and create a new image that you will add as a second disk
kvm-img create -f qcow2 fake.qcow2 1G
 
* Start the machine. You will be prompted to install the driver. This is enough to allow to boot on the ''virtio'' disk
kvm -drive file=windows.qcow2,if=ide,boot=on -drive file=fake.qcow2,if='''virtio''' ...
 
* Restart the machine, but with the ''virtio'' driver on the first disk
kvm -drive file=windows.qcow2,if='''virtio''',boot=on
 
* You will be prompted once again to install the driver.
 
[[Category:Virtio]][[Category:Docs]][[Category:HowTo]]

Latest revision as of 09:41, 31 May 2015

Introduction

Virtio block device is a para-virtualized device for kvm guest. It is different from normal emulated hard drive, because it is simply faster. This small how-to is about how to make a disk para-virtualized and boot from it.

Linux

Steps

  1. create a disk and install os to it by appending "-hda <your_disk_image>" to your virtual machine
  2. in your guest os, upgrade kernel to 2.6.25 which contains virtio_* drivers. or ubuntu 8.04 also has it.
  3. in guest os, change /boot/grub/device.map from "(hd0) /dev/sda" to "(hd0) /dev/vda"
  4. in guest os, change /boot/grub/menu.list from "root=/dev/sda1" to "root=/dev/vda1", if you are using UUID, then no need to do this step.
  5. enable para-virtualization by changing "-hda <your_disk_image" to "-drive file=<your_disk_image>,if=virtio,boot=on"

note: current debian lenny default kernel (2.6.26-2-amd64) will not give any output when running "dmesg | grep virtio"

Error 18

you may experience this error while grub is booting. I solved it by making the /boot the first partition and make it 32MB.

qcow2

I have problem to boot from qcow2 format image, it will hang while kernel booting. you may convert your disk image to raw format by "qemu-img convert -f qcow2 <your_disk_image> -O raw <a_new_location>".

Booting with lilo

You must add this to your lilo.conf:

boot=/dev/vda
disk=/dev/vda bios=0x80 max-partitions=7

and after your image clausule change:

root=/dev/vda1

where vda1 is your boot partition

Updating the guest initramfs with the virtio driver

If you are hosting a debian guest then you may want to update its initramfs with the virtio driver as explained in Using VirtIO NIC

Windows XP

Windows driver installation is a bit tricky.

  • In your guest, download the Windows driver
  • Stop the machine and create a new image that you will add as a second disk
kvm-img create -f qcow2 fake.qcow2 1G
  • Start the machine. You will be prompted to install the driver. This is enough to allow to boot on the virtio disk
kvm -drive file=windows.qcow2,if=ide,boot=on -drive file=fake.qcow2,if=virtio ...
  • Restart the machine, but with the virtio driver on the first disk
kvm -drive file=windows.qcow2,if=virtio,boot=on
  • You will be prompted once again to install the driver.