Are you enjoying your favorite Linux distro running within the Windows 10 Linux Subsystem?
Have you configured all nicely?
What happened if you get a new pc and you’d like to migrate your VM across?
This is what happened to me. And looking around, I found this post that gave me this kinda-dirty way, but did work!
After that, I decided to review the steps, and I’ve added these directories in the exclude’s list, to make clearer the process of export/import:
Of course, if you have important data in these folders and you want to move across too, just update the one-liner below accordingly. 😉
On your OLD PC
- Open your Linux VM
- Get inside your Downloads directory (replace <user> with your username):
- Make sure to be root (
sudo su -)
tar -cvpzf backup.tar.gz --exclude=/backup.tar.gz --exclude=/dev --exclude=/proc --exclude=/sys --exclude=/run --exclude=/tmp --exclude=/media --exclude=/mnt --exclude=/var/cache --exclude=/var/run --one-file-system /
NOTE: you could achieve the same using the option
--exclude-from=file.txt, and having the list of exclusions in this file. I used a one-liner as it’s quicker to copy and paste.
- Once done, close your Linux VM
- Verify that you have a new file called
On your NEW PC
- Install from Microsoft Store the same Linux VM (or reinstall in the same way you have done originally on your old pc)
- Copy across your
backup.tar.bzwithin your new Downloads folder
- Open the VM that you’ve just installed (minimal setup – this will be completely overwritten, so don’t be bothered too much)
- Once you’re inside and your
backup.tar.bzis in Download, run the following (replace <user> with your username):
sudo tar -xpzf /mnt/c/Users/<user>/Dowloads/backup.tar.gz -C / --numeric-owner
- Ignore the errors
- Close and re-open the VM: DONE! 🙂
Happy migration! 😉