Thumbdrive behavior--nested partitions question about core-admin/qubes-devices library

A thumbdrive, on initial plugin, will (usually) show two devices…sys-usb:sda and sys-usb:sda1; sda1 is a partition basically nested within sda.

Usually you want to attach sys-usb:sda1 to whatever VM is supposed to work with the thumb drive. Once you do this, though, the device menu will never, ever show sys-usb:sda again, even if you detach sys-usb:sda1. It is necessary to unplug the device and plug it back in again to get sda back.

Even in the core-admin qubes-devices library, sda appears to vanish completely.

There are situations I run into where I might want sda to come back (I might want to run gparted on the thumb drive, for instance; I have other cases specific to my setup). Is there some process I can follow in core-admin that will “reset” it as though I had unplugged and then reinserted the drive?

If you don’t want to physically plug or unplug the drive, you can achieve the same result by triggering a udev event in sys-usb:

sudo udevadm trigger --subsystem-match block --action remove /dev/sda
sudo udevadm trigger --subsystem-match block --action add /dev/sda

Some time ago, I wrote a workaround patch for core-admin that automatically performs such actions when a partition is detached from a qube, but I’ve lost it somewhere…

1 Like

A thumbdrive, on initial plugin, will (usually) show two
devices…sys-usb:sda and sys-usb:sda1; sda1 is a partition basically
nested within sda.

Usually you want to attach sys-usb:sda1 to whatever VM is supposed to
work with the thumb drive.

I always attach sys-usb:sda to the VMs. Then, in the VM, I mount
/dev/xvdi1 partition. And then work with the thumbdrive storage in that
VM.

Once you do this, though, the device menu will never, ever show
sys-usb:sda again, even if you detach sys-usb:sda1. It is necessary to
unplug the device and plug it back in again to get sda back.

Yeah, I also observe something “screwed up” like that.

That’s certainly one approach! I was doing that for a while, but it was getting tedious having to remember to mount xvdi1 not xvdi in the qube, particularly when that was what I usually wanted to do. (I could have automated this eventually, but chose to do the automation earlier in the process.)

Many of my thumbdrives I actually just go ahead and format the whole thing as ext3 or ext4 and there’s no nesting. It takes some doing to get that to happen but it works in Linux once you do so. Of course, you won’t ever get the kiosk at OfficeDepot to read that thumbdrive…

I was trying to write something smart enough to handle either case directly. I can tell it to “ignore children” and it will mount sda. I can tell it to ignore parents and it will mount sda1 (and ask which one, if there is also an sda2, etc.) But I can’t do it if the system insists on taking whatever I do as a precedent and never shows me what I ignored ever again. In 4.2 it would lose the parent (if I mounted a child), but at least if I mounted the parent, it would still remember the children. 4.3 will now forget the children in the latter case too.

I guess I would have to have dom0 (which is doing the coordination) tell sys-usb to do this–another complication but one I can manage. (I’m not about to try to patch core-admin…I don’t understand most of it!)

Thanks!

1 Like

OK…I realized (belatedly) that those commands you gave are actually to be issued in dom0…no need for a qvm-run call or anything like that.

Unfortunately…the add does not work; it ONLY adds /dev/sda, not its children sda1 thru sda4.

I think that indicates an USB controller is connected to dom0.
Anyway, I wonder if there’s a difference in how udev handles things between dom0 and sys-usb? At least, it worked when I tested it on my sys-usb.

Actually…I realized those commands actually DO need to be run on sys-usb. I should have come back here and said so. Running on dom0 seemed to “work” sort of because it was disconnecting an internal SSD, not the thumbdrive.

I essentially have no known barriers left to converting my desktop over to 4.3…other than the fact that I simply won’t have time to do so for the next two weeks.