Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zstd support #152

Open
Vinfall opened this issue Apr 13, 2024 · 3 comments
Open

zstd support #152

Vinfall opened this issue Apr 13, 2024 · 3 comments
Assignees

Comments

@Vinfall
Copy link
Contributor

Vinfall commented Apr 13, 2024

Zstandard is a loseless compression algorithm, and dual-licensed under BSD OR GPLv2.

WSL supports importing quite a few formats already like .tar., .tar.xz, .tar.gz and .tar.zst.

I'm aware of #109 and agree with the size increase worry. Regarding implementation, do you mean a go package for the compression algorithms or something else? If you mean packages, I think this or this would work.

To test if it's possible, I just blindly modified

var (
defaultRootFiles = []string{"install.tar", "install.tar.gz", "rootfs.tar", "rootfs.tar.gz", "install.ext4.vhdx", "install.ext4.vhdx.gz"}
)
and gladly importing .tar.zst just works. A more thorough support would require importing the package and change
// uncompress and copy
rootPathLower := strings.ToLower(rootPath)
if strings.HasSuffix(rootPathLower, ".gz") {
// compressed with gzip
gr, err := gzip.NewReader(src)
if err != nil {
return err
}
_, err = io.Copy(dest, gr)
if err != nil {
return err
}
} else {
// not compressed
_, err = io.Copy(dest, src)
if err != nil {
return err
}
}
or wherever I'm unaware of.

A test build of wsldl is available here and I successfully built DevuanWSL based on that. Running Devuan.exe does register the instance and it works flawlessly as far as I can tell so it should be feasible I guess.

@yuk7
Copy link
Owner

yuk7 commented May 5, 2024

Ok, I understood.
I'll support it.

@yuk7 yuk7 self-assigned this May 6, 2024
@yuk7
Copy link
Owner

yuk7 commented May 6, 2024

I have released a new build that supports .tar.zst rootfs.
Please note that this may not be available in users version of WSL.

I will decide later whether to support zstd compression for vhd installs and backups.

@Vinfall
Copy link
Contributor Author

Vinfall commented May 7, 2024

I'll keep this open as it's just partially solved, but personally I use native WSL export and redirecting that to Zstandard works perfectly, thus having no preference on zstd compression support by wsldl.

Code snippet in case anyone is interested:

wsl --shutdown
cd path\to\distro
# Make sure to use cmd as PowerShell pipe is known to be problematic
cmd /c "wsl --export Devuan - | zstd -T0 -o Devuan-$(Get-Date -UFormat "%Y%m%d").tar.zst"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants