KVM Guest Raw Disk Access

In the process of setting up my NFS server, I ran into how best to attach a USB3 disk directly to the KVM guest for direct writethrough.

Pools vs. Raw

My criteria for the solution were as follows:

  1. Portability. I don’t want to be stuck with a disk I can’t read without KVM tools.
  2. Speed. I’m actually going to be using this disk.
  3. Low overhead. I don’t need KVM to worry about the disk.

Pools offer a lot of flexibility, but I don’t really need it. Also, the raw disk options I explored for pools require that the partition be mounted in the host, which seems like an added point of failure.

I went with raw device access, since it does everything I need and nothing I don’t.


First, you prepare the disk on the host. I wrote a GPT partition table to disk with a single large partition, and formatted it ext4 with 1% reserved blocks:

[nc@hv1 ~]$ sudo mkfs.ext4 -m 1 /dev/sdc1

Then I got the UUID and attached the disk to the running guest:

[nc@hv1 ~]$ blkid /dev/sdc1
/dev/sdc1: UUID="5d3a2dbf-e9d9-43df-9bc0-cd33312fdd1c" TYPE="ext4" PARTUUID="664f9ecd-d3dc-4c2c-a69d-f3a51182b71f"
[nc@hv1 ~]$ sudo virsh attach-disk store /dev/disk/by-uuid/5d3a2dbf-e9d9-43df-9bc0-cd33312fdd1c vdb --cache none

That’s it! The drive became available immediately. I added entries in my fstab (mounting by path, since the path in the guest is static), and rebooted the guest to make sure changes were persistent.