From 4706ee2467dd1522726cd8864d8ccbad53263ec3 Mon Sep 17 00:00:00 2001 From: taradiddles Date: Fri, 23 Feb 2018 20:53:58 +0200 Subject: [PATCH 001/295] Add windows.md instructions --- managing-os/windows/windows-vm.md | 268 ++++++++++++++++++++++++++++++ 1 file changed, 268 insertions(+) create mode 100644 managing-os/windows/windows-vm.md diff --git a/managing-os/windows/windows-vm.md b/managing-os/windows/windows-vm.md new file mode 100644 index 00000000..5e991ea0 --- /dev/null +++ b/managing-os/windows/windows-vm.md @@ -0,0 +1,268 @@ +--- +layout: doc +title: Installing a Windows VM +permalink: /doc/windows-vm/ +--- + + +Installing a Windows VM +======================= + +Importing from R3.2 to R4.x +--------------------------- + +Importing should work, simply make sure that you are not using Xen's newer linux stubdomain and that the VM is in HVM mode (these steps should be done automatically when importing the VM): + +R4.0: +~~~ +qvm-features VMNAME linux-stubdom '' +qvm-prefs VMNAME virt_mode hvm +~~~ + +Note however that you are better off creating a new Windows VM to benefit from the more recent emulated hardware: R3.2 uses a MiniOS based stubdomain with an old and mostly unmaintained 'qemu-traditional' while R4.0 uses a Linux based stubdomain with a recent version of upstream qemu (see [this post](https://groups.google.com/d/msg/qubes-devel/tBqwJmOAJ94/xmFCGJnuAwAJ)). + + +Windows installation +---------------------- + +See [below](/doc/windows-vm/#command-summary) if you are only looking for a quick summary of the necessary commands. + +MS Windows versions considerations: + +- The instructions *may* work on other versions than Windows 7 x74 but haven't been tested. +- Qubes Windows Tools (QWT) only supports Windows 7 x64. + + +Create a VM named win7new in [HVM](/doc/hvm/) mode (Xen's current PVH limitations precludes from using PVH): + +R3.2: +~~~ +qvm-create win7new --hvm --label red +~~~ + +R4.0: +~~~ +qvm-create --class StandaloneVM --label red --property virt_mode=hvm win7new +~~~ + +Windows' installer requires a significant amount of memory or else the VM will crash with such errors: + +`/var/log/xen/console/hypervisor.log`: + +> p2m_pod_demand_populate: Dom120 out of PoD memory! (tot=102411 ents=921600 dom120) +> (XEN) domain_crash called from p2m-pod.c:1218 +> (XEN) Domain 120 (vcpu#0) crashed on cpu#3: + +So, increase the VM's memory to 4000Mo (memory = maxmen because we don't use memory balancing). + +R3.2: +~~~ +qvm-prefs -s win7new memory 4000 +qvm-prefs -s win7new maxmem 4000 +~~~ + +R4.0: +~~~ +qvm-prefs win7new memory 4000 +qvm-prefs win7new maxmem 4000 +~~~ + + +On R4.0, disable direct boot so that the VM will go through the standard cdrom/HDD boot sequence: + +~~~ +qvm-prefs win7new kernel '' +~~~ + +A typical Windows 7 installation requires between 15Go up to 19Go of disk space depending on the version (Home/Professional/...). Windows updates also end up using significant space. So, extend the root volume from the default 10Go to 25Go (note: it is straightforward to increase the root volume size after Windows is installed: simply extend the volume again in dom0 and then extend the system partition with Windows's disk manager). + +R3.2: +~~~ +qvm-grow-root win7new 25g +~~~ + +R4.0: +~~~ +qvm-volume extend win7new:root 25g +~~~ + +Set the debug flag in order to have a graphical console: + +R3.2: +~~~ +qvm-prefs -s win7new debug true +~~~ + +R4.0: +~~~ +qvm-prefs win7new debug true +~~~ + +The second part of the installation process will crash with the standard vga video adapter and the VM will stay in "transient" mode with the following error in `guest-win7new-dm.log`: + +> qemu: /home/user/qubes-src/vmm-xen-stubdom-linux/build/qemu/exec.c:1187: cpu_physical_memory_snapshot_get_dirty: Assertion `start + length <= snap->end' failed. + +To avoid that error we temporarily have to switch the video adapter to 'cirrus': + +R3.2: backup the VM's configuration file and substitute the video driver from 'xen' to 'cirrus': +~~~ +cp /var/lib/qubes/appvms/win7new/win7new.conf /tmp +sed -i "s/ Manage / Device manager / Display adapters) temporarily re-enable the standard VGA adapter and disable "Qubes video driver". You can disable debugging and revert to Qubes' display once the VM is updated. + + +Xen PV drivers + Qubes integration +---------------------------------- + +If you plan to update your newly isntalled Windows VM it is recommended that you do so *before* installing Qubes Windows Tools (QWT). If QWT are installed, you should temporarily re-enable the standard VGA adapter in Windows and disable Qubes' (see the section above). + +Increase the VM's qrexec_timeout before installing QWT: + +- The first time the VM is run after QWT is installed, some time is needed to move the user profiles to the private volume (if you didn't disable that step in the installer, of course). +- In case you happen to get a BSOD or a similar crash in the VM, chkdsk won't complete on restart before qrexec_timeout automatically halts the VM. That can really put the VM in a totally unrecoverable state, whereas with higher qrexec_timeout, chkdsk or the appropriate utility has plenty of time to fix the VM. + +R3.2: +~~~ +qvm-prefs -s win7new qrexec_timeout 300 +~~~ + +R4.0: +~~~ +qvm-prefs win7new qrexec_timeout 300 +~~~ + +Installing QWT on R3.2: see [this page](/doc/windows-tools/) + +Installing QWT on R4.0: you'll have to install QWT for Qubes R3.2. See [issue #3585](https://github.com/QubesOS/qubes-issues/issues/3585) for instructions and known issues. + +Qubes Windows Tools install Xen's PV drivers by default so there is no need to install the [official ones](https://www.xenproject.org/developers/teams/windows-pv-drivers.html). *However*, Xen's VBD (storage) PV driver is disabled by default during QWT's setup and enabling it on a Windows 7 VM that isn't fully updated results in a BSOD and broken VM. Updating Windows takes *hours* and for casual usage there isn't much of a performance between the disk PV driver and the default one; so there is likely no need to go through the lengthy Windows Update process if your VM is isolated from the network and you don't use I/O intensive apps. +With a fully updated Windows 7 and QWT already installed (without the storage PV driver) you can install the storage PV driver from Xen's site (xenvbd.tar). + +You can now turn off debugging (early graphical console): + +R3.2: +~~~ +qvm-prefs -s win7new debug false +~~~ + +R4.0: +~~~ +qvm-prefs win7new debug false +~~~ + + +Tweaks +------ + +- Set a fixed size page file size (system properties / advanced tab / Performance settings / advanced tab / Virtual memory / Change...) +- Adjust for best performance (system properties / advanced tab / Performance settings). + + +Command summary +----------------- + +Most of the commands below can be combined into only a few commands but they are split for the sake of clarity. + +R3.2: +~~~ +qvm-create win7new --hvm --label red +qvm-prefs -s win7new memory 4000 +qvm-prefs -s win7new maxmem 4000 +qvm-grow-root win7new 25g +qvm-prefs -s win7new debug true +cp /var/lib/qubes/appvms/win7new/win7new.conf /tmp +sed -i "s/ Date: Fri, 23 Feb 2018 20:57:25 +0200 Subject: [PATCH 002/295] removed windows-appvms.md --- managing-os/windows/windows-appvms.md | 143 -------------------------- 1 file changed, 143 deletions(-) delete mode 100644 managing-os/windows/windows-appvms.md diff --git a/managing-os/windows/windows-appvms.md b/managing-os/windows/windows-appvms.md deleted file mode 100644 index 98f1c1f5..00000000 --- a/managing-os/windows/windows-appvms.md +++ /dev/null @@ -1,143 +0,0 @@ ---- -layout: doc -title: Windows AppVms -permalink: /doc/windows-appvms/ -redirect_from: -- /en/doc/windows-appvms/ -- /doc/WindowsAppVms/ -- /wiki/WindowsAppVms/ ---- - -Installing and using Windows-based AppVMs -========================================= - -Qubes provides special support for running Windows-based AppVMs. This requires the user to install Windows 7 x64 in a Qubes VM and subsequently install Qubes Windows Tools inside the VM (support for Windows 8+ is in development). This page describes this process in detail. - -Qubes Windows Tools are a set of programs and drivers that provide integration of Windows AppVMs with the rest of the Qubes system. Currently the following features are available for Windows VMs after installation of those tools: - -- Seamless GUI mode that integrates apps windows onto the common Qubes trusted desktop (available on Qubes R2 Beta 3 and later) -- Support for [secure clipboard copy/paste](/doc/copy-paste/) between the Windows VM and other AppVMs -- Support for [secure file exchange](/doc/copying-files/) between the Windows VM and other AppVMs -- Support for qvm-run and generic qrexec for the Windows VM (e.g. ability to run custom service within/from the Windows VM) -- Xen PV drivers for Windows that increase performance compared to qemu emulated devices - -Qubes Windows Tools are open source and are distributed under a GPL license. - -NOTE: Currently only 64-bit versions of Windows 7 are supported by Qubes Windows Tools. Only emulated SVGA GPU is supported (although [there has been reports](https://groups.google.com/forum/#!topic/qubes-users/cmPRMOkxkdA) on working GPU pass-through). There is currently no audio support for Windows HVMs. - -Installing Windows OS in a Qubes VM ------------------------------------ - -Please refer to [this page](/doc/hvm-create/) for instructions on how to install Windows in a Qubes VM. - -NOTE: It is strongly suggested to enable autologon for any Windows HVMs that will have Qubes Tools installed. To do so, run `netplwiz` command from the `Win+R`/Start menu and uncheck the *Users must enter a user name and password to use this computer* option. - -Installing Qubes guest tools in Windows 7 VMs ---------------------------------------------- - -First, make sure that `qubes-windows-tools` is installed in your system: - -~~~ -sudo qubes-dom0-update qubes-windows-tools -~~~ - -(If the above command does not work, it could be that the Qubes Tools are not in the stable repo yet. Try installing from the testing repo instead.) - -You can also install the package from testing repositories, where we usually publish new versions first: - -~~~ -sudo qubes-dom0-update --enablerepo=qubes-dom0-current-testing qubes-windows-tools -~~~ - -This package brings the ISO with Qubes Windows Tools that is passed to the VM when `--install-windows-tools` is specified for the `qvm-start` command. Please note that none of this software ever runs in Dom0 or any other part of the system except for the Windows AppVM in which it is to be installed. - -Before proceeding with the installation we need to disable Windows mechanism that allows only signed drivers to be installed, because currently (beta releases) the drivers we provide as part of the Windows Tools are not digitally signed with a publicly recognizable certificate. To do that: - -- Start command prompt as Administrator, i.e. right click on the Command Prompt icon and choose "Run as administrator" -- In the command prompt type `bcdedit /set testsigning on` -- Reboot your Windows VM - -In the future this step will not be necessary anymore, because we will sign our drivers with a publicly verifiable certificate. However, it should be noted that even now, the fact that those drivers are not digitally signed, this doesn't affect security of the Windows VM in 'any' way. This is because the actual installation ISO (the `qubes-windows-tools-*.iso` file) is distributed as a signed RPM package and its signature is verified by the `qubes-dom0-update` utility once it's being installed in Dom0. The only downside of those drivers not being signed is the inconvenience to the user that he or she must disable the signature enforcement policy before installing the tools. - -To install the Qubes Windows Tools in a Windows VM one should start the VM passing the additional option `--install-windows-tools`: - -~~~ -qvm-start lab-win7 --install-windows-tools -~~~ - -Once the Windows VM boots, a CDROM should appear in the 'My Computer' menu (typically as `D:`) with a setup program in its main directory. - -After successful installation, the Windows VM must be shut down and started again, possibly a couple of times (see [this page](/doc/windows-tools-3/) for detailed configuration options). - -Qubes (R2 Beta 3 and later releases) will automatically detect the tools has been installed in the VM and will set appropriate properties for the VM, such as `qrexec_installed`, `guiagent_installed`, and `default_user`. This can be verified (but is not required) using qvm-prefs command: - -~~~ -qvm-prefs -~~~ - -NOTE: it is recommended to increase the default value of Windows VM's `qrexec_timeout` property from 60 (seconds) to, for example, 300. During one of the first reboots after Windows Tools installation Windows user profiles are moved onto the private VM's virtual disk (private.img) and this operation can take some time. Moving profiles is performed in an early boot phase when qrexec is not yet running, so timeout may occur with the default value. To change the property use this command in dom0: - -~~~ -qvm-prefs -s qrexec_timeout 300 -~~~ - -Using Windows AppVMs in seamless mode (Qubes R2 Beta 3 and later) ------------------------------------------------------------------ - -Once you start a Windows-based AppVM with Qubes Tools installed, you can easily start individual applications from the VM (note the `-a` switch used here, which will auto-start the VM if it is not running): - -~~~ -qvm-run -a my-win7-appvm explorer.exe -~~~ - -![windows-seamless-4.png](/attachment/wiki/WindowsAppVms/windows-seamless-4.png) ![windows-seamless-1.png](/attachment/wiki/WindowsAppVms/windows-seamless-1.png) - -Also, the inter-VM services work as usual -- e.g. to request opening a document or URL in the Windows AppVM from another VM: - -~~~ -[user@work ~]$ qvm-open-in-vm work-win7 roadmap.pptx -~~~ - -~~~ -[user@work ~]$ qvm-open-in-vm work-win7 https://invisiblethingslab.com -~~~ - -... just like in the case of Linux AppVMs. Of course all those operations are governed by central policy engine running in Dom0 -- if the policy doesn't contain explicit rules for the source and/or target AppVM, the user will be asked whether to allow or deny the operation. - -Inter-VM file copy and clipboard works for Windows AppVMs the same way as for Linux AppVM (except that we don't provide a command line wrapper, `qvm-copy-to-vm` in Windows VMs) -- to copy files from Windows AppVMs just right-click on the file in Explorer, and choose: Send To-\> Other AppVM. - -To simulate CTRL-ALT-DELETE in the HVM (SAS, Secure Attention Sequence), press Ctrl-Alt-Home while having any window of this VM in the foreground. - -![windows-seamless-7.png](/attachment/wiki/WindowsAppVms/windows-seamless-7.png) - -Changing between seamless and full desktop mode ------------------------------------------------ - -You can switch between seamless and "full desktop" mode for Windows HVMs in their settings in Qubes Manager. The latter is the default. - -Using template-based Windows AppVMs (Qubes R2 Beta 3 and later) ---------------------------------------------------------------- - -Qubes allows HVM VMs to share a common root filesystem from a select Template VM, just like it is done for Linux AppVMs. This mode is not limited to Windows AppVMs, and can be used for any HVM (e.g. FreeBSD running in a HVM). In order to create a HVM TemplateVM one can use the following command: - -~~~ -qvm-create --hvm-template win7-x64-template -l green -~~~ - -... and install Windows OS (or other OS) into this template the same way as you would install it into a normal HVM -- please see instructions on [this page](/doc/hvm-create/). However, it would make lots of sense to store the `C:\Users` directory on the 2nd disk which is automatically exposed by Qubes to all HVMs. This 2nd disk is backed by the `private.img` file in the AppVMs' and is not reset upon AppVMs reboot, so the user's directories and profiles would survive the AppVMs reboot, unlike the "root" filesystem which will be reverted to the "golden image" from the Template VM automatically. To facilitate such separation of user profiles, Qubes Windows Tools provide an option to automatically move `C:\Users` directory to the 2nd disk backed by `private.img`. It's a selectable feature of the installer, enabled by default. If that feature is selected during installation, completion of the process requires two reboots: - -- The private disk is initialized and formatted on the first reboot after tools installation. It can't be done **during** the installation because Xen mass storage drivers are not yet active. -- User profiles are moved to the private disk on the next reboot after the private disk is initialized. Reboot is required because the "mover utility" runs very early in the boot process so OS can't yet lock any files in there. This can take some time depending on the profiles' size and because the GUI agent is not yet active dom0/Qubes Manager may complain that the AppVM failed to boot. That's a false alarm (you can increase AppVM's default boot timeout using `qvm-prefs`), the VM should appear "green" in Qubes Manager shortly after. - -It also makes sense to disable Automatic Updates for all the template-based AppVMs -- of course this should be done in the Template VM, not in individual AppVMs, because the system-wide settings are stored in the root filesystem (which holds the system-wide registry hives). Then, periodically check for updates in the Template VM and the changes will be carried over to any child AppVMs. - -Once the template has been created and installed it is easy to create AppVMs based on it: - -~~~ -qvm-create --hvm --template --label