You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
WSL2 Increase the maximum amount of inotify user watches #4293
Please consider increasing the maximum amount of inotify user watches (fs.inotify.max_user_watches) in WSL2.
The current limit (8192) is too low for most projects.
For a seamless Visual Studio Code Remote Development experience a new limit of 524288 is suggested. That would allow to watch up to 524288 files, using up to 540 MiB kernel memory.
Alternatively make fs.inotify.max_user_watches configurable, which would probably require the init system of WSL2 to read configuration files placed in /etc/sysctl.d/. See #4232.
Run sudo chown root:root and sudo chmod 755 on the script
Either move the script to a directory owned by root or run sudo chattr +i on it, otherwise it can be deleted
Run sudo EDITOR=nano visudo and add this: %sudo ALL=(ALL:ALL) NOPASSWD:/path/to/script.sh
Add this to .profile: sudo /path/to/script.sh
Don't forget to remove the line above from visudo if you delete /path/to/script.sh
Reacted by Joe Maller, Paul Becotte, Adam Vigneaux, Dmitriy I, Freek van Rijt, Andrey Gorbunov, Karol Walasek, Παναγιώτης Γεωργακόπουλος, Mark Penner, Francis Gyimah and 6 more
@Comevius thank you, thank you, thank you! This is really a brilliant workaround, and actually the only one that works. I spent several hours trying to make it work and the most of 'google' solutions claimed that: sudo sysctl fs.inotify.max_user_watches=524288 && sudo sysctl -p should've been enough to make it pernament. It is not the case for WSL. Now everything works smoothely.
This really needs to be documented (at least) or implemented in WSL2.
Reacted by Joe Maller, Charles Williams, Mitchell Skaggs, Garrett Simpson, Wei-Lun Tsai, Rafael Hengles and Rian Finnegan
I use sudo passwd root to enable root user ,
then cd /root
then I create a init.sh file in /root
then I sudo chown root:root init.sh and sudo chmod 755
then vim /etc/sudoers
add %sudo ALL=(ALL:ALL) NOPASSWD:/root/init.sh
then vim .profile
add sudo /root/init.sh
You don't need to enable password for root, just use sudo su -
You can't use vim directly to edit /etc/sudoers, you should use visudo (pay attention to the original instructions).
There is already a line in /etc/sudoers for the %sudo group, the order of records is important, so you should put the additional record after the existing one:
%sudo ALL=(ALL:ALL) ALL
%sudo ALL=(ALL:ALL) NOPASSWD:/root/init.sh
You need to exit the editor the changes to take effect.
To check, that everything works just open another bash shell and try to execute: sudo /root/init.sh
it should not ask for a password.
After placing script call into the .profile there should be init.sh output visible during the shell start.
This blog post says that WSL2 only watches file in the WSL-related folders. So I move my original one from Windows-related to WSL-related and it works! Many thanks to this blog.
Activity
therealkenc commentedon Jul 10, 2019
#4232
marcinolek commentedon Jul 30, 2019
@Comevius thank you, thank you, thank you! This is really a brilliant workaround, and actually the only one that works. I spent several hours trying to make it work and the most of 'google' solutions claimed that:
sudo sysctl fs.inotify.max_user_watches=524288 && sudo sysctl -pshould've been enough to make it pernament. It is not the case for WSL. Now everything works smoothely.This really needs to be documented (at least) or implemented in WSL2.
jiangbo0216 commentedon Oct 14, 2019
I use
sudo passwd rootto enable root user ,then
cd /rootthen I create a
init.shfile in/rootthen
I sudo chown root:root init.shandsudo chmod 755then
vim /etc/sudoersadd
%sudo ALL=(ALL:ALL) NOPASSWD:/root/init.shthen
vim .profileadd
sudo /root/init.shthe result : fail
#4232
please help!!
gorbunovav commentedon Oct 23, 2019
jiangbo (@jiangbo0216) it works for me.
You don't need to enable password for root, just use
sudo su -You can't use vim directly to edit
/etc/sudoers, you should usevisudo(pay attention to the original instructions).There is already a line in
/etc/sudoersfor the%sudogroup, the order of records is important, so you should put the additional record after the existing one:You need to exit the editor the changes to take effect.
To check, that everything works just open another bash shell and try to execute:
sudo /root/init.shit should not ask for a password.
After placing script call into the
.profilethere should beinit.shoutput visible during the shell start.alan23273850 commentedon Jun 12, 2021
https://auo.nu/posts/wsl2-livereload/
This blog post says that WSL2 only watches file in the WSL-related folders. So I move my original one from Windows-related to WSL-related and it works! Many thanks to this blog.