Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows drives are automatically mounted when logging into a running WSL distro through another privilege level PowerShell in Windows Terminal, even [automount.enabled]=false is in /etc/wsl.conf. #12443

Open
1 of 2 tasks
Zhaopudark opened this issue Jan 7, 2025 · 5 comments
Assignees
Labels

Comments

@Zhaopudark
Copy link

Zhaopudark commented Jan 7, 2025

Windows Version

Microsoft Windows [Version 10.0.26100.2605]

WSL Version

2.3.26.0

Are you using WSL 1 or WSL 2?

  • WSL 2
  • WSL 1

Kernel Version

5.15.167.4-1

Distro Version

Ubuntu 24.04

Other Software

No about other apps.

Repro Steps

1.Prepare

The following steps are my normal configs to make WSL2 only automatically mount Windows drive C: with DrvFs and not mount any other Windows drives.

  • Open a Windows Terminal with PowerShell
  • Install a native Ubuntu-24.04
    #pwsh
    wsl --install Ubuntu-24.04
  • Login into Ubuntu-24.04,
    #pwsh
    wsl -d Ubuntu-24.04
  • According to Automount settings, modify /etc/wsl.conf, as:
    [boot]
    systemd=true
    [automount]
    enabled=false
    This will disable automatically mounting Windows drives with DrvFs
  • According to Mount a Linux disk in WSL 2, modify /etc/fstab as :
    # UNCONFIGURED FSTAB FOR BASE SYSTEM
    C: /mnt/c drvfs defaults 0 0
  • Shutdown for next start-up:
    wsl --shutdown

This will automatically mount Windows drive C: to /mnt/c with DrvFs.
Put another way, the above settings make the Ubuntu-24.04 distro only mount Windows drive C: to /mnt/c when starting, and do not involve other Windows drives.

2.Test

2.1 Start Ubuntu-24.04 within a general Windows privilege and check the mounting configuration
  • Open a Windows Terminal with PowerShell with a normal privilege.
  • Make sure Ubuntu-24.04 is not running
    wsl -l -v
    # NAME              STATE           VERSION
    # * Ubuntu-24.04      Stopped         2
    
  • Run and login into Ubuntu-24.04:
    wsl -d Ubuntu-24.04 
    
  • use df -h to show the mounted Windows drives
    user@<Machine-Name>:/mnt/c/Users/<windows_username>$ df -h
    Filesystem      Size  Used Avail Use% Mounted on
    none             16G     0   16G   0% /usr/lib/modules/5.15.167.4-microsoft-standard-WSL2
    none             16G  4.0K   16G   1% /mnt/wsl
    drivers         1.9T  504G  1.4T  28% /usr/lib/wsl/drivers
    /dev/sdc       1007G  1.2G  955G   1% /
    none             16G   76K   16G   1% /mnt/wslg
    none             16G     0   16G   0% /usr/lib/wsl/lib
    rootfs           16G  2.2M   16G   1% /init
    none             16G  632K   16G   1% /run
    none             16G     0   16G   0% /run/lock
    none             16G     0   16G   0% /run/shm
    none             16G   64K   16G   1% /mnt/wslg/versions.txt
    none             16G   64K   16G   1% /mnt/wslg/doc
    C:              1.9T  504G  1.4T  28% /mnt/c
    tmpfs           3.2G   16K  3.2G   1% /run/user/1000
    Here only C: mounted, which is expected.
2.2 check the mounting configuration within an Admin Windows privilege.
  • Do not shutdown the previous Ubuntu-24.04!
  • Open a Windows Terminal with PowerShell with Admin privilege.
  • Login into Ubuntu-24.04 again (within Windows admin privilege):
    wsl -d Ubuntu-24.04 
    
  • use df -h to show the mounted Windows drives
    user@<Machine-Name>:/mnt/c/Users/<windows_username>$ df -h
    Filesystem      Size  Used Avail Use% Mounted on
    /dev/sdc       1007G  1.2G  955G   1% /
    rootfs           16G  2.2M   16G   1% /init
    none             16G     0   16G   0% /dev/shm
    none             16G  624K   16G   1% /run
    none             16G     0   16G   0% /run/lock
    none             16G   80K   16G   1% /run/user
    tmpfs           3.2G   16K  3.2G   1% /run/user/1000
    drivers         1.9T  504G  1.4T  28% /usr/lib/wsl/drivers
    none             16G     0   16G   0% /usr/lib/wsl/lib
    none             16G  4.0K   16G   1% /mnt/wsl
    none             16G   76K   16G   1% /mnt/wslg/versions.txt
    none             16G   76K   16G   1% /mnt/wslg/doc
    none             16G     0   16G   0% /usr/lib/modules/5.15.167.4-microsoft-standard-WSL2
    C:              1.9T  504G  1.4T  28% /mnt/c
    D:\             3.5T  280G  3.3T   8% /mnt/d
    E:\             3.7T  1.1T  2.6T  30% /mnt/e
    F:\              19T  3.7T   15T  21% /mnt/f
    T:\             1.9T  516G  1.4T  28% /mnt/t
    Here, not only C:, but also D:\, E:\, F:\ and T:\ are mounted. This is not the expectation since [automount] enabled=false have been sed in /etc/wsl.conf.

Expected Behavior

As the above configuration.

  • The /etc/wsl.conf is as:
    [boot]
    systemd=true
    [automount]
    enabled=false
  • The /etc/fstab is as :
    # UNCONFIGURED FSTAB FOR BASE SYSTEM
    C: /mnt/c drvfs defaults 0 0

It is expected that, whatever method to start and login into the Ubuntu-24.04 distro, only Windows drive C: should be mounted to /mnt/c while other Windows drives are not involved.

Actual Behavior

If start and login into the Ubuntu-24.04 through a PowerShell within a normal Windows privilege, it is indeed the case that only Windows drive C: is mounted to /mnt/c, and other Windows drives are not.

But, if retain the running Ubuntu-24.04, and login into it through a PowerShell within an Admin Windows privilege, the other Windows drives, such as D:\, E:\, and F:\ are mounted as well. This is out of the expectation, as the [automount] enabled=false is in /etc/wsl.conf.

Some conclusions form additional ablation tests

I've done further tests and found that:

  • As long as there is a pair of PowerShell processes, one of which is within normal Windows privilege and another is within an Admin Windows privilege.
  • shutdown the WSL2.
  • In one PowerShell, start the Ubuntu-24.04 distro, and retain it.
  • Then, in another PowerShell, login the running Ubuntu-24.04 distro, it will auto-mount all Windows drives, even [automount] enabled=false is in the /etc/wsl.conf.

Diagnostic Logs

WslLogs-2025-01-07_19-27-51.zip

Copy link

github-actions bot commented Jan 7, 2025

Logs are required for review from WSL team

If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'.
Otherwise please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.

How to collect WSL logs

Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:

Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
Set-ExecutionPolicy Bypass -Scope Process -Force
.\collect-wsl-logs.ps1

The script will output the path of the log file once done.

If this is a networking issue, please use collect-networking-logs.ps1, following the instructions here

Once completed please upload the output files to this Github issue.

Click here for more info on logging
If you choose to email these logs instead of attaching to the bug, please send them to wsl-gh-logs@microsoft.com with the number of the github issue in the subject, and in the message a link to your comment in the github issue and reply with '/emailed-logs'.

View similar issues

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it!

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@Zhaopudark Zhaopudark changed the title Windows drives will be auto-mounted when login into a normal started (by general Windows privilege) WSL distro through another shell with Windows Admin privilege, even [automount.enabled]=false is in /etc/wsl.conf. Windows drives will be auto-mounted when login into a running (started by general Windows privilege) WSL distro through another shell with Windows Admin privilege, even [automount.enabled]=false is in /etc/wsl.conf. Jan 7, 2025
Copy link

github-actions bot commented Jan 7, 2025

Logs are required for review from WSL team

If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'.
Otherwise please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.

How to collect WSL logs

Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:

Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
Set-ExecutionPolicy Bypass -Scope Process -Force
.\collect-wsl-logs.ps1

The script will output the path of the log file once done.

If this is a networking issue, please use collect-networking-logs.ps1, following the instructions here

Once completed please upload the output files to this Github issue.

Click here for more info on logging
If you choose to email these logs instead of attaching to the bug, please send them to wsl-gh-logs@microsoft.com with the number of the github issue in the subject, and in the message a link to your comment in the github issue and reply with '/emailed-logs'.

View similar issues

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it!

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

Copy link

github-actions bot commented Jan 7, 2025

Diagnostic information
Issue was edited and new log file was found: https://github.com/user-attachments/files/18331825/WslLogs-2025-01-07_19-27-51.zip
Multiple log files found, using: https://github.com/user-attachments/files/18331825/WslLogs-2025-01-07_19-27-51.zip
.wslconfig found
Detected appx version: 2.3.26.0

@Zhaopudark Zhaopudark changed the title Windows drives will be auto-mounted when login into a running (started by general Windows privilege) WSL distro through another shell with Windows Admin privilege, even [automount.enabled]=false is in /etc/wsl.conf. Windows drives are automatically mounted when logging into a running WSL distrothrough another privilege level PowerShell in Windows Terminal, even [automount.enabled]=false is in /etc/wsl.conf. Jan 7, 2025
@Zhaopudark Zhaopudark changed the title Windows drives are automatically mounted when logging into a running WSL distrothrough another privilege level PowerShell in Windows Terminal, even [automount.enabled]=false is in /etc/wsl.conf. Windows drives are automatically mounted when logging into a running WSL distro through another privilege level PowerShell in Windows Terminal, even [automount.enabled]=false is in /etc/wsl.conf. Jan 7, 2025
Copy link

github-actions bot commented Jan 7, 2025

View similar issues

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

Diagnostic information
.wslconfig found
Detected appx version: 2.3.26.0

1 similar comment
Copy link

github-actions bot commented Jan 7, 2025

View similar issues

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

Diagnostic information
.wslconfig found
Detected appx version: 2.3.26.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants