10 Şubat 2021 Çarşamba

Windows Subsystem for Linux - WSL

Giriş
WSL'in iki tane sürümü var. WSL 1 eski, kullanmamak lazım. WSL 2 tercih edilmeli

WSL 1
Açıklaması şöyle. 2016 yılında çıktı
When the Windows Subsystem for Linux (WSL 1) was released in 2016, it became possible to run a real Linux dev environment in a Linux shell, while retaining the familiar Windows UX around the shell. Even File Explorer was integrated nicely with the Linux file system.

The big drawbacks are that WSL 1 emulates a Linux kernel, and it runs in a full VM. The first means processes that require a native kernel, like Docker, can’t run. The second means that WSL 1 consumes a lot of resources. WSL 1 was not sufficient to run Kafka reliably.
WSL 2
Açıklaması şöyle. 2019 yılında çıktı
But Microsoft delivered WSL 2 in 2019, and it’s a whole new world. They fixed the two biggest limitations, so WSL 2 runs a real Linux kernel, and the kernel runs on a subset of Hyper-V features, not in a full VM.
WSL Kurulumu
1. Enable the Windows Subsystem for Linux
PowerShell'de şöyle yaparız
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all
/norestart
2. Enable the Virtual Machine Feature
PowerShell'de şöyle yaparız
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
3. Set the Default WSL Version
PowerShell'de şöyle yaparız
wsl --set-default-version 2
4. Install From Microsoft Store
Microsoft Store'a gidip Linux yazarak bir tane Linux türevi seçeriz ve kurarız

Exe
Microsoft Store'dan yapılan kurumlar için bir exe olmayabilir. Açıklaması şöyle
Apps installed from the Microsoft Store are not traditional Windows "executables". They are Appx packages with a manifest and resources, and they aren't launched with a traditional "command line." 
Ancak WSL için var. Çalıştırmak için wsl.exe kullanılabilir. Açıklaması şöyle
wsl.exe or wsl should work. It can be found in C:\Windows\System32. 
Ancak ben Ubuntu kurdum ve sadece Ubuntu yazınca da çalışıyor.

WSL'den Local Host'a Erişim
Açıklaması şöyle
By default wsl2 enables wsl localhost to be accessible from windows but not vice versa.
Windows bilgisayarın adresini bulmak için şöyle yaparız. Bu adresi ping'lersek erişilemediğini görürüz
grep -m 1 nameserver /etc/resolv.conf | awk '{print $2}'
Windows bilgisayardaki Windows Defender yani Firewall üzerinde WSL2 IP adresine erişim hakkı vermek gerek. Bir örnek burada. Bur örnekte tüm uzak bilgisayarlara ping hakkı veriliyor. Biz ise sadece "Kapsam" alanında Uzak IP adresi olarak örneğin "192.168.238.1" ile WSL2'ye hak versek daha iyi.

Network Share'e Erişim
Örnek - Common Internet File System
Şöyle yaparız
$ sudo apt install cifs-utils
$ sudo mount -t cifs -o user={user},pass={password},vers=1.0 //server/share /mnt/share
Systemd
Sanırım WSL Systemd'yi desteklemiyor




Hiç yorum yok:

Yorum Gönder