Mounting USB Block device - "backend doesn't expose device"

I’m trying to attach a USB block device using its device node, not individual partitions. So, for example:

qvm-block 
sys-usb:sda1 TransMemory ...
sys-usb:sda2 TransMemory ...

When I try to attach the device, it fails:

qvm-block attach (destVM) s_usb:sda
error: backend vm sys-usb doesn't expose device 'sda'

Mounting individual partitions (e.g using qvm-block attach (destVM) s_usb:sda1) works fine.

Any idea how I can attach the whole USB drive?

Use qvm-device instead?

1 Like

qvm-block is just an alias to qvm-device. It shouldn’t result in different functionality.

I’m not sure what the problem was, but it works now. Using the same USB drive, now qvm-block lists the device node sda at the top of the list and I can attach it fine.

1 Like
Well actually... (offtopic but maybe useful...)

Sorry to correct a minor point - it is absolutely possible for an executable to change behaviour, depending on its filename.

This feature is fairly widely used in Linux and other unix-y systems… (Busybox is a particularly neat case, where a single file can act as an entire Linux base system, just by creating multiple links to it)

Bonus point: I use this occasionally in shell scripts, by testing the value of the $0 variable. It can help avoid code duplication or management of dependencies.

I bet everyone is pleased to know that :slight_smile:

I think this is (probably) exactly the case of qvm-{device,block,usb,pci,…}

In that case, I think I answered too quickly :slight_smile: I was wrong, I thought that sda will be available trough qvm-device usb.

qvm-block is an alias, as stated in the qvm-device manpages. If you do man qvm-block you get the manpage of qvm-device

If any partition has been attached to a VM, then it may be necessary to unplug the device, and look immediately after it has been connected.
After plugin, I see :

  • Block : sys-usb:sdc
  • Block : sys-usb:sdc1
  • USB Device: sys-usb:2-3

After attaching the sys-usb:sdc1 partition to a disposable, I do not see the sdc block, because it was hidden when the partition was attached. I am guessing this is to avoid parallel access to the blocks from two different VMs, although the USB device does remain available (because of multifunction devices, maybe?).
The sdc blockdev remains hidden after detaching the partition, or closing the disposable.

Running sudo udevadm trigger in sys-usb seems to make it come back (as does physical unplug-replug).

2 Likes