šØāš» Reinstalling Windows - the bittersweet pain of PC ownership! Itās the one task that every computer user dreads. And yet, when I visit my parents, itās a task that I am often called upon to do with alarming frequency. It seems like every time I arrive, thereās a different PC in need of some TLC. Malware, viruses, registry issues, HDD replacements - all contributing to slow and sluggish performance.
As a software engineer, I knew there had to be a more efficient way of dealing with this. And so, I turned to disk images. I tried a number of different solutions for disk cloning, but surprisingly, the best tool for the job turned out to be good old UNIX āddā. Who would have thought?!
Hereās how I make it happen:
I detach the SSD from the PC in question and connect it to my trusty MacBook.
Using qemu, I install Windows 10 from an ISO image. Pro tip - this works on Linux too! ```bash #!/bin/bash
DISK=${1:-disk.img} ISO=${2:-}
if ! command -v qemu-system-x86_64 2> /dev/null; then brew install qemu fi
for d in ${DISK}*; do diskutil unmount ā$dā done
exec qemu-system-x86_64
-m 8096
-usb
-device usb-tablet
-monitor stdio
-device intel-hda
-machine type=q35,accel=hvf
-cpu Haswell
-hda ā$DISKā
-boot d -cdrom $ISOā
Just remember - for Linux users, you'll need to change `accel=hvf` to `kvm`.
3. Install all the necessary software. I like to use Chocolatey (like `apt-get` or `brew` but for Windows) to bulk install basic essentials like Opera (my parents' fave), Telegram, and mpv (a lightweight and powerful video player).
Pro tip: To install it, just run
```powershell
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
Attach the disk. I use a trusty USB-SATA adapter, but donāt forget to check diskutility
to see what the device file is for the attached disk. It could be something like /dev/disk2
(on a Mac).
dd
command again (but donāt worry, itās not as scary as it looks):
sudo dd if=disk.img of=${DIS} bs=1M status=progress
If you prefer, you can also use Etcher, which makes flashing images to flash/HDD/SSD a breeze.
bzip -9 disk.img
And thatās it! With these simple steps, I now have a reliable and efficient way to reinstall Windows on multiple PCs without the hassle of doing everything manually. Maybe someday Iāll convince my parents to switch to Linuxā¦but until then, weāll keep on reinstalling.