I'm running Deepin 15.3 x64 and i have an external HDD with EXT4 file system. whereat i store things like VM images. Oracle VM VirtualBox and VMware Workstation Player works just fine with this config, but KVM can't read files from it. I've tried to chown the files, the container directory and even chmod -R 0777 on the entire drive. But KVM still complains that it can't access the directory. However KVM can create images there, but KVM won't be able to access the image file as soon as it gets created. Here's a video of this (in case something's not clear). Note that I can't move the images to /var/lib/libvirt/images because i don't have enough space on my SSD for any of them.
The problem I was having was that my system (Fedora 27) automatically mounts new drives (external HDDs, USB, SD) to
For whatever reason this causes the permissions issue. What I did to fix the issue was unmount the drive from that location as root, and then mount it to
/mnt. My USB thumb drive is
/dev/sdc1 on my system so I did the following.
# su - (then enter root password) # umount /run/media/yourusername/devicename # mount /dev/sdc1 /mnt (mount usb to /mnt)
After that I just made sure to have symbolic links from the original location of the qcow2 drives to the new location (still as root)
# cd /var/lib/libvirt/images # ln -s (new target) (link name)
so if your vm is named MyVM
# ln -s /mnt/Myvm.qcow2 MyVm.qcow2
Once I saw that my VMs were now working, I edited
/etc/fstab to automatically mount the drive at
/mnt. The folders and qcow2 drives were owned by my standard user account and group. I am sure there are better ways to do it, but this is what worked for me.
Solution: Run Virtmanager as root, choose create a new VM -> select 'Import existing disk image' and browse it. After clicking continue it will ask whether you want it to fix permission issues or not for that path. After choosing 'Yes', it fixes the permission issue and will work when it's running as a normal user too.
This is because the Qemu requires execution permission along the image file's path. If the image is in the mounted disk, it requires +x permission in the /media/$username
For me, I fixed this issue by this command:
sudo chmod a+x /media/houcheng/
For rest of the detail, please see this.
KVM uses libvirt, which requires images to be in a defined pool. You can do this with Virsh by copying the config of the default pool
virsh pool-dumpxml default > new_pool.xml edit new_pool.xml ## use a different name & path virsh pool-create new_pool.xml virsh pool-refresh name
KVM should then be able to pick up images on your additional drive.