Hades

From CUSF Wiki
Revision as of 17:55, 30 April 2021 by EllieClifford (talk | contribs) (Update Hades from latest on GitHub)
Jump to navigation Jump to search

This page was automatically generated. Please do not edit it

Custom CUSF boot screen, made by 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 Tim's humble opinion).

If you have all of the licenses required for Hades (being a student at Cambridge is enough), drop Tim or Henry a message and we will authorize you to access the prebuilt image (10GB). Then see Install Hades with our image. The rest of this page is dedicated to installing and optimizing Hades from scratch.

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, you can get all the proprietary source files here (20GB).

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

  1. 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
  1. Download the image here. If you get a permission error, you will need to message Tim or Henry to get access.

  2. (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/tim-clifford.asc) # Import Tim's public key
gpg --verify hades-rev1.qcow2.asc hades-rev1.qcow2 # Verify that Tim signed the image
sha256sum -c hades-rev1.qcow2.sha256 # Verify the integrity of the image
  1. 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-rev1.qcow2
sudo make install

Then just run hades from a terminal (or in the normal way you would run programs) to start Hades. The password is a. 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)

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

  1. First, grab the necessary ISOs and place theme at ./src/Win10.iso and ./src/virtio-win.iso
  2. Run make. This will create a new VM image and begin the Windows installation, putting all the modifiable files in run (to keep the git working tree clean). It may take a while to boot for the first time, don’t panic! If you get stuck in the VM, know that Ctrl-Alt-G releases the mouse.
  3. Within Windows, 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).

  1. Within Windows, install the SPICE guest tools here (navigate to Guest->Windows Binaries)

  2. Shutdown the VM and optionally edit hades.sh to change the core count and memory allocation to your preference.

  3. Run sudo make install to install Hades (or you can just run it with hades.sh)

  4. 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:

  5. Install SolidWorks as usual. (If you downloaded it on Linux, you can install directly from the network drive)

  6. 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)

Start SolidWorks faster

To set up:

  1. Install openbsd-netcat (the name may vary, this is correct on Arch Linux)
  2. Start Hades and open SolidWorks
  3. On the host, open the qemu monitor with hades-monitor
  4. Enter savevm solidworks in the qemu monitor. This will save a snapshot with the name solidworks
  5. Run sudo make solidworks to install solidworks to your PATH

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

  1. Install msys2 on the guest. You can get the installer here
  2. Inside admin msys2, run //10.0.2.4/qemu/path/to/util/msys2-setup.sh
  3. Open port 22 on the guest
  4. From the host, run ssh -p 6969 windows-username@localhost. The user must have a password for this to work. You can use passwd to create one easily

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.

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).

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