Search notes:

/etc/wsl.conf

/etc/wsl.conf is the configuration file for a distribution running in Windows Subsystem for Linux.
Changing the file apparently requires to restart the subsystem:
C:> wsl --shutdown

Example

# Automatically mount Windows drive when the distribution is launched
[automount]

# Set to true will automount fixed drives (C:/ or D:/) with DrvFs under the root directory set above.
# Set to false means drives won't be mounted automatically, but need to be mounted manually or with fstab.
enabled = true

# Sets the directory where fixed drives will be automatically mounted.
# Using the slash as mounts C:\ to /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"

# Process /etc/fstab when a WSL distribution is launched.
mountFsTab = true

[network]
# Network host settings that enable the DNS server used by WSL 2.

# Specify hostname
hostname = DemoHost

# Setting generateHosts to false prevents WSL from the default behavior of auto-generating /etc/hosts
generateHosts = false

# Setting generateResolvConf to false prevents WSL from auto-generating /etc/resolv.conf, so that you can create your own nameserver (ie. nameserver 1.1.1.1).
generateResolvConf = false

[interop]

# Block launching Windows processing:
enabled = false

# Do not add %PATH%:
appendWindowsPath = false

# Set the user when launching a distribution with WSL.
[user]
default = DemoUser

[boot]
# Enable systemd
systemd=true
# Set a command to run when a new WSL instance launches.
command = service docker start

TODO

C:\> wsl --debug-shell

Welcome to CBL-Mariner 2.0.20230630 (x86_64) - Kernel 5.15.133.1-microsoft-standard-WSL2 (hvc1)
tq84host login: root (automatic login)

root@tq84host [ ~ ]# cat /mnt/wsl/resolv.conf
# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateResolvConf = false
nameserver 172.31.16.1

See also

The global configuration file is %userprofile%/.wslconfig.

Links

Advanced settings configuration in WSL: wsl.conf
https://devblogs.microsoft.com/commandline/automatically-configuring-wsl/

Index