Skip to content

Instantly share code, notes, and snippets.

@Nislaco
Created February 3, 2025 21:31
Show Gist options
  • Save Nislaco/abb4aa864c27930fdf87034745a0d369 to your computer and use it in GitHub Desktop.
Save Nislaco/abb4aa864c27930fdf87034745a0d369 to your computer and use it in GitHub Desktop.
$username="username"
$ip="ip"
ssh ${username}@${ip} "mkdir -p ~/wsl/drivers; mkdir -p ~/wsl/lib;"
(Get-CimInstance -ClassName Win32_VideoController -Property *).InstalledDisplayDrivers | Select-String "C:\\Windows\\System32\\DriverStore\\FileRepository\\[a-zA-Z0-9\\._]+\\" | foreach {
$l=$_.Matches.Value.Substring(0, $_.Matches.Value.Length-1)
scp -r $l ${username}@${ip}:~/wsl/drivers/
}
scp -r "C:\Windows\System32\lxss\lib" ${username}@${ip}:~/wsl/;
scp -r "C:\Program Files\WSL\lib" ${username}@${ip}:~/wsl/
ssh ${username}@${ip} "sudo -S chmod -R 555 ~/wsl";
ssh ${username}@${ip} "sudo -S chown -R root:root ~/wsl";
ssh ${username}@${ip} "sudo -S mkdir -p $(echo /usr/lib/wsl/drivers/)";
ssh ${username}@${ip} "sudo -S mkdir -p $(echo /usr/lib/wsl/lib/)";
ssh ${username}@${ip} "sudo -S mv ~/wsl/lib/* /usr/lib/wsl/lib;sudo -S ln -s /usr/lib/wsl/lib/libd3d12core.so /usr/lib/wsl/lib/libD3D12Core.so;sudo -S mv ~/wsl/drivers/* /usr/lib/wsl/drivers"
ssh ${username}@${ip} "sudo -S echo '/usr/lib/wsl/lib' | sudo -S tee '/etc/ld.so.conf.d/ld.wsl.conf'"
ssh ${username}@${ip} "sudo -S ldconfig"
ssh ${username}@${ip} "sudo -S echo "'export PATH=$PATH:/usr/lib/wsl/lib'" | sudo -S tee '/etc/profile.d/wsl.sh'"
ssh ${username}@${ip} "sudo -S chmod +x /etc/profile.d/wsl.sh"
@Nislaco
Copy link
Author

Nislaco commented Feb 3, 2025

Please run the listed commands from power shell on Window host.

This is for moving files from a Windows host with WSL2 installed to a Linux (ubuntu/Debian) Hyper-v instance.

This uses files external from WSL2 instance that are provided by WSL2.

These commands do not affect any running WSL instances.

(wsl update). Please run if files are missing from "C:\Program Files\WSL\lib"

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