Ubuntu – Add physical disk to KVM virtual machine

kvmvirtualization

I'm setting up a file server (nas4free) as a KVM virtual machine on a Ubuntu Server 12.04 system.

How do I add physical hard drives directly to the VM so they can be used by the guest (nas4free), but not the host?

Specifically the hard drive I'd like to mount is /dev/sda (which is not currently mounted on the server.)

So far I've found two solutions but I haven't gotten either to work.

The first is from Server Fault where it's suggested to use virt-manager. I haven't gotent this to work because when I try to select an existing drive nothing is being listed. My best guess as to why this is, is because I'm using virt-manager over ssh and not connecting as root, should that make a difference?

The second solution I've found here is to just run the command (modified for my system)

qm set nas4free -virtio /dev/sda

but that seems to require proxmox which I don't have installed and doesn't seem to be in the default repositories?

Finally, once the above is sorted out and I can mount the drive directly to the VM, does anyone have an experience with whether the drive should be mounted to the VM as scsi, ide, or virtio? (I know virtio was recommend in the linked ServerFault page, but I hadn't heard of it before now since I mainly use VMWare).

Thanks for your help!!!

Best Answer

Although this has been answered, rather than using /dev/sda you should use /dev/disk/by-id/ where you get from

    ls -l /dev/disk/by-id

That way you are covered just in case the disk changes from /dev/sda to /dev/sdb.