Mount external drive
When I plug in an external drive (E:) after WSL is already running, it does not become available at /mnt/e automatically. It can be manually mounted with
wsl.exe -u root -e mount -t drvfs E: /mnt/eOn Stack Overflow there are also ideas how to automate it: https://superuser.com/questions/1734353/is-there-a-way-to-mount-an-external-drive-when-it-becomes-available-in-wsl
Export and import
Save as vhdx:
wsl.exe --shutdown
wsl.exe --export --vhd 'Ubuntu' "D:\backup\wsl\2024-07-14\2024-07-14 Ubuntu.vhdx"Import (after 2024-07-14 reinstalling windows):
wsl.exe --import Ubuntu C:\wsl\ubuntu '.\2024-07-14 Ubuntu.vhdx' --vhd