Skip to content

Instantly share code, notes, and snippets.

@augustin64
Created April 28, 2023 10:04
Show Gist options
  • Save augustin64/58dcee79a9d9c5bebe607bb39a606f03 to your computer and use it in GitHub Desktop.
Save augustin64/58dcee79a9d9c5bebe607bb39a606f03 to your computer and use it in GitHub Desktop.
#!/bin/bash
MEMORY=8192
CORES=4
DISK_IMAGE=windows10.qcow2
LIVE_CD=Win10_French_x64.iso # Download this from https://www.microsoft.com/fr-fr/software-download/windows10
create () {
# Will create a blank disk of 64G maximum capacity
# It does not require 64G of disk space on your computer, but just creates a file that can contain up to 64G in a VM
qemu-img create -f qcow2 "$DISK_IMAGE" 64G
}
install () {
# Launch the actual installation of windows, you need to go through it manually
qemu-system-x86_64 \
-m $MEMORY \
-boot d \
-net nic \
-smp $CORES \
-net user \
-enable-kvm \
-hda "./$DISK_IMAGE" \
-cdrom "./$LIVE_CD"
}
start () {
# start the created VM
qemu-system-x86_64 \
-m $MEMORY \
-boot d \
-net nic \
-smp $CORES \
-net user \
-enable-kvm \
-hda "./$DISK_IMAGE"
}
@augustin64
Copy link
Author

First run:

source ./windows_vm.sh
create # Create the disk
install # Start the VM with the inserted installation disk

Once this has exited, start the VM using that command each time:

source ./windows_vm.sh
start

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment