This is description of how to backup raw partitions in preparation for switching a new machine to Linux. The main reason would be to preserve a brand new Windows licence key and driver installation to ease installation/restoration for switchimg the computer back at a later date.
Another method would be preferable (or at least more steps need to be taken) to set up dual boot
or preserving/migrating data from a Windows installation currently in use (in which case
rsync to a backup drive would be a better solution).
Save a copy of your Windows activation key first: this should be stored in the UEFI/ACPI firmware MSDM table, but it is better to record ssomewhere safely. You may also have a hard copy in the documetation that came with (or a sticker right on) your new hardware.
Start up the computer and press Shift+F10 to open up a command prompt in the Windows installer and run (it may take a little while for the dialog to come up):
powershell "(Get-CimInstance SoftwareLicensingService).OA3xOriginalProductKey"slmgr /dli and confirm that is the key in usesudo setfont /usr/share/consolefonts/Lat15-TerminusBold32x16.psf.gz to use a larger font.lsblk -f: pick the backup partition (for this example, I’ll use /dev/sdb3 — change to yours)sudo mkdir /mnt/backupsudo mount /dev/sdb3 /mnt/backup/sudo mkdir /mnt/backup/windowscd /mnt/backup/windows/sudo chmod go+w .sudo strings /sys/firmware/acpi/tables/MSDM | tail -1 | tee activation.keywpa_passphrase <Your Wi-Fi SSID> | sudo tee /etc/wpa_supplicant.confsudo wpa_supplicant -B -i wlp0s20f3 -c /etc/wpa_supplicant.confsudo dhcpcd wlp0s20f3sudo apt updatesudo apt install gdisksudo apt install partclonefdisk -l and pick out your Windows drive (probably /dev/nvme0n1)sudo sgdisk --backup=gpt.bin /dev/nvme0n1sudo sfdisk --dump /dev/nvme0n1 > ptable.sfdisklsblk -f to confirm that you have the standard Windows installation layout.sudo partclone.vfat -c -s /dev/nvme0n1p1 | zstd > p1-efi.pcl.zst — EFI partitionsudo dd if=/dev/nvme0n1p2 | zstd > p2-msr.img.zst — Microsoft Reservedsudo partclone.ntfs -c -s /dev/nvme0n1p3 | zstd > p3-windows.pcl.zst — Windows C: drivesudo partclone.ntfs -c -s /dev/nvme0n1p4 | zstd > p4-recovery.pcl.zst — Windows Recoverycd /sudo umount /mnt/backupsudo sgdisk -p /dev/nvme0n1 — it is probably the first one (1)sudo sgdisk -d 2 -d 3 -d 4 /dev/nvme0n1 — delete the rest (other three: 2, 3, and 4)sudo sgdisk -n 2:0:+512M -t 2:8300 -c 2:boot /dev/nvme0n1 — create a 500 MiB partitionsudo sgdisk -n 3:0:0 -t 3:8309 -c 3:root /dev/nvme0n1 — create a partition container for LUKS/LVMsudo wipefs -a /dev/nvme0n1p2 /dev/nvme0n1p3