2019-01-05 04:30:04 -05:00
---
2021-03-13 13:06:18 -05:00
lang: en
2019-01-05 04:30:04 -05:00
layout: doc
redirect_from:
2021-06-16 01:33:51 -04:00
- /doc/device-handling/
2019-03-29 20:12:44 -04:00
- /doc/external-device-mount-point/
- /en/doc/external-device-mount-point/
- /doc/ExternalDeviceMountPoint/
- /wiki/ExternalDeviceMountPoint/
2021-03-13 13:06:18 -05:00
ref: 188
2019-01-05 04:30:04 -05:00
---
2021-03-13 12:03:23 -05:00
# Device Handling
2019-01-05 04:30:04 -05:00
2019-08-18 13:37:33 -04:00
This is an overview of device handling in Qubes OS.
2021-04-10 18:09:05 -04:00
For specific devices ([block](/doc/block-devices/), [USB ](/doc/usb-devices/ ) and [PCI ](/doc/pci-devices/ ) devices), please visit their respective pages.
2019-01-05 04:30:04 -05:00
2019-08-18 13:37:33 -04:00
**Important security warning:** Device handling comes with many security implications.
2021-04-10 18:09:05 -04:00
Please make sure you carefully read and understand the ** [security considerations ](/doc/device-handling-security/ )**.
2019-01-05 04:30:04 -05:00
2019-03-29 20:12:44 -04:00
## Introduction ##
2019-08-18 13:37:33 -04:00
The interface to deal with devices of all sorts was unified in Qubes 4.0 with the `qvm-device` command and the Qubes Devices Widget.
In Qubes 3.X, the Qubes VM Manager dealt with attachment as well.
This functionality was moved to the Qubes Device Widget, the tool tray icon with a yellow square located in the top right of your screen by default.
2019-01-05 04:30:04 -05:00
There are currently four categories of devices Qubes understands:
- Microphones
- Block devices
- USB devices
- PCI devices
2019-08-18 13:37:33 -04:00
Microphones, block devices and USB devices can be attached with the GUI-tool.
PCI devices can be attached using the Qube Settings, but require a VM reboot.
2019-01-05 04:30:04 -05:00
2019-03-29 20:12:44 -04:00
## General Qubes Device Widget Behavior And Handling ##
2021-04-10 18:09:05 -04:00
When clicking on the tray icon (which looks similar to this): ![SD card and thumbdrive ](/attachment/wiki/Devices/media-removable.png ) several device-classes separated by lines are displayed as tooltip.
2019-08-18 13:37:33 -04:00
Block devices are displayed on top, microphones one below and USB-devices at the bottom.
2019-01-05 04:30:04 -05:00
On most laptops, integrated hardware such as cameras and fingerprint-readers are implemented as USB-devices and can be found here.
2019-03-29 20:12:44 -04:00
### Attaching Using The Widget ###
2019-08-18 13:37:33 -04:00
Click the tray icon.
Hover on a device you want to attach to a VM.
A list of running VMs (except dom0) appears.
Click on one and your device will be attached!
2019-01-05 04:30:04 -05:00
2019-03-29 20:12:44 -04:00
### Detaching Using The Widget ###
2019-08-18 13:37:33 -04:00
To detach a device, click the Qubes Devices Widget icon again.
Attached devices are displayed in bold.
Hover the one you want to detach.
2021-04-10 18:09:05 -04:00
A list of VMs appears, one showing the eject symbol: ![eject icon ](/attachment/wiki/Devices/media-eject.png )
2019-01-05 04:30:04 -05:00
2019-03-29 20:12:44 -04:00
### Attaching a Device to Several VMs ###
2019-08-18 13:37:33 -04:00
Only `mic` should be attached to more than one running VM.
2020-03-06 18:21:06 -05:00
You may *assign* a device to more than one VM (using the `--persistent` option), however, only one of them can be started at the same time.
2019-01-09 05:54:47 -05:00
2021-04-10 18:09:05 -04:00
But be careful: There is a [bug in `qvm-device block` or `qvm-block` ](https://github.com/QubesOS/qubes-issues/issues/4692 ) which will allow you to *attach* a block device to two running VMs.
2019-08-18 13:37:33 -04:00
Don't do that!
2019-01-05 04:30:04 -05:00
2019-03-29 20:12:44 -04:00
## General `qvm-device` Command Line Tool Behavior ##
2019-01-05 04:30:04 -05:00
All devices, including PCI-devices, may be attached from the commandline using the `qvm-device` -tools.
2019-03-29 20:12:44 -04:00
### Device Classes ###
2019-08-18 13:37:33 -04:00
`qvm-device` expects DEVICE_CLASS as first argument.
DEVICE_CLASS can be one of
2019-01-05 04:30:04 -05:00
- `pci`
- `usb`
- `block`
- `mic`
2019-03-29 20:12:44 -04:00
### Actions ###
2019-01-05 04:30:04 -05:00
`qvm-device` supports three actions:
- `list` (ls, l) - list all devices of DEVICE_CLASS
- `attach` (at, a) - attach a specific device of DEVICE_CLASS
- `detach` (dt, d) - detach a specific device of DEVICE_CLASS
2019-03-29 20:12:44 -04:00
### Global Options ###
2019-01-05 08:40:48 -05:00
These three options are always available:
2019-01-05 04:30:04 -05:00
- `--help` , `-h` - show help message and exit
- `--verbose` , `-v` - increase verbosity
- `--quiet` , `-q` - decrease verbosity
2019-08-18 13:37:33 -04:00
A full command consists of one DEVICE_CLASS and one action.
If no action is given, list is implied.
DEVICE_CLASS however is required.
2019-01-05 04:30:04 -05:00
**SYNOPSIS**:
`qvm-device DEVICE_CLASS {action} [action-specific arguments] [options]`
2021-03-13 12:03:23 -05:00
## Actions
2019-03-29 20:12:44 -04:00
2019-01-05 04:30:04 -05:00
Actions are applicable to every DEVICE_CLASS and expose some additional options.
2021-03-13 12:03:23 -05:00
### Listing Devices
2019-03-29 20:12:44 -04:00
2019-08-18 13:37:33 -04:00
The `list` action lists known devices in the system.
`list` accepts VM-names to narrow down listed devices.
Devices available in, as well as attached to the named VMs will be listed.
2019-01-05 04:30:04 -05:00
`list` accepts two options:
2021-03-13 12:03:23 -05:00
- `--all` - equivalent to specifying every VM name after `list` .
2019-08-18 13:37:33 -04:00
No VM-name implies `--all` .
2021-03-13 12:03:23 -05:00
- `--exclude` - exclude VMs from `--all` .
2019-08-18 13:37:33 -04:00
Requires `--all` .
2019-01-05 04:30:04 -05:00
**SYNOPSIS**
`qvm-device DEVICE_CLASS {list|ls|l} [--all [--exclude VM [VM [...]]] | VM [VM [...]]]`
2021-03-13 12:03:23 -05:00
### Attaching Devices
2019-03-29 20:12:44 -04:00
2019-08-18 13:37:33 -04:00
The `attach` action assigns an exposed device to a VM.
This makes the device available in the VM it's attached to.
Required argument are targetVM and sourceVM:deviceID.
(sourceVM:deviceID can be determined from `list` output)
2019-01-05 04:30:04 -05:00
`attach` accepts two options:
2021-03-13 12:03:23 -05:00
- `--persistent` - attach device on targetVM-boot.
2019-08-18 13:37:33 -04:00
If the device is unavailable (physically missing or sourceVM not started), booting the targetVM fails.
2021-03-13 12:03:23 -05:00
- `--option` , `-o` - set additional options specific to DEVICE_CLASS.
2019-01-05 04:30:04 -05:00
**SYNOPSIS**
`qvm-device DEVICE_CLASS {attach|at|a} targetVM sourceVM:deviceID [options]`
2021-03-13 12:03:23 -05:00
### Detaching Devices
2019-03-29 20:12:44 -04:00
2019-08-18 13:37:33 -04:00
The `detach` action removes an assigned device from a targetVM.
It won't be available afterwards anymore.
Though it tries to do so gracefully, beware that data-connections might be broken unexpectedly, so close any transaction before detaching a device!
2019-01-05 04:30:04 -05:00
2019-01-09 05:54:47 -05:00
If no specific `sourceVM:deviceID` combination is given, *all devices of that DEVICE_CLASS will be detached.*
2019-01-05 04:30:04 -05:00
`detach` accepts no options.
**SYNOPSIS**
2019-01-09 05:54:47 -05:00
`qvm-device DEVICE_CLASS {detach|dt|d} targetVM [sourceVM:deviceID]`
2019-01-05 04:30:04 -05:00