Open diablodale opened 4 years ago
I didn't find something interesting in the logs, but I guess:
run only when user is logged on
is supported.mount >> $LOGFILE 2>&1
other than mount &>> $LOGFILE
.ls
in test.shIt is unclear to be what your 1-3 comments are. If you are suggesting workarounds for the bug/regression, then that is not needed. I already have a workaround for the actual scenario on my machines. The issue report I provide above is a short, clear, and isolated scenario so you can reproduce the WSL2 regression/bug.
&>>
works fine in bash as it is a deprecated feature not eliminated. It correctly concats stdout/err. No action needed here.If you have questions of me, please do ask them and I'll endeavor to get answers.
I can also confirm that /etc/fstab is ignored with the following configuration:
cat /etc/wsl.conf
[automount] enabled = true options = metadata,umask=22,fmask=11 mountFsTab = true
Is there any update on this? @diablodale what is your workaround?
Last time I tried, still doesn't work as expected.
As my current workaround, I have a task in task scheduler that runs at logon of my user, and that task does wsl.exe bash -lc exit
. Doing it at this time (when I am also interactively logged in).
In this scenario, the mounts occur.
So on my computer, I have to always be interactively logged in, therefore I use a short screen lock and Windowskey-L now by habit.
Try add to /etc/wsl.conf
[boot]
command="mount -a"
or in boot script on windows:
wsl.exe -u root -e mount -u
/etc/wsl.conf
[boot]
command="mount -a"
This has no effect. Automount on boot still does not happen.
see #6073
Any update on this problem. Windows 11 still has the problem. It looks like the system ignores the file. Even if I change it for e.g swappiness or swapon... It cannot make it permanent. I made the change in the file, but everytime i reboot It does not read that change. Those files does not make sense in wsl booting.
It seems like /etc/fstab works fine with the following configuration:
WSL version: 1.2.5.0 Kernel version: 5.15.90.1 Windows version: 10.0.22000.2176
/etc/wsl.conf:
[automount]
# Automatically mount Windows drive when the distribution is launched plus /etc/fstab
enabled = false
# Sets the `/etc/fstab` file to be processed when a WSL distribution is launched.
# Redundant if enabled = true
mountFsTab = true
/etc/fstab:
# Mount a network drive
//JoeHost/E$ /mnt/re cifs uid=joe,gid=joe,user=joe,pass=shmo 0 0
# Mount local E:\ drive
drvfs /mnt/e 9p rw,noatime,dirsync,aname=drvfs;path=E:\;uid=1000;gid=1000;symlinkroot=/mnt/,mmap,access=client,msize=262144,trans=virtio 0 0
wsl.conf is ignored when wsl2 is booted by task scheduler in condition "Run whether user is logged on or not". Is there any solution now? 😭
If you have systemd enabled with WSL 2 on Windows 10, there's no need to enable automount, as systemd will parse /etc/fstab and generate the corresponding mount units.
Here follows my current settings.
/etc/wsl.conf
[boot]
systemd=true
[automount]
enabled = false
mountFsTab = false
/etc/fstab
drvfs /mnt/c 9p rw,noatime,dirsync,aname=drvfs;path=C:\;uid=1000;gid=1000;symlinkroot=/mnt/,mmap,access=client,msize=262144,trans=virtio 0 0
drvfs /mnt/debian 9p ro,aname=drvfs;path=D:\,mmap,access=client,trans=virtio 0 0
$ uname -r -m
5.15.133.1-microsoft-standard-WSL2 x86_64
$ sudo systemctl list-units --type mount mnt-*
UNIT LOAD ACTIVE SUB DESCRIPTION
mnt-c.mount loaded active mounted /mnt/c
mnt-debian.mount loaded active mounted /mnt/debian
mnt-wsl.mount loaded active mounted /mnt/wsl
mnt-wslg-distro.mount loaded active mounted /mnt/wslg/distro
mnt-wslg-doc.mount loaded active mounted /mnt/wslg/doc
mnt-wslg-versions.txt.mount loaded active mounted /mnt/wslg/versions.txt
mnt-wslg.mount loaded active mounted /mnt/wslg
/etc/fstab
is not automounted when a WSL2 Ubuntu distro is used from Windows Task Scheduler viawsl.exe
.This issue does not reproduce in WSL1 Ubuntu. I discovered it during my WSL1->2 migration. It reminds me of the old WSL1 issue https://github.com/microsoft/WSL/issues/1602 Perhaps related to https://github.com/microsoft/WSL/issues/4226
Environment
Steps to reproduce
dale
username in below steps with your own username.apt update
andapt upgrade
/etc/wsl.conf
to have content ofC: /mnt/c drvfs rw,noatime,uid=1000,gid=1000,fmask=0027,dmask=0027,metadata 0 0
.ssh
directory. Therefore, I firstmkdir /home/dale/.ssh
and then added the line/mnt/c/Users/Dale/.ssh /home/dale/.ssh none bind 0 0
//home-nas/dale /mnt/n drvfs rw,noatime,uid=1000,gid=1000,fmask=0027,dmask=0027,_netdev,nofail 0 0
wsl --shutdown
/etc/fstab
are successful; C drive, your bind mount, and your network share.test.sh
in your Linux home directory, e.g./home/dale/test.sh
, with the below content. Remember to change username and use the directory you bind mounted in step 5.ii above.chmod 755 test.sh
wsltest1
Run whether user is logged on or not
Windows 10
Actions
New...
Start a program
at the topC:\Windows\System32\wsl.exe
bash -lc "/home/dale/test.sh"
Settings
Allow task to be run on demand
Run
/home/dale/testout.log
Actual Behavior
mounts from
/etc/fstab
did not successfully occur. Thetestout.log
output will show in sequence/home/dale/.ssh
is not corrected listed. Instead, you only see the/home/dale/.ssh
directory that you created. This is easily seen by looking at the datetime and in the following....ssh
directory shows only the.
and..
entries. It does not list the files that should be from/mnt/c/Users/Dale/.ssh
due to your bind mountExpected Behavior
All mounts from
/etc/fstab
to successfully occur. Thetestout.log
should show the correct contents of your bind mount, and all three mounts should appear in the list of mounts.WSL logs
Available at https://aka.ms/AA9ubkh