Difference between revisions of "Hades"
(Update Hades from latest on GitHub) |
(Update Hades from latest on GitHub) |
||
(34 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
''This page was automatically generated. Please do not edit it'' | |||
[[File:hades_boot.png|thumb|Custom CUSF boot screen, made by [[User:HenryFranks|Henry]]]] | |||
Hades is a minimal Windows virtual machine designed for using SolidWorks on | |||
Linux. It is named after Hell itself, as that's what using Windows feels like | |||
(in [[User:EllieClifford|Ellie]]'s humble opinion). Hades has been successfully | |||
built for both SolidWorks 2018 SP03 and SolidWorks 2020 SP03. | |||
If you are a student at Cambridge, see | |||
[[Hades#Install Hades with our image|Install Hades with our image]]. The rest | |||
of this page is dedicated to installing and optimizing Hades from scratch. | |||
If you have all of the licenses required for Hades but are not a student at | |||
Cambridge, drop [[User:EllieClifford|Ellie]] or [[User:HenryFranks|Henry]] a | |||
message and we will authorize you to access the necessary files. Then see | |||
[[Hades#Install Hades with our image|Install Hades with our image]] | |||
If you are some sort of masochist (read: Gentoo user) and want to do it from | |||
scratch "for fun" despite having access to the prebuilt image, we can authorize | |||
you to access the proprietary source files too. | |||
= A Note on SolidWorks Network Licences = | |||
Using this without a SolidWorks Network License contravenes the SolidWorks | |||
licensing. However, this procedure ''does'' successfully convince SolidWorks that | |||
it’s not in a VM. This is justifiable because there are artificial locks | |||
against using "unsupported" hypervisors, so you couldn’t do it without tricking | |||
SolidWorks even with the correct license. Please don't sue us. | |||
= Install Hades with our image = | |||
The latest image (Revision 2) is built with: | |||
* Solidworks 2020 SP03 | |||
* Windows 10 21H1 English International | |||
* Virtio 0.1.208 | |||
{{Warning|This image is accessible over SSH from the host, with a publicly available key used by [[Charon]]. The key can also be found in <code>keys/</code>. Make sure that this is not accessible to anyone else on the network by making sure that the output of <code>nmap $(hostname -i)</code> does not show port 2200 as open.}} | |||
# Install QEMU, a SPICE viewer, and samba. As an example, on Arch Linux, that would look something like this: | |||
== | <source lang="bash">sudo pacman -S qemu virt-viewer samba</source> | ||
<ol start="2" style="list-style-type: decimal;"> | |||
<li><p>Download the image [https://files.cusf.co.uk/hades-v2/hades-v2.qcow2 here]. The file is currently accessible to Cambridge students only.</p></li> | |||
<li><p>(Optionally) verify the integrity and signature of the files by downloading [https://files.cusf.co.uk/hades-v2/hades-v2.qcow2.sha256 the checksum] and [https://files.cusf.co.uk/hades-v2/hades-v2.qcow2.asc the signature] and verifying them:</p></li></ol> | |||
<source lang="bash">gpg --import <(curl -L pgp.cusf.co.uk/ellie-clifford.asc) # Import Ellie's public key | |||
gpg --verify hades-v2.qcow2.asc hades-v2.qcow2 # Verify that Ellie signed the image | |||
sha256sum -c hades-v2.qcow2.sha256 # Verify the integrity of the image</source> | |||
<ol start="4" style="list-style-type: decimal;"> | |||
<li>Clone the Hades repository and install Hades with the image:</li></ol> | |||
<source lang="bash">git clone https://github.com/smh-my-head/hades | |||
cd hades | |||
make with-image image=path/to/hades-v2.qcow2 | |||
sudo make install</source> | |||
Then just run <code>hades</code> from a terminal (or in the normal way you would run programs) to start Hades. You may also want to see [[Hades#Start SolidWorks faster|Start SolidWorks faster]] to make starting SolidWorks quicker (note that this will decrease portability) | |||
[ | = Install Hades from scratch = | ||
== Prerequisites == | |||
'''On the host (Linux)''' | |||
* [https://github.com/smh-my-head/hades Hades] | |||
* QEMU (should be available in your package manager) | |||
* a SPICE viewer (e.g. virt-viewer). | |||
* [https://www.microsoft.com/en-gb/software-download/windows10ISO Windows ISO], | |||
* [https://github.com/virtio-win/virtio-win-pkg-scripts Virtio ISO] | |||
'''On the guest (Windows)''' | |||
* SPICE guest tools binary. Can be found [https://www.spice-space.org/download.html here] (navigate to ''Guest->Windows Binaries'') | |||
* SolidWorks installer (this can be downloaded on Linux, the Linux filesystem will be mapped as a network drive later on) | |||
== Setup == | |||
# First, grab the necessary ISOs and place theme at <code>./src/Win10.iso</code> and <code>./src/virtio-win.iso</code> | |||
# Run <code>make</code>. This will create a new VM image and begin the Windows installation, putting all the modifiable files in <code>run</code> (to keep the git working tree clean). You may need to press a key when it says ''"Press any key to boot from CD/DVD''". It may take a while to boot for the first time, don’t panic! If you get stuck in the VM, note that Ctrl-Alt-G releases the mouse. | |||
# Within the Windows VM, install the virtio drivers by following these instructions from the ArchWiki | |||
<blockquote>Windows will detect the fake disk and look for a suitable driver. If it fails, go to Device Manager, locate the SCSI drive with an exclamation mark icon (should be open), click Update driver and select the virtual CD-ROM. Do not navigate to the driver folder within the CD-ROM, simply select the CD-ROM drive and Windows will find the appropriate driver automatically (tested for Windows 7 SP1). | |||
</blockquote> | |||
<ol start="4" style="list-style-type: decimal;"> | |||
<li><p>Within the Windows VM, install the SPICE guest tools [https://www.spice-space.org/download.html here] (navigate to ''Guest->Windows Binaries'')</p></li> | |||
<li><p>Shutdown the VM and optionally edit <code>hades.sh</code> to change the core count and memory allocation to your preference.</p></li> | |||
<li><p>Run <code>sudo make install</code> to install Hades (or you can just run it with <code>hades.sh</code>)</p></li> | |||
<li><p>Start Hades again, and within Windows, connect to a the host filesystem with a loopback network device, by navigating in the file explorer to ''This PC -> Computer -> Map network drive'' and entering <code>\\10.0.2.4\qemu</code> under ''Folder:''. Then map the same device as an administrator by executing <code>net use z: \\10.0.2.4\qemu /persistent:yes</code> in an administrator command prompt.</p></li> | |||
<li><p>Install SolidWorks as usual. (If you downloaded it on Linux, you can install directly from the network drive)</p></li> | |||
<li><p>Optionally follow the instructions in [[Hades#Start SolidWorks faster|Start SolidWorks faster]] to set yourself up for starting SolidWorks quickly.</p></li></ol> | |||
== Suggestions == | |||
See the rest of the docs for ways to make the vm even better (including minifying, skipping some of the boot process, and other tweaks) | |||
* See [https://wiki.archlinux.org/index.php/QEMU this ArchWiki page] for advanced options, and [https://wiki.archlinux.org/index.php/PCI_passthrough_via_OVMF this ArchWiki page] to configure PCI passthrough and other performance tweaks. | |||
= Start SolidWorks faster = | |||
'''To set up:''' | |||
# Install <code>openbsd-netcat</code> (the name may vary, this is correct on Arch Linux) | |||
# Start Hades and open SolidWorks | |||
# On the host, open the qemu monitor with <code>hades-monitor</code> | |||
# Enter <code>savevm solidworks</code> in the qemu monitor. This will save a snapshot with the name <code>solidworks</code> | |||
# Run <code>sudo make solidworks</code> to install <code>solidworks</code> to your <code>PATH</code> | |||
'''To use:''' | |||
Start SolidWorks with <code>solidworks</code> and wait for the virtual machine to boot (there will be no feedback except something like “Connecting to graphic server” until it has booted). This usually takes 10-15 seconds, but can vary depending on a few factors. | |||
= SSH from the host to the guest = | |||
# Install msys2 on the guest. You can get the installer [https://www.msys2.org/ here] | |||
# Inside admin msys2, run <code>//10.0.2.4/qemu/path/to/util/msys2-setup.sh</code> | |||
# Open port 22 on the guest | |||
# From the host, run <code>ssh -p 2200 windows-username@localhost</code>. The user must have a password for this to work. You can use <code>passwd</code> to create one easily | |||
# Lots of things can go wrong. See [https://gist.github.com/samhocevar/00eec26d9e9988d080ac here] for common problems etc. It is possible to use ssh keys, but you will have to generate /etc/passwd and possibly /etc/group with <code>mkpasswd -l > /etc/passwd && mkgroup -l > /etc/group</code> | |||
= Clean and Minify = | |||
== From Guest == | |||
=== Compress Windows OS Files (Optional) === | |||
You can try compacting the OS from within Windows to reduce the size taken up by the OS. Whether or not this makes a difference is yet to be proved (see the pidgeon hole principle), so use at your own peril. | |||
To compress the OS files, open an administrator command prompt and run <code>compact.exe /CompactOS:always</code>. To disable OS file compression, run <code>compact.exe /CompactOS:never</code> from an admin prompt. | |||
=== Clear Data from Previously Uninstalled Programs === | |||
If you have installed and then later uninstalled programs, check both AppData and both Program Files folders for any storage used by these programs that’s no longer needed. | |||
In addition, registry entries from uninstalled programs may be found in the registry locations <code>Computer\HKEY_CURRENT_USER\SOFTWARE</code> and <code>Computer\HKEY_LOCAL_MACHINE\SOFTWARE</code>. | |||
=== Use the Built-In Windows Cleanup Tool === | |||
Windows comes pre-packaged with a tool for freeing up space on disk by deleting temporary and/or old system files. While this tool is not as thorough as others in this document, it is still valuable in the pursuit of the smallest possible VM image size. | |||
To use the tool, just search for ‘Disk Cleanup’. The program should be very easy to use from the GUI, and should be run for both user and system files. | |||
=== Cleanup the WinSxS Folder === | |||
Run <code>dism /Online /Cleanup-Image /StartComponentCleanup /ResetBase</code> and then <code>dism /Online /Cleanup-Image /SPSuperseded</code> from an administrator command prompt. | |||
=== Clear the SoftwareDistribution folder === | |||
This folder is safe to remove. Windows will try to redownload it, but of course it can’t if you shrink the drive afterwards. Run the following from an administrator command prompt: | |||
<pre>net stop wuauserv | |||
net stop bits</pre> | |||
then remove the folder (if you start the services again windows will re-download it) | |||
=== Remove things from WindowsApps === | |||
Go ham deleting things in <code>C:\Program Files\WindowsApps</code>. The easiest way is to mount the image in Linux first: | |||
<pre>/path/to/util/qemu_mnt.sh /path/to/img.qcow2 | |||
sudo mount /dev/nbd0p3 /path/to/mount/point | |||
# delete the stuff | |||
sudo umount /path/to/mount/point | |||
/path/to/utiu/qemu_umnt.sh</pre> | |||
You may then need to go into ''Settings -> Apps and Features -> [Broken App] -> Advanced options -> Reset'' for each one. | |||
=== Defragment the Virtual Disk === | |||
Windows has a built-in tool for defragging the disk, [https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/defrag <code>defrag.exe</code>]. You’ll want to run this on the <code>C:</code> drive from an administrator prompt, and may want to use some of the following useful options: - <code>/u</code>: Print the progress of the operation on the screen. - <code>/v</code>: Print verbose output containing the fragmentation statistics. - <code>/x</code>: Perform free space consolidation on the specified volumes. - <code>/h</code>: Run the operation at normal priority (default is low). | |||
The recommended command (by Henry) is <code>defrag.exe c: /u /x /h</code>. Free space consolidation in particular is recommended in trying to reduce the size of the disk, but your mileage may vary. | |||
=== Shrink the Windows Partition === | |||
Windows could be considered gaseous, in that it tends to fill the volume of whatever container it’s in. To stop Windows from taking any and all free space, you can shrink the partition with the built-in Disk Manager GUI. Make sure to note down the final disk size. | |||
=== Zero Empty Disk Space === | |||
The ‘empty’ space on the virtual hard disk may be full of junk data, and Windows would never tell you. To truly clear this space, you will need to use the Windows sysinternals tool [https://docs.microsoft.com/en-us/sysinternals/downloads/sdelete SDelete]. | |||
To use SDelete, open an administrator command prompt and run (from within the downloaded folder) <code>sdelete64.exe -c c:</code> followed by <code>sdelete64.exe -z c:</code>. What these commands do is first clean, then zero the free space respectively. | |||
== From Host == | |||
=== Shrink VM Image === | |||
QEMU provides a tool for resizing a qcow2 image, <code>qemu-img resize</code>. To shrink the size of the disk (make sure not to make it smaller than the Windows partition!), use <code>qemu-img resize --shrink img.qcow2 SIZE</code> (see <code>man qemu-img</code> for SIZE). | |||
=== Remove recovery partition === | |||
In powershell or command prompt (as administrator): | |||
<pre>diskpart | |||
list disk | |||
select disk # | |||
list partition | |||
select partition # | |||
delete partition override</pre> | |||
=== Sparsify and Compress VM Image === | |||
An important step in minimising image size is to sparsify it. Optionally, you can compress the image at the same time, although this can make disk speeds slower). To sparsify and compress the image, run <code>qemu-img convert -c -O qcow2 img.qcow2 img-compressed.qcow2</code>, and leave the <code>-c</code> flag out if you would rather not compress the image. | |||
To undo this change, you can use <code>qemu-img convert -O qcow2 img-compressed.qcow2 img.qcow2</code>. | |||
= Tweak Windows for a better user experience = | |||
=== Run the Windows 10 Debloater === | |||
To easily remove much of the pre-packaged bloatware in Windows 10, you can use [https://github.com/Sycnex/Windows10Debloater this debloating script]. A full guide to using the script can be found in the repo, but if you’re unsure, you can’t go wrong with the GUI. Except maybe bricking your system. Probably not though. | |||
=== Disable UAC === | |||
Although often controversial, no one really likes UAC. Don’t lie, you always just click allow anyway, so you might as well save yourself the trouble and disable it altogether. This can be done through the Control Panel, under ''User Account and Family Safety -> User Accounts -> Change User Account Control settings'', by dragging the slider to the bottom (‘Never notify’). | |||
=== Clean up the Taskbar === | |||
The taskbar serves very little purpose on a virtual machine, so it’s recommended to clean it up a bit (read: almost completely). To do this, open Settings and navigate to ''Taskbar -> Turn System Icons On and Off''. | |||
=== Hide the Recycle Bin Icon from the Desktop === | |||
If you’re using the remote mounted host filesytem (and you should be), the Windows recycle bin serves little purpose and blocks out some of the wallpaper, which should be appreciated in its full glory. To disable it, open Settings and navigate to ''Personalization -> Themes, Desktop Icon Settings'' and disable it from there. | |||
=== Disable Notifications === | |||
A desktop operating system should not need notifications. If you feel you need to be notified the instant someone wants to contact you, buy a phone. Notifications should be disabled through ''Settings -> System -> Notifications & actions'', and toggling the switch under ‘Get notifications from apps and other senders’ to the off position. | |||
=== Disable Action Center === | |||
Following on from the previous point, the quick settings do not belong in a notification center. That is what the taskbar is for. The cloest way to disable this particular piece of bloat by ensuring the ‘Action Center’ taskbar icon is disabled, and then make sure to ignore its existence. Unfortunately Windows does not currently allow users to completely disable the Action Center, but consider it out of sight and out of mind. | |||
=== Disable Unneeded Startup Programs === | |||
Download autoruns from sysinternals [https://docs.microsoft.com/en-us/sysinternals/downloads/autoruns here], and use the included GUI to disable startup programs at your own discretion. | |||
=== Set the Holy Wallpaper === | |||
Download [https://i.imgur.com/LwYlpqn.png this wallpaper] and set it as the desktop picture. This is a ''vital'' configuration step. | |||
=== Enable ‘Ultimate Performance’ === | |||
To maximise Windows performance, first launch the built-in utility <code>powercfg</code> to enable the ‘Ultimate Performance’ setting, by running <code>powercfg.exe -duplicatescheme e9a42b02-d5df-448d-aa00-03f14749eb61</code> from an administrator command prompt. After making the option visible, open Control Panel and select the option under ''Hardware and Sound -> Power Options -> Choose a power plan''. | |||
Additionally, you can also go to ''Settings -> System -> About -> Advanced system settings -> Performance Options'' and select ‘Adjust for best performance’. | |||
=== Disable All Telemetry === | |||
No explanation needed. Just make your way on over to ''Settings -> Privacy'' and go HAM from there. In addition, there are numerous tutorials available online describing several additional steps to disable Microsoft Telemetry. | |||
In all honesty, the subject of disabling Microsoft telemetry could constitute and entire document of its own, and this section should, at some point in the future, be updated with a more detailed guide. | |||
=== Disable Search Indexing === | |||
To disable Windows search indexing, and stop the service regularly consuming valuable resources, run <code>services.msc</code> and locate the ‘Windows Search’ service. Double click the service, and under the drop-down menu entitled ‘startup type’, select ‘Disable’. | |||
=== Disable Hibernation === | |||
Hibernation isn’t really needed for a virtual machine, and can be disabled by running the command <code>powercfg.exe /hibernate off</code> as an administrator. | |||
=== Disable Visual Effects === | |||
We don’t need animations or glossy finishes; while these options make for cool screenshots, they really only make the VM run slower. Disable them under ''Settings -> Ease of Access -> Display -> Simplify and personalise Windows''. | |||
=== Disable Lock Screen === | |||
A computer does not need a lock screen. It is not a cell phone. Disable the lock screen (and jump straight to the login prompt) by first opening regedit and navigating to <code>HKLM\SOFTWARE\Policies\Microsoft\Windows</code>. From here, create a new key called <code>Personalization</code>, and give this key a single DWORD called <code>NoLockScreen</code> with the value <code>0x00000000</code> (0). | |||
=== Disable Swap === | |||
Disabling the swapfile (pagefile) is a hotly-debated topic. If you would like to do it, it can be done by opening ''Settings -> System -> About -> Advanced system settings -> Performance Options -> Advanced -> Virtual memory'', clicking ‘Change’ and clicking the checkbox for ‘Automatically manage paging file size for all drives’ followed by the radio button for ‘No paging file’. Then click Ok back through all the menus. | |||
= Install the SolidWorks Dracula theme = | |||
This is an essential step if you value the sustained function of your eyes. Full instructions can be found [https://draculatheme.com/solidworks here]. | |||
= Enable the CUSF boot logo = | |||
# Generate the right type of bitmap with <code>./util/make_boot_logo.sh</code>. The result will be at <code>./img/Logo.bmp</code>. | |||
# Compile [https://github.com/tianocore/edk2 EDK2], replacing <code>edk2/MdeModulePkg/Logo/Logo.bmp</code> with <code>./img/Logo.bmp</code>. | |||
# Convert <code>./OVMF_VARS.fd</code> (the compilation output) to qcow2 format with <code>qemu-img convert -0 qcow2 OVMF_VARS.fd OVMF_VARS.qcow2</code> | |||
# Replace <code>./OVMF_VARS.qcow2</code> with the new file you have just created | |||
# ??? | |||
# Profit |
Latest revision as of 13:12, 15 October 2024
This page was automatically generated. Please do not edit it
Hades is a minimal Windows virtual machine designed for using SolidWorks on Linux. It is named after Hell itself, as that's what using Windows feels like (in Ellie's humble opinion). Hades has been successfully built for both SolidWorks 2018 SP03 and SolidWorks 2020 SP03.
If you are a student at Cambridge, see Install Hades with our image. The rest of this page is dedicated to installing and optimizing Hades from scratch.
If you have all of the licenses required for Hades but are not a student at Cambridge, drop Ellie or Henry a message and we will authorize you to access the necessary files. Then see Install Hades with our image
If you are some sort of masochist (read: Gentoo user) and want to do it from scratch "for fun" despite having access to the prebuilt image, we can authorize you to access the proprietary source files too.
A Note on SolidWorks Network Licences
Using this without a SolidWorks Network License contravenes the SolidWorks licensing. However, this procedure does successfully convince SolidWorks that it’s not in a VM. This is justifiable because there are artificial locks against using "unsupported" hypervisors, so you couldn’t do it without tricking SolidWorks even with the correct license. Please don't sue us.
Install Hades with our image
The latest image (Revision 2) is built with:
- Solidworks 2020 SP03
- Windows 10 21H1 English International
- Virtio 0.1.208
keys/
. Make sure that this is not accessible to anyone else on the network by making sure that the output of nmap $(hostname -i)
does not show port 2200 as open.- Install QEMU, a SPICE viewer, and samba. As an example, on Arch Linux, that would look something like this:
sudo pacman -S qemu virt-viewer samba
Download the image here. The file is currently accessible to Cambridge students only.
(Optionally) verify the integrity and signature of the files by downloading the checksum and the signature and verifying them:
gpg --import <(curl -L pgp.cusf.co.uk/ellie-clifford.asc) # Import Ellie's public key
gpg --verify hades-v2.qcow2.asc hades-v2.qcow2 # Verify that Ellie signed the image
sha256sum -c hades-v2.qcow2.sha256 # Verify the integrity of the image
- Clone the Hades repository and install Hades with the image:
git clone https://github.com/smh-my-head/hades
cd hades
make with-image image=path/to/hades-v2.qcow2
sudo make install
Then just run hades
from a terminal (or in the normal way you would run programs) to start Hades. You may also want to see Start SolidWorks faster to make starting SolidWorks quicker (note that this will decrease portability)
Install Hades from scratch
Prerequisites
On the host (Linux)
- Hades
- QEMU (should be available in your package manager)
- a SPICE viewer (e.g. virt-viewer).
- Windows ISO,
- Virtio ISO
On the guest (Windows)
- SPICE guest tools binary. Can be found here (navigate to Guest->Windows Binaries)
- SolidWorks installer (this can be downloaded on Linux, the Linux filesystem will be mapped as a network drive later on)
Setup
- First, grab the necessary ISOs and place theme at
./src/Win10.iso
and./src/virtio-win.iso
- Run
make
. This will create a new VM image and begin the Windows installation, putting all the modifiable files inrun
(to keep the git working tree clean). You may need to press a key when it says "Press any key to boot from CD/DVD". It may take a while to boot for the first time, don’t panic! If you get stuck in the VM, note that Ctrl-Alt-G releases the mouse. - Within the Windows VM, install the virtio drivers by following these instructions from the ArchWiki
Windows will detect the fake disk and look for a suitable driver. If it fails, go to Device Manager, locate the SCSI drive with an exclamation mark icon (should be open), click Update driver and select the virtual CD-ROM. Do not navigate to the driver folder within the CD-ROM, simply select the CD-ROM drive and Windows will find the appropriate driver automatically (tested for Windows 7 SP1).
Within the Windows VM, install the SPICE guest tools here (navigate to Guest->Windows Binaries)
Shutdown the VM and optionally edit
hades.sh
to change the core count and memory allocation to your preference.Run
sudo make install
to install Hades (or you can just run it withhades.sh
)Start Hades again, and within Windows, connect to a the host filesystem with a loopback network device, by navigating in the file explorer to This PC -> Computer -> Map network drive and entering
\\10.0.2.4\qemu
under Folder:. Then map the same device as an administrator by executingnet use z: \\10.0.2.4\qemu /persistent:yes
in an administrator command prompt.Install SolidWorks as usual. (If you downloaded it on Linux, you can install directly from the network drive)
Optionally follow the instructions in Start SolidWorks faster to set yourself up for starting SolidWorks quickly.
Suggestions
See the rest of the docs for ways to make the vm even better (including minifying, skipping some of the boot process, and other tweaks)
- See this ArchWiki page for advanced options, and this ArchWiki page to configure PCI passthrough and other performance tweaks.
Start SolidWorks faster
To set up:
- Install
openbsd-netcat
(the name may vary, this is correct on Arch Linux) - Start Hades and open SolidWorks
- On the host, open the qemu monitor with
hades-monitor
- Enter
savevm solidworks
in the qemu monitor. This will save a snapshot with the namesolidworks
- Run
sudo make solidworks
to installsolidworks
to yourPATH
To use:
Start SolidWorks with solidworks
and wait for the virtual machine to boot (there will be no feedback except something like “Connecting to graphic server” until it has booted). This usually takes 10-15 seconds, but can vary depending on a few factors.
SSH from the host to the guest
- Install msys2 on the guest. You can get the installer here
- Inside admin msys2, run
//10.0.2.4/qemu/path/to/util/msys2-setup.sh
- Open port 22 on the guest
- From the host, run
ssh -p 2200 windows-username@localhost
. The user must have a password for this to work. You can usepasswd
to create one easily - Lots of things can go wrong. See here for common problems etc. It is possible to use ssh keys, but you will have to generate /etc/passwd and possibly /etc/group with
mkpasswd -l > /etc/passwd && mkgroup -l > /etc/group
Clean and Minify
From Guest
Compress Windows OS Files (Optional)
You can try compacting the OS from within Windows to reduce the size taken up by the OS. Whether or not this makes a difference is yet to be proved (see the pidgeon hole principle), so use at your own peril.
To compress the OS files, open an administrator command prompt and run compact.exe /CompactOS:always
. To disable OS file compression, run compact.exe /CompactOS:never
from an admin prompt.
Clear Data from Previously Uninstalled Programs
If you have installed and then later uninstalled programs, check both AppData and both Program Files folders for any storage used by these programs that’s no longer needed.
In addition, registry entries from uninstalled programs may be found in the registry locations Computer\HKEY_CURRENT_USER\SOFTWARE
and Computer\HKEY_LOCAL_MACHINE\SOFTWARE
.
Use the Built-In Windows Cleanup Tool
Windows comes pre-packaged with a tool for freeing up space on disk by deleting temporary and/or old system files. While this tool is not as thorough as others in this document, it is still valuable in the pursuit of the smallest possible VM image size.
To use the tool, just search for ‘Disk Cleanup’. The program should be very easy to use from the GUI, and should be run for both user and system files.
Cleanup the WinSxS Folder
Run dism /Online /Cleanup-Image /StartComponentCleanup /ResetBase
and then dism /Online /Cleanup-Image /SPSuperseded
from an administrator command prompt.
Clear the SoftwareDistribution folder
This folder is safe to remove. Windows will try to redownload it, but of course it can’t if you shrink the drive afterwards. Run the following from an administrator command prompt:
net stop wuauserv net stop bits
then remove the folder (if you start the services again windows will re-download it)
Remove things from WindowsApps
Go ham deleting things in C:\Program Files\WindowsApps
. The easiest way is to mount the image in Linux first:
/path/to/util/qemu_mnt.sh /path/to/img.qcow2 sudo mount /dev/nbd0p3 /path/to/mount/point # delete the stuff sudo umount /path/to/mount/point /path/to/utiu/qemu_umnt.sh
You may then need to go into Settings -> Apps and Features -> [Broken App] -> Advanced options -> Reset for each one.
Defragment the Virtual Disk
Windows has a built-in tool for defragging the disk, defrag.exe
. You’ll want to run this on the C:
drive from an administrator prompt, and may want to use some of the following useful options: - /u
: Print the progress of the operation on the screen. - /v
: Print verbose output containing the fragmentation statistics. - /x
: Perform free space consolidation on the specified volumes. - /h
: Run the operation at normal priority (default is low).
The recommended command (by Henry) is defrag.exe c: /u /x /h
. Free space consolidation in particular is recommended in trying to reduce the size of the disk, but your mileage may vary.
Shrink the Windows Partition
Windows could be considered gaseous, in that it tends to fill the volume of whatever container it’s in. To stop Windows from taking any and all free space, you can shrink the partition with the built-in Disk Manager GUI. Make sure to note down the final disk size.
Zero Empty Disk Space
The ‘empty’ space on the virtual hard disk may be full of junk data, and Windows would never tell you. To truly clear this space, you will need to use the Windows sysinternals tool SDelete.
To use SDelete, open an administrator command prompt and run (from within the downloaded folder) sdelete64.exe -c c:
followed by sdelete64.exe -z c:
. What these commands do is first clean, then zero the free space respectively.
From Host
Shrink VM Image
QEMU provides a tool for resizing a qcow2 image, qemu-img resize
. To shrink the size of the disk (make sure not to make it smaller than the Windows partition!), use qemu-img resize --shrink img.qcow2 SIZE
(see man qemu-img
for SIZE).
Remove recovery partition
In powershell or command prompt (as administrator):
diskpart list disk select disk # list partition select partition # delete partition override
Sparsify and Compress VM Image
An important step in minimising image size is to sparsify it. Optionally, you can compress the image at the same time, although this can make disk speeds slower). To sparsify and compress the image, run qemu-img convert -c -O qcow2 img.qcow2 img-compressed.qcow2
, and leave the -c
flag out if you would rather not compress the image.
To undo this change, you can use qemu-img convert -O qcow2 img-compressed.qcow2 img.qcow2
.
Tweak Windows for a better user experience
Run the Windows 10 Debloater
To easily remove much of the pre-packaged bloatware in Windows 10, you can use this debloating script. A full guide to using the script can be found in the repo, but if you’re unsure, you can’t go wrong with the GUI. Except maybe bricking your system. Probably not though.
Disable UAC
Although often controversial, no one really likes UAC. Don’t lie, you always just click allow anyway, so you might as well save yourself the trouble and disable it altogether. This can be done through the Control Panel, under User Account and Family Safety -> User Accounts -> Change User Account Control settings, by dragging the slider to the bottom (‘Never notify’).
Clean up the Taskbar
The taskbar serves very little purpose on a virtual machine, so it’s recommended to clean it up a bit (read: almost completely). To do this, open Settings and navigate to Taskbar -> Turn System Icons On and Off.
Hide the Recycle Bin Icon from the Desktop
If you’re using the remote mounted host filesytem (and you should be), the Windows recycle bin serves little purpose and blocks out some of the wallpaper, which should be appreciated in its full glory. To disable it, open Settings and navigate to Personalization -> Themes, Desktop Icon Settings and disable it from there.
Disable Notifications
A desktop operating system should not need notifications. If you feel you need to be notified the instant someone wants to contact you, buy a phone. Notifications should be disabled through Settings -> System -> Notifications & actions, and toggling the switch under ‘Get notifications from apps and other senders’ to the off position.
Disable Action Center
Following on from the previous point, the quick settings do not belong in a notification center. That is what the taskbar is for. The cloest way to disable this particular piece of bloat by ensuring the ‘Action Center’ taskbar icon is disabled, and then make sure to ignore its existence. Unfortunately Windows does not currently allow users to completely disable the Action Center, but consider it out of sight and out of mind.
Disable Unneeded Startup Programs
Download autoruns from sysinternals here, and use the included GUI to disable startup programs at your own discretion.
Set the Holy Wallpaper
Download this wallpaper and set it as the desktop picture. This is a vital configuration step.
Enable ‘Ultimate Performance’
To maximise Windows performance, first launch the built-in utility powercfg
to enable the ‘Ultimate Performance’ setting, by running powercfg.exe -duplicatescheme e9a42b02-d5df-448d-aa00-03f14749eb61
from an administrator command prompt. After making the option visible, open Control Panel and select the option under Hardware and Sound -> Power Options -> Choose a power plan.
Additionally, you can also go to Settings -> System -> About -> Advanced system settings -> Performance Options and select ‘Adjust for best performance’.
Disable All Telemetry
No explanation needed. Just make your way on over to Settings -> Privacy and go HAM from there. In addition, there are numerous tutorials available online describing several additional steps to disable Microsoft Telemetry.
In all honesty, the subject of disabling Microsoft telemetry could constitute and entire document of its own, and this section should, at some point in the future, be updated with a more detailed guide.
Disable Search Indexing
To disable Windows search indexing, and stop the service regularly consuming valuable resources, run services.msc
and locate the ‘Windows Search’ service. Double click the service, and under the drop-down menu entitled ‘startup type’, select ‘Disable’.
Disable Hibernation
Hibernation isn’t really needed for a virtual machine, and can be disabled by running the command powercfg.exe /hibernate off
as an administrator.
Disable Visual Effects
We don’t need animations or glossy finishes; while these options make for cool screenshots, they really only make the VM run slower. Disable them under Settings -> Ease of Access -> Display -> Simplify and personalise Windows.
Disable Lock Screen
A computer does not need a lock screen. It is not a cell phone. Disable the lock screen (and jump straight to the login prompt) by first opening regedit and navigating to HKLM\SOFTWARE\Policies\Microsoft\Windows
. From here, create a new key called Personalization
, and give this key a single DWORD called NoLockScreen
with the value 0x00000000
(0).
Disable Swap
Disabling the swapfile (pagefile) is a hotly-debated topic. If you would like to do it, it can be done by opening Settings -> System -> About -> Advanced system settings -> Performance Options -> Advanced -> Virtual memory, clicking ‘Change’ and clicking the checkbox for ‘Automatically manage paging file size for all drives’ followed by the radio button for ‘No paging file’. Then click Ok back through all the menus.
Install the SolidWorks Dracula theme
This is an essential step if you value the sustained function of your eyes. Full instructions can be found here.
Enable the CUSF boot logo
- Generate the right type of bitmap with
./util/make_boot_logo.sh
. The result will be at./img/Logo.bmp
. - Compile EDK2, replacing
edk2/MdeModulePkg/Logo/Logo.bmp
with./img/Logo.bmp
. - Convert
./OVMF_VARS.fd
(the compilation output) to qcow2 format withqemu-img convert -0 qcow2 OVMF_VARS.fd OVMF_VARS.qcow2
- Replace
./OVMF_VARS.qcow2
with the new file you have just created - ???
- Profit