WSL2
Installation
Install wsl with the following command:
wsl.exe --install
Install FedoraLinux-42 distribution:
wsl.exe --install FedoraLinux-42
Keep your WSL installation updated by running:
PS E:\clones\homelabguide> wsl.exe --update
Checking for updates.
The most recent version of Windows Subsystem for Linux is already installed.
Configuration
Resource Allocation
Create or modify .wslconfig
file to customize WSL2 resource allocation:
cd ~
notepad.exe .wslconfig
Here is a sample configuration:
# Settings apply across all Linux distros running on WSL 2
[wsl2]
memory=4GB
processors=4
swap=4GB
networkingMode=mirrored
dnsTunneling=true
autoProxy=true
[experimental]
autoMemoryReclaim=gradual
I'm not going into details why I configure with these settings, but you can read more about it here.
After making changes to .wslconfig
, apply them by shutting down WSL:
wsl.exe --shutdown
Disable windows interop
I experience slowness when typing in the WSL terminal while the interop appendWindowsPath
is enabled. You can disable it by configuring /etc/wsl.conf
file:
[interop]
appendWindowsPath=false
Read more about it here
Accessing Your WSL Environment
Enter your Fedora Linux environment:
wsl.exe -d FedoraLinux-42
SSH Setup
Generate an SSH key for secure authentication:
ssh-keygen
To share your existing Windows SSH keys with WSL:
wsl -d FedoraLinux-42
cp -rv /mnt/c/Users/{replace_with_your_username}/.ssh/ ~
chmod 600 ~/.ssh/id_ed25519
Make sure to replace {replace_with_your_username}
with your actual Windows username.
Key Principles
- Always think Window and WSL as two separate operating systems.
- Windows files are mounted inside WSL under
/mnt/c
, but this is actually a mounted Windows file system, not native Linux storage. - To avoid perfomance issues do not work with Windows files from Linux and avoid editing WSL files directly from Windows. If you need to sync files between the two environments, consider using a remote git repository or a dedicated syncroization tool like Mutagen.io, as these methods are more reliable for cross-platform workflows.