Virt-Manager Qemu/KVM USB problem

New to Debian (Or Linux in general)? Ask your questions here!

Re: Virt-Manager Qemu/KVM USB problem

Postby CwF » 2019-08-13 22:39

Yes, simpler than many say. If this doesn't work for you, I don't know why?! Another guy I explained this to said he had permission problems, then it worked, then didn't hold after a reboot, then deleted the thread here, probably because it did work and he figured out what he was doing wrong!

Create a link for the disk in question, /dev/disk/by-id/your disk or by-label if it's labeled, in the directory /var/lib/libvirt/images. This needs done by root.

Then, with the link in the standard storage pool, refresh if needed and using virt-manager attach this in the VM's properties page with 'Select or Create Custom Storage'. It will be storage type Disk, storage format raw, hypervisor default caching should be ok, or none.

Actual example:
/var/lib/libvirt/ata-ST31000528AS_9VPBXMK9 links to /dev/disk/by-id/ata-ST31000528AS_9VPBXMK9

I add a step to hide this disk from the desktop and others,
Create the file /etc/udev/rules.d/99-hide-partition.rules with the following content:
Code: Select all
ENV{ID_SERIAL}=="ST31000528AS_9VPBXMK9", ENV{UDISKS_IGNORE}="1"


You can leave the disk attached to the vm, umount in the vm, and mount on the host while the guest is live, umount from the host and remount in the vm. BE VERY CAREFUL.
CwF
 
Posts: 388
Joined: 2018-06-20 15:16

Re: Virt-Manager Qemu/KVM USB problem

Postby PsySc0rpi0n » 2019-08-14 11:55

CwF wrote:Yes, simpler than many say. If this doesn't work for you, I don't know why?! Another guy I explained this to said he had permission problems, then it worked, then didn't hold after a reboot, then deleted the thread here, probably because it did work and he figured out what he was doing wrong!

Create a link for the disk in question, /dev/disk/by-id/your disk or by-label if it's labeled, in the directory /var/lib/libvirt/images. This needs done by root.

Then, with the link in the standard storage pool, refresh if needed and using virt-manager attach this in the VM's properties page with 'Select or Create Custom Storage'. It will be storage type Disk, storage format raw, hypervisor default caching should be ok, or none.

Actual example:
/var/lib/libvirt/ata-ST31000528AS_9VPBXMK9 links to /dev/disk/by-id/ata-ST31000528AS_9VPBXMK9

I add a step to hide this disk from the desktop and others,
Create the file /etc/udev/rules.d/99-hide-partition.rules with the following content:
Code: Select all
ENV{ID_SERIAL}=="ST31000528AS_9VPBXMK9", ENV{UDISKS_IGNORE}="1"


You can leave the disk attached to the vm, umount in the vm, and mount on the host while the guest is live, umount from the host and remount in the vm. BE VERY CAREFUL.


Ok, I'll try that when I get home.
However, the last part of your post says I can mount and unmount and etc while VM is live. Then, you say BE VERY CAREFUL... Why is this? Am I getting into dangerous fields? How come? What are the risks?

Thanks
Psy
User avatar
PsySc0rpi0n
 
Posts: 76
Joined: 2012-10-24 13:54

Re: Virt-Manager Qemu/KVM USB problem

Postby CwF » 2019-08-14 15:41

It is possible to have a disk in this fashion mounted twice, on the host and in a vm. That's not good, yet you will get no warning. Typically the secondary mount will appear to work fine, but changes may be held in cache and never committed to disk. Just saying cool magic functionality and disaster are close friends. Similar issues can happen with improper use of guestmount.

My posting may sometimes deserve a disclaimer!
CwF
 
Posts: 388
Joined: 2018-06-20 15:16

Re: Virt-Manager Qemu/KVM USB problem

Postby PsySc0rpi0n » 2019-08-14 18:09

CwF wrote:It is possible to have a disk in this fashion mounted twice, on the host and in a vm. That's not good, yet you will get no warning. Typically the secondary mount will appear to work fine, but changes may be held in cache and never committed to disk. Just saying cool magic functionality and disaster are close friends. Similar issues can happen with improper use of guestmount.

My posting may sometimes deserve a disclaimer!


So, to be safe, better to unmount from host and use it solely in guest, is that it?

Where can I see the pool? I only remember it when about to create a new VM!???


Edited;

Forget about the pool. I foun it.

However I can't find the option 'raw' and I have another option you don't mention:
BUS TYPE:
-IDE
-SATA
-SCSI
-SD
-USB
-VirtIO

I chose VirtIO and going to restart VM now!
I'm having issues is with unmounting it from the host!


Edited;

I think I got it!
User avatar
PsySc0rpi0n
 
Posts: 76
Joined: 2012-10-24 13:54

Re: Virt-Manager Qemu/KVM USB problem

Postby PsySc0rpi0n » 2019-08-17 22:06

New problem with my VM...

I had to force restart my host and couldn't gracefully shutdown my guest OS.

Now when I reboot the VM I always get this for ever:
Image

Any help to solve this? Or do I have to reinstall the damn VM?



edited;
another screenshot
Image

Just another information.
I can login in rescue mode into text mode, meaning no desktop GUI...
Anything I can do here?
User avatar
PsySc0rpi0n
 
Posts: 76
Joined: 2012-10-24 13:54

Re: Virt-Manager Qemu/KVM USB problem

Postby CwF » 2019-08-18 13:14

Actually, from the screenshots I don't see the error. I do see evidence of things I wouldn't do, but no errors. If you get past unlocking the drive, and then get to a blank screen, then you need to probe around, it's a config issue in the vm, try a 'startx'. It's salvageable, approach it like bare metal, it's not a vm or disk issue ?

The screenshot shows a clean file system. Other than the fact it does work, I would not recommend passing a single disk encrypted device to a VM. At least set hypervisor caching to 'none'.
Yes, it's good to have ALL OS images setup to be virtualized. Passing the lvm disk should be a rescue or forensics attempt, and not the daily driver. That extra disk should boot the host too btw, so consider setting up your host to be able to be virtualized also, just in case.

There are better ways to utilize extra disk space. I assume the primary host is also on a single disk lvm? If so, any extra space should be linked in to the host disk, but not in a dependent way, and in a crash worthy way. Look into using qcow2 layers and place only the read-write 'runtime' layer on the host. Use the external space for READ-ONLY qcow2 layers, virtual usb qcows, ISO's, or guest controlled simple FS's. I use 3 layers typically, and have 5 disk in my main machine. I do pass 2 spinners to vm's, but with only guest caching.

Before you go much further verify some parachutes. If the power button is setup to shutdown the system it will shut down vm's if the OS is alive and it's some gui lockup. If it is a gui lockup and the system is still running, be aware VM's may continue oblivious to the issue, so learn to identify that, and give things time. It's useful to have a second machine capable of reaching in via ssh, vnc, etc. A vfio assisted vm with it's own kbm can even reach back into host if setup. If the situation is a hardware lock and the OS is indeed froze, identify and fix it before continuing.

Fun!
CwF
 
Posts: 388
Joined: 2018-06-20 15:16

Previous

Return to Beginners Questions

Who is online

Users browsing this forum: No registered users and 9 guests

fashionable