Instructions for Disposable USB qube are complete. These instructions assume the the service-dvm in the previous instructions would be used as the disp-sys-usb template i.e. template_for_dispvms true
My next step is to do some fine tuning on both sets of DispVM instructions. Get feedback for any changes. Then I will submit a pull request to qubes-docs (if that is OK with everyone)
Also, I know much of the sys-usb info I mentioned is already in the Qubes docs. I wanted to add it here in case anyone wanted to test the instructions. Having all info in the same place makes it easier.
Create a Disposable sys-usb VM
Qubes 4.0 users now have the option of creating a sys-usb Disposable VM. This will provide significant benefits over the default sys-usb VM. Considering that USB devises can pose a serious security risk, the use of a disposable USB qube would mitigate many of the risks associated with attaching a USB. Not only is dom0 afforded the same protections the default USB qube provides from a malicious USB. The Disposable USB qubes’ non-persistent filesystem prevents malware from gaining a persistent foothold in the VMs /home folder.
Users must first create the dvm template which the disposable USB VM is based on (steps 1-3 “Create sys-net and sys-firewall Disposable VMs” chapter)
1. In dom0, create the disposable USB VM
qvm-create -P <pool_name> --template service-dvm --class DispVM --label red disp-sys-usb
2. In dom0, set the virtualization mode to hvm
qvm-prefs disp-sys-usb virt_mode hvm
3. In dom0, set disp-sys-usb NetVM to none
qvm-prefs usb-disp netvm ""
4. In dom0, list all available PCI devices
qvm-pci
5. In dom0, attach the USB controller to the USB VM
Note: the bakend:BDF address will look similar to this dom0:00_1a.0
qvm-pci attach --persistent disp-sys-usb <backined>:<bdf>
6. Hide USB controllers from dom0
Warning: If a USB AEM is being used, all USB controllers should not be hidden from dom0. This would prevent the USB AEM devices from functioning.
Note: If users created a usb qube during qubes install or by using salt, the following steps can be ignored.
If users have created a USB qube manually, there will be a brief period of time during the boot process when dom0 will be exposed to your USB controllers and any attached devices. This is a security risk, since even a brief exposure to a malicious USB device could result in dom0 being compromised. It is recommended users hide (blacklist) all USB controllers from dom0.
GRUB2
In dom0 terminal, open GRUB2 configuration file in a text editor
sudo nano /etc/default/grub
Locate the line that begins with GRUB_CMDLINE_LINUX and append the following text
rd.qubes.hide_all_usb
save and exit
In dom0 , update GRUB2 for the new changes to take affect
grub2-mkconfig -o /boot/grub2/grub.cfg
In dom0, reboot Qubes for the new boot parameters to take affect
sudo reboot
EFI
In dom0, open EFI boot configuration file in a text editor
sudo nano /boot/efi/EFI/qubes/xen.cfg
Locate the line that begins with “kernel=” and append the following text
Note: more than one “kernel=” line may be present
rd.qubes.hide_all_usb
save and exit
Troublshooting
If the USB qube fails to start the likely reason is one of the controllers does not support reset. Quite often the offending contoller is a USB 3.0 device. The following errors would suggest this is the issue.
In dom0, xl dmesg output
(XEN) [VT-D] It’s disallowed to assign 0000:00:1a.0 with shared RMRR at dbe9a000 for Dom19.
(XEN) XEN_DOMCTL_assign_device: assign 0000:00:1a.0 to dom19 failed (-1)
In dom0, when qvm-start disp-sys-usb is run
internal error: Unable to reset PCI device […] no FLR, PM reset or bus reset available
Users have serveral solutions available to restore VM functionality
-
remove the offending controller from the disp-sys-usb VM and try to restart the VM.
-
disable the USB 3.0 in the BIOS.
-
try to force USB 2.0 modes for the USB ports
In dom0, force USB modes for all USB ports
lspci -nn | grep USB | cut -d '[' -f3 | cut -d ']' -f1 | xargs -I@ setpci -H1 -d @ d0.l=0
-
set the pci_strictreset option
In dom0, set the no-strict-reset option
qvm-pci attach --persistent --option no-strict-reset=true disp-sys-usb <backend>:<bdf>