I was required to auto map a USB DoK to a KVM VM (specific VM, mind you!), as a result of connecting this device to the host. I’ve looked it up on the Internet, and the closest I could get there was this link. It was almost a complete solution, but it had a few bugs, so I will re-describe the whole process, with the fixes I’ve added to the process and udev rules file. While this guide is rather old, it did solve my requirement, which was to map a specific set of devices (“known USB devices”) to the VM, and not any and every USB device (or even – USB DoK) connected to the system.
In my example, I’ve used SanDisk Corp. Ultra Fit, which its USB identifier is 0781:5583, as can be seen using ‘lsusb’ command:
[root@localhost ~]# lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 020: ID 0781:5583 SanDisk Corp. Ultra Fit
My VM is called “centos7.0” in this example. I am using integrated KVM+QEMU+LIBVIRT on a generic CentOS 7.5 system.
Preparation
You will need to prepare two files:
USB definitions file (for easier config of libvirt)
UDEV rules file (which will be triggered by add/remove operation, and will call the USB definitions file)
USB Definitions file
I’ve placed it in /opt/autousb/hostdev-0781:5583.xml , and it holds the following (mind the USB device identifiers!)
I’ve created a file /etc/udev/rules.d/90-libvirt-usb.rules with the content below. Note that the device identifiers are there, but in the “remove” section they appear differently. Remove leading zero(s) and change the string. This is caused because on removal, the device does not report all its properties to the OS. Also – you cannot connect more than three (3) such devices to a VM, so when you fail to detach three devices (following a consecutive insert/remove operations, for example), you will not be able to attach a fourth time.
SSH is a wonderful tool. One of its best features is the ability to pierce a firewall and let you go through it. If you’re using the dynamic port (-D as argument in command line openSSH), you actually get a SOCKS5 proxy over which you can transport all your desired data. This allows you the…
HP MSA1000 is an entry-level disk storage capable of communicating via different types of interfaces, such as SCSI and FC, and can allow FC failover. This FC failover, however, is controller failover and not path failover. It means that if the primary controller fails entirely, the backup controller will “kick in”. However, if a multi-path…
Every Linux admin is familiar with the long time running through a large directory tree (with hundred of thousands of files and more) can take. Most are aware that if you re-run the same run-through, it will be shorter. This is caused by a short-valid filesystem cache, where the memory is allocated to other tasks,…
I have a nice SCSI tape connected to a single server. This allows for on-demand backups, with the hope (and seldom, with the established knowledge) that I can recover the data I have there. Old computers, decommissioned computers and systems I wish to erase and reuse are seldom backed-up, just because of the effort in…
I’m in the process of installing VCS on two guest (virtual) Linux nodes, each using the following setup: 256MB RAM One local (Virtual) HDD, SCSI channel 0 Two shared (Virtual) HDDs, SCSI channel 1 Two NICs, one bridged, and one using /dev/vmnet2, a personal Virtual switch. The host (carrier) is a Pentium 3 800MHz, with…
For some reason, my home Internet connection stopped receiving large packets. This could be something with PMTU discovery blocks on the ISP side, or it could be something that I changed. An automated job which uploaded files using SSH (to be exact: scp) to my home stopped working. The failure was a time-out after the…
One Comment