microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.38k stars 819 forks source link

Add .xz archive support to wsl.exe --import to improve microsoft/WSL-DistroLauncher #6056

Open jonstanley opened 4 years ago

jonstanley commented 4 years ago

When using microsoft/WSL-DistroLauncher, an archive of the distro filesystem must be provided at install.tar and can be GZIP compressed, install.tar.gz or install.tgz

It would improve ease of use (archives are already compressed with XZ) plus reduce storage and bandwidth requirements if XZ compressed can be supported by the import command, users modifying microsoft/WSL-DistroLauncher wouldn't then be bound to using on GZIP compression

user@host:/home/user/Gentoo$ gzip -l install.tar.gz
         compressed        uncompressed  ratio uncompressed_name
          324853255          1080278906  69.9% install.tar
user@host:/home/user/Gentoo$ xz -l install.tar.xz
Strms  Blocks   Compressed Uncompressed  Ratio  Check   Filename
    1       1    169.0 MiB  1,030.2 MiB  0.164  CRC64   install.tar.xz

A ~1GiB install.tar is nearly 50% smaller when compressed with xz versus gzip (both at -9)

duongdominhchau commented 1 year ago

I haven't tried importing xz tarball yet, but I tried zstd tarball and WSL can import that successfully. zstd is supposed to be superior compared to xz, the compressed tarball may not be smaller, but the compression/decompression speed is better. You can also trade speed with space by increasing the compression level (e.g: zstd -5 wsl_distro.tar instead of the default level of 3 in zstd wsl_distro.tar), so, give it a try maybe?

My wsl --version:

WSL version: 0.70.4.0
Kernel version: 5.15.68.1
WSLg version: 1.0.45
MSRDC version: 1.2.3575
Direct3D version: 1.606.4
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22621.675

I use Windows 11 btw, don't know why Windows version is 10 here 🤷

lucastheisen commented 1 year ago

I tried the rockylinux .tar.xz today and it worked. I'm on a recent update of Windows 11 after running wsl --update, so currently:

PS C:\Users\lucas\git\lucastheisen-dev-bootstrap> wsl --version
WSL version: 1.1.6.0
Kernel version: 5.15.90.1
WSLg version: 1.0.50
MSRDC version: 1.2.3770
Direct3D version: 1.608.2-61064218
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22621.1413

This issue can probably be closed out, but I would suggest updating the wsl --help (and probably online help) to mention that .tar.xz is supported.

Vinfall commented 6 months ago

I can confirm importing .tar.gz, .tar.xz & .tar.zst works perfectly as of latest 2.1.5.

For zstd, you can export like (cmd is called to avoid a PowerShell pipe bug):

cmd /c "wsl --export void-glibc - | zstd -T4 -o void-glibc-$(Get-Date -UFormat "%Y%m%d").tar.zst"