This will describe in short how to get your old wsl environment running in a container runtime, such as containerd or Podman. While it is possible to use vhdx, I had better results with tarballs. A vhdx needs to be converted, use qemy-nbd etc, as you can not boot this as a VM unless you install the kernel and modules.
Prepare the distribution for export, such as removing large files, unnecessary mountpoints, symlinks, etc. After this
wsl --export dotfedora D:\Backups\dotfedora-260513.tar.gz --format tar.gz
With two prerequisites in place beforehand
~/.config/containers/containers.conf:
[engine]
image_copy_tmp_dir="/home/gbraad/podman-import-tmp"This is needed to prevent copying/moving the image from a primary disk to an external/different disk, or in my case, running out of space on /var.
/etc/subuid and /etc/subgid:
sudo sed -i 's/gbraad:100000:65536/gbraad:100000:1000000/' /etc/subuid /etc/subgid
podman system migrateotherwise issues for the user can occur, as WSL uses ver high numbered users and groups.
Sit back and grab a cup of coffee as thks can take long. Or better, do something else ...
nohup bash -c 'zcat /home/gbraad/dotfedora-260513.tar.gz | podman import - wslimport-backup:260513'We use nohup to prevent issues that will stop the import, like a disconnected ssh session
Then prepare to run with systemd. These mountpoints are specific to my image, so make sure to make changes.
FROM localhost/wslimport-backup:260513
RUN rm -f /home/gbraad/Projects /home/gbraad/Documents /home/gbraad/Downloads \
/home/gbraad/Music /home/gbraad/Videos /home/gbraad/Pictures \
&& mkdir -p /home/gbraad/Projects /home/gbraad/Documents /home/gbraad/Downloads \
/var/home/gbraad/Projects /var/home/gbraad/Documents /var/home/gbraad/Downloads
# Run with systemd
CMD ["/sbin/init"]Build image
podman build -f Containerfile -t localhost/wslimport-backup:latestRun your image with distrobox or podman with the right mountpoints setup. In my case:
dev wslbackup from-image ...