0

I have an issue with VS Code and WSL remote extension. On my machine, Windows Defender Firewall blocked node. I do not have sufficient rights to unblock it, but admins created excluded folder, where based on what they said "I can copy everything that I will need and it is excluded from Windows Defender Firewall check". So I copied VS Code there but I need to also copy the package with Debian Linux there and link it to the new path.

But I was not able to find where this path to Debian is stored, and how it can be changed. For me, the folder is now in C:\Users\{username}\AppData\Local\Packages\TheDebianProject.DebianGNULinux_... and need to be moved to C:\ExcludedFolder

Is this possible? Thank you very much for your response.

Feri
  • 1

1 Answers1

0

First up, you might be able to solve your firewall problem a slightly different way. I can't say for certain (and things are always changing), but it's been my experience that Firewall/Defender only detect and block for WSL1 applications. This is at least true for the malware/antivirus detection, but I believe it would extend to the firewall functionality as well. On the other hand, if it doesn't, then moving the instance to a different directory may not help with your issue.

You can double-check the version of your Debian instance using wsl -l -v. If it's version 1, then let's try converting it to 2 (if you have that permission on your system).

The first steps here are going to be the same regardless of whether you just convert the instance or move it:

  • First, exit your WSL/Debian instance and then issue wsl --shutdown. You can do this from PowerShell, CMD, or the Start Menu; but I'm going to assume for the rest of the instructions that you are in PowerShell.

  • Run the following in PowerShell:

    cd <your exclusion directory>
    mkdir wsl\images
    cd wsl\images
    wsl --export Debian 2021-11-02_Debian_backup.tar
    
  • Assuming that your instance is WSL1 and you want to try to convert to WSL2, you at least now have a backup. Run wsl --set-version Debian 2 to convert it to WSL2. Then start it up and see if there are any differences in how node behaves. You can always convert it back with wsl --set-version Debian 1, of course.

  • If you still need to try moving it:

    cd <your exclusion directory>\wsl
    mkdir instances\debian_exclude
    wsl --import debian_exclude instances\debian_exclude images\2021-11-02_Debian_backup.tar --version 2
    wsl -d debian_exclude
    

    Note that you can, of course, call the filenames and directories whatever you want. Also note that you can change the version number when you import it. Select whichever WSL version you need there.

  • You should now be in a new instance of Debian, but you'll be running as root by default. You need to set the default user of the imported instance by creating /etc/wsl.conf with the following:

    [user]
    default=<your_wsl_username>
    
  • Exit the instance, run another wsl --shutdown, and restart. You should now be running as your normal user. Try node again there to see if new location allows it to be excluded from the firewall rules.

  • If everything is working as intended, you can wsl --unregister Debian to remove the old instance. Please note that this will remove all files in the instance, so please make sure that your backup and new instance have everything you need first.

  • Unregistering the old instance should set the new one as your default, but if not, you can use wsl --set-default debian_exclude.

NotTheDr01ds
  • 15,620
  • 5
  • 44
  • 70