For some project I need to have QEMU/KVM virtual machine with raw disk image.
So I have created this raw disk image as simple as
dd if=/dev/zero of=~/disk.img bs=1M count=3092
and got 3 Gb of space on it.
Then I have set-up new virtual machine from Virtual Machine Manager (virt-manager
) on Ubuntu 16.04 LTS using my normal account. So I have installed the Ubuntu from mini.iso to inside the ~/disk.img. My user is a member of libvirtd
group. I can boot the VM when virtual disk image is inside my home folder.
Then I moved this file to the external FAT32 (vfat) medium which is mounted read-and-write. So it is located inside /media/username/FLASH/disk.img. I specified this path in the Virtual Disk setting section of the virtual machine.
But when I try to start this machine I get the following error message:
Error starting domain: internal error: process exited while connecting to monitor: 2020-01-22T21:45:20.221697Z qemu-system-x86_64: -drive file=/media/username/FLASH/disk.img,format=raw,if=none,id=drive-ide0-0-1: Could not open '/media/username/FLASH/disk.img': Permission denied
And this message persists even if I run the Virtual Machine Manager as root using sudo virt-manager
.
The permissions of this file are the following:
$ ls -al /media/username/FLASH/disk.img -rw-r--r-- 1 username username 3221225472 Jan 23 00:18 /media/username/FLASH/disk.img
Also I tried to create a symbolic link using ln -s /media/username/FLASH/disk.img ~/disk.img
and set machine to use the latter disk path. But it does not work too.
How can I boot QEMU/KVM virtual machine from the disk image located on external storage?
qemu-system-x86_64 -drive file=/media/username/FLASH/disk.img,format=raw -m 1024
as my normal users boots VM without issues. Whilevirt-manager
tries to launch it as libvirt-qemu user. So seems to be unix-file permissions issue as described in answer below. – N0rbert Jan 24 '20 at 18:40