Mount a VM Drive on Qubes

When mounting a USB drive on Qubes v3.2, the system automatically recognizes the device, such as /dev/sdb, and its partitions, such as /dev/sdb1. They show in little rectangular notifications on the desktop.

But, that doesn’t mount the filesystem. Consider mounting it on dom0 unsecure.

Instead, attach the block device to a VM:

  1. Open the VM Manager
  2. Right click on the VM to open the menu
  3. Select “Attach/detach block devices” from the menu, which opens a list showing the device
  4. Click on the device in the list to attach it to the VM.

Attaching to a VM does not mount the filesystem on the VM. Typical next step:

  1. Open the Files app — Nautilus in a Fedora VM
  2. Select “Other Locations” from its menu, which displays the USB drive’s label and its virtual device path, such as /dev/xvdi1, but it’s not mounted yet
  3. Click the drive’s label name to mount and display the contents of the filesystem

When done, reverse this process by clicking the eject icon in the Files app for the mounted drive, then detach it in the VM manager.

That’s not always convenient.

If intending to use the drive from a VM terminal, ready to run some programs to work with its files, why move my concentration away from the terminal window to start and use the Files app?

There must be a way to mount and unmount the drive on the VM’s command line after dom0 attaches it to the VM.

Qubes documents ( use of qvm-block to see the drive inside dom0 and attach it to a VM. But, with a terminal already open in the VM, there should be a way to attach it without using qvm-block in dom0.

Use udisksctl(1) on the command line in the VM.

Instead of command line options, udisksctl uses command names. No leading hyphens or double-hyphens. Two relevant commands: mount and unmount.

Verify the correct device name as the VM sees it. It’s not mounted yet so don’t assume. Use the following command to find the name, probably at the end of the list:

$ sudo fdisk -l

Mount the partition, such as /dev/xvdi1:

$ udisksctl mount -b /dev/xvdi1

This command doesn’t need a sudo because the user has automounting privilege in every VM. When the command finishes it tells where on the filesystem it was mounted. Verify it with df(1).

Later, unmount the partition, such as /dev/xvdi1:

$ udisksctl unmount -b /dev/xvdi1

When done it tells which partition was unmounted.

After unmounting it, go back to the VM manager and detach it. When so detached in dom0, attach it to another VM or pull the USB drive.

Leave a Comment