====== wsl vhdx compact, method, reclaim ====== * diskpart https://fiddley.wordpress.com/2014/01/27/dynamically-expanding-vhd-not-compacting-in-hyper-v/ ++++ Diskpart | select vdisk File=”I:\path\to\your.vhd” attach vdisk readonly compact vdisk detach vdisk ++++ ====== WSL2 high cpu ====== taskkill -IM "wslservice.exe" /F wsl --shutdown ====== WSL2 port forwarding ====== * https://www.tune-it.ru/web/alenet/blog/-/blogs/windows-wsl2-docker-zizn-posle-linux * https://www.williamjbowman.com/blog/2020/04/25/running-a-public-server-from-wsl-2/ netsh interface portproxy add v4tov4 listenport=$PORT listenaddress=0.0.0.0 connectport=$PORT connectaddress=127.0.0.1 :!: ++++ PowerShell Script for tcp port forward| # Run on unprivileged user with WSL2 $remoteport = bash.exe -c "ip a s eth0 | grep 'inet '" $found = $remoteport -match '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}'; if( $found ){ $remoteport = $matches[0]; } else{ echo "The Script Exited, the ip address of WSL 2 cannot be found"; exit; } Write-Host @remoteport # !!!! On privileged user !!!! #[Ports] #All the ports you want to forward separated by coma $ports=@(1433,1434); # from previous step $remoteport='172.31.28.155'; #[Static ip] #You can change the addr to your ip config to listen to a specific address $addr='0.0.0.0'; $ports_a = $ports -join ","; #Remove Firewall Exception Rules iex "Remove-NetFireWallRule -DisplayName 'WSL 2 Firewall Unlock' " #adding Exception Rules for inbound and outbound Rules iex "New-NetFireWallRule -DisplayName 'WSL 2 Firewall Unlock' -Direction Outbound -LocalPort $ports_a -Action Allow -Protocol TCP"; iex "New-NetFireWallRule -DisplayName 'WSL 2 Firewall Unlock' -Direction Inbound -LocalPort $ports_a -Action Allow -Protocol TCP"; for( $i = 0; $i -lt $ports.length; $i++ ){ $port = $ports[$i]; iex "netsh interface portproxy delete v4tov4 listenport=$port listenaddress=$addr"; iex "netsh interface portproxy add v4tov4 listenport=$port listenaddress=$addr connectport=$port connectaddress=$remoteport"; } # Show rules netsh interface portproxy show all # Reset all netsh interface portproxy reset ++++ ++++ PowerShell Script for udp port forward socat| # https://serverfault.com/questions/1051667/forward-incoming-udp-packets-on-windows-server-to-client-on-different-interface # udp forward https://mattryall.net/blog/udp-port-forwarding-with-socat # distr https://sourceforge.net/projects/unix-utils/files/socat/1.7.3.2/ socat UDP4-RECVFROM:161,fork UDP4-SENDTO:localhost:10161 ++++ ====== Windows system linux ====== * Шрифты git clone https://github.com/powerline/fonts.git * Статься по настройке https://blog.nillsf.com/index.php/2020/02/17/setting-up-wsl2-windows-terminal-and-oh-my-zsh/ * приемы работы - https://habr.com/ru/company/microsoft/blog/476026/ ===== windows terminal config ===== ++++ Windows terminal config| // This file was initially generated by Windows Terminal 1.0.1401.0 // It should still be usable in newer versions, but newer versions might have additional // settings, help text, or changes that you will not see unless you clear this file // and let us generate a new one for you. // To view the default settings, hold "alt" while clicking on the "Settings" button. // For documentation on these settings, see: https://aka.ms/terminal-documentation { "$schema": "https://aka.ms/terminal-profiles-schema", "defaultProfile": "{07b52e3e-de2c-5db4-bd2d-ba144ed6c273}", // You can add more global application settings here. // To learn more about global settings, visit https://aka.ms/terminal-global-settings // If enabled, selections are automatically copied to your clipboard. "copyOnSelect": false, // If enabled, formatted data is also copied to your clipboard "copyFormatting": false, // A profile specifies a command to execute paired with information about how it should look and feel. // Each one of them will appear in the 'New Tab' dropdown, // and can be invoked from the commandline with `wt.exe -p xxx` // To learn more about profiles, visit https://aka.ms/terminal-profile-settings "profiles": { "defaults": { // Put settings here that you want to apply to all profiles. }, "list": [ { // Make changes here to the powershell.exe profile. "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}", "name": "Windows PowerShell", "commandline": "powershell.exe", "hidden": false }, { // Make changes here to the cmd.exe profile. "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}", "name": "Командная строка", "commandline": "cmd.exe", "hidden": false }, { "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}", "hidden": false, "name": "Azure Cloud Shell", "source": "Windows.Terminal.Azure" }, { "guid": "{07b52e3e-de2c-5db4-bd2d-ba144ed6c273}", "hidden": false, "name": "Ubuntu-20.04", "source": "Windows.Terminal.Wsl", "colorScheme" : "wsl", //"fontFace" : "DejaVu Sans Mono for Powerline" "startingDirectory" : "~", "closeOnExit" : false, // "colorScheme" : "Solarized Dark", "cursorColor" : "#00FF00", "cursorHeight" : 25, "cursorShape" : "vintage", "fontFace" : "Fira Code Retina", "fontSize" : 12, "historySize" : 9001, "icon" : "ms-appdata:///roaming/pwsh-32.png", "padding" : "0, 0, 0, 0", "snapOnInput" : true, "acrylicOpacity" : 0.8, "useAcrylic" : true }, { "acrylicOpacity" : 0.85, "background" : "#012456", "backgroundImage" : "C:/Users/user/AppData/Local/Packages/Microsoft.WindowsTerminal_8wekyb3d8bbwe/RoamingState/starwars.gif", "backgroundImageOpacity" : 0.7, "backgroundImageStretchMode" : "uniformToFill", "closeOnExit" : false, "colorScheme" : "Solarized Dark", "commandline" : "powershell.exe", "cursorColor" : "#00FF00", "cursorHeight" : 25, "cursorShape" : "vintage", "fontFace" : "Fira Code", // "fontFace" : "FantasqueSansMono-Regular.ttf+Powerline+Awesome", "fontSize" : 12, "guid" : "{79285a8e-036c-446f-8a9c-78994e34bf78}", "historySize" : 9001, "icon" : "ms-appdata:///roaming/pwsh-32.png", "name" : "PowerShell with StarWars", "padding" : "0, 0, 0, 0", "snapOnInput" : true, "startingDirectory" : "%USERPROFILE%", "useAcrylic" : false }, { "useAcrylic" : true, "acrylicOpacity" : 0.85, // "background" : "#012456", "closeOnExit" : false, // "colorScheme" : "Solarized Dark", "colorScheme" : "wsl", "commandline" : "C:/Program Files/mysql-shell/bin/mysqlsh.exe", "cursorColor" : "#00FF00", "cursorHeight" : 25, "cursorShape" : "vintage", // "fontFace" : "Fira Code", "fontFace" : "FantasqueSansMono-Regular.ttf+Powerline+Awesome", "fontSize" : 12, // "guid" : "{79285a8e-036c-446f-8a9c-78994e34bf78}", "historySize" : 9001, "icon" : "ms-appdata:///roaming/pwsh-32.png", "name" : "MysqlShell", "snapOnInput" : true, "startingDirectory" : "C:/Program Files/mysql-shell/bin/", } ] }, // Add custom color schemes to this array. // To learn more about color schemes, visit https://aka.ms/terminal-color-schemes "schemes": [ { "background" : "#002B36", "black" : "#002B36", "blue" : "#268BD2", "brightBlack" : "#657B83", "brightBlue" : "#839496", "brightCyan" : "#D33682", "brightGreen" : "#B58900", "brightPurple" : "#EEE8D5", "brightRed" : "#CB4B16", "brightWhite" : "#FDF6E3", "brightYellow" : "#586E75", "cyan" : "#2AA198", "foreground" : "#93A1A1", "green" : "#859900", "name" : "wsl", "purple" : "#6C71C4", "red" : "#DC322F", "white" : "#93A1A1", "yellow" : "#B58900" } ], // Add custom keybindings to this array. // To unbind a key combination from your defaults.json, set the command to "unbound". // To learn more about keybindings, visit https://aka.ms/terminal-keybindings "keybindings": [ // Copy and paste are bound to Ctrl+Shift+C and Ctrl+Shift+V in your defaults.json. // These two lines additionally bind them to Ctrl+C and Ctrl+V. // To learn more about selection, visit https://aka.ms/terminal-selection { "command": {"action": "copy", "singleLine": false }, "keys": "ctrl+c" }, { "command": "paste", "keys": "ctrl+v" }, // Press Ctrl+Shift+F to open the search box { "command": "find", "keys": "ctrl+shift+f" }, // Press Alt+Shift+D to open a new pane. // - "split": "auto" makes this pane open in the direction that provides the most surface area. // - "splitMode": "duplicate" makes the new pane use the focused pane's profile. // To learn more about panes, visit https://aka.ms/terminal-panes { "command": { "action": "splitPane", "split": "auto", "splitMode": "duplicate" }, "keys": "alt+shift+d" } ] } ++++