Skip to content

Instantly share code, notes, and snippets.

@sirredbeard
Last active June 6, 2022 19:09
Show Gist options
  • Select an option

  • Save sirredbeard/aeb478f883adca49992a3c9d7903d940 to your computer and use it in GitHub Desktop.

Select an option

Save sirredbeard/aeb478f883adca49992a3c9d7903d940 to your computer and use it in GitHub Desktop.
Create a live bootable USB drive of your favorite distro with an extra exFAT partition large enough to hold the image you will be making (the used space on the HDD)
Boot the live bootable USB drive on the device with the HDD
Mount the HDD you want to create an image of, for example at /mnt/debiandrive
Mount the exFAT partition on your USB drive, for example at /mnt/exfatpart
Then you need to create a tar of the HDD contents /mnt/debiandrive in a tar on /mnt/exfatpart so something like:
sudo tar -cpzf /mnt/exfatpart/debian-image.tar.gz -C /mnt/debiandrive .
(sudo is necessary because some of the files you will be archiving will have higher permissions to read)
Safely unmount everything at this point
Take the USB drive to your Windows device (or reboot the drive into Windows if that is what you are doing)
Insert the USB, Windows should be able to mount the exFAT partition automatically
Copy debian-image.tar.gz from there to somewhere on your C:\ drive
Then use the wsl.exe --import tool, something like:
wsl.exe --import "Debian" C:\WSL\Debian C:\Users\prdevlin1\Downloads\debian-image.tar.gz
See https://docs.microsoft.com/en-us/windows/wsl/basic-commands#import-a-new-distribution
If you are booting Windows on the device with the Debian HDD on it, you may be able to use the new wsl.exe --mount command to mount the Debian drive directly and use another temporary WSL distro to create a tar without booting from another drive
See https://docs.microsoft.com/en-us/windows/wsl/basic-commands#mount-a-disk-or-device
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment