Last active
May 21, 2025 13:36
-
-
Save voroninadm/1650c5ab756a03ae65ce82d7ebf819d8 to your computer and use it in GitHub Desktop.
WSL notes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1. Import/Export | |
| Список установленных дистрибутивов | |
| wsl -l | |
| - Бэкап | |
| wsl --export (distribution) (file path) | |
| Replacing the placeholders with the correct information, you'll get something like this: | |
| wsl --export Ubuntu "C:\Users\joaoc\Documents\Linux backups\ubuntubackup.tar" | |
| - Восстановление | |
| wsl --import (distribution) (install location) (file path) | |
| So, using the same information we used for the import, the command would look like this: | |
| wsl --import Ubuntu "C:\Linux" "C:\Users\joaoc\Documents\Linux backups\ubuntubackup.tar" | |
| - Удаление образа | |
| wsl --unregister <distribution> | |
| 2. Настройка | |
| Пример файла wsl.conf в /etc/wsl.conf | |
| В приведенном ниже wsl.conf примере файла демонстрируются некоторые из доступных параметров конфигурации. В этом примере дистрибутив — Ubuntu-20.04, а путь к файлу — \\wsl.localhost\Ubuntu-20.04\etc\wsl.conf. | |
| Bash | |
| ***** НАЧАЛО ***** | |
| # Настройка монтирования дисков Windows | |
| [automount] | |
| # Вызывает автоматическое монтирование фиксированных дисков | |
| enabled = true | |
| # Sets the directory where fixed drives will be automatically mounted. This example changes the mount location, so your C-drive would be /c, rather than the default /mnt/c. | |
| #root = / | |
| # DrvFs-specific options can be specified. | |
| #options = "metadata,uid=1003,gid=1003,umask=077,fmask=11,case=off" | |
| # Sets the `/etc/fstab` file to be processed when a WSL distribution is launched. | |
| #mountFsTab = true | |
| # Network host settings that enable the DNS server used by WSL 2. This example changes the hostname, sets generateHosts to false, preventing WSL from the default behavior of auto-generating /etc/hosts, and sets generateResolvConf to false, preventing WSL from auto-generating /etc/resolv.conf, so that you can create your own (ie. nameserver 1.1.1.1). | |
| [network] | |
| #hostname = DemoHost | |
| generateHosts = false | |
| generateResolvConf = false | |
| # Set whether WSL supports interop processes like launching Windows apps and adding path variables. Setting these to false will block the launch of Windows processes and block adding $PATH environment variables. | |
| [interop] | |
| enabled = false | |
| appendWindowsPath = false | |
| # Set a command to run when a new WSL instance launches. This example starts the Docker container service. | |
| [boot] | |
| #command = service docker start | |
| systemd=true | |
| # Настройка параметров wsl | |
| [wsl2] | |
| memory=8GB | |
| processors=4 | |
| swap=2GB | |
| localhostForwarding=true | |
| ***** ОКОНЧАНИЕ ***** | |
| P.S. Настройка юзера при запуске wsl. Конфиг задается при установке образа и обычно не требует изменений | |
| [user] | |
| default=admin | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Настройка сети | |
| Посмотреть адресацию - ip addr show | |
| Настроим адресацию: | |
| sudo nano /etc/netplan/01-netcfg.yaml | |
| Добавляем в конфиг: | |
| network: | |
| version: 2 | |
| ethernets: | |
| eth0: | |
| addresses: | |
| - 192.168.50.2/24 | |
| gateway4: 192.168.50.1 | |
| nameservers: | |
| addresses: [8.8.8.8, 8.8.4.4] | |
| 2. Добавляем ssh-доступ | |
| sudo apt install openssh-server | |
| # sudo systemctl enable ssh | |
| в системе прробрасываем порты | |
| netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=22 connectaddress=172.23.129.80 connectport=22 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment