1

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.

1

The problem I was having was that my system (Fedora 27) automatically mounts new drives (external HDDs, USB, SD) to

/run/media/(username)/(device name)

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.

2

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.

1

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.

  • no one seeing this ? it's works great on my RHEL 8 system just move any qcow2 & iso to /home folder. Thanks a lot :) – haidarvm Aug 9 at 18:38
0

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.

  • virsh pool-dumpxml default > new_pool.xml error: failed to get pool 'default' error: Storage pool not found: no storage pool with matching name 'default' Also virsh pool-list list shows no pools. – Weylyn Savan Feb 10 '17 at 20:27
  • Ok, default pool created and is active. It points to the directory where i store the images. Permissions: mode: 0777, owner: 119, group: 128. Still access denied. – Weylyn Savan Feb 12 '17 at 21:20
  • The above has worked for me in the past. I'm not sure what the issue could be other than ownership without seeing your setup. an alternate method you could try, is a symlink on the additional storage directory to /var/lib/libvirt/images directory: ln -sf /path/to/additional/storage /var/lib/libvirt/images Permissions/ownership will need to be identical for that to work, but I can't vouch for that working definitely, as I haven't tested it myself – RobotJohnny Feb 13 '17 at 15:37
  • It's still not working. There's a video link in the question so you can see this part of my setup. For some reason it won't play from Google Drive so you have to download it but don't worry, it's only 17,1 MB. – Weylyn Savan Feb 14 '17 at 6:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.