lucyllewy / one-script-wsl2-systemd

The one-script variant of the systemd hack for WSL2
MIT License
231 stars 38 forks source link

WIP: Improvements for Builds >=21286 #4

Closed lucyllewy closed 3 years ago

lucyllewy commented 3 years ago

This will become the primary branch once Windows in stable channels supports the boot.command feature in WSL.

nezorflame commented 3 years ago

Hi! Decided to give this another go on stable 21H1 19043.1052 build. It's not Insiders one, but AFAIK should work fine.

I had a few issues during the script execution:

  1. I had to replace powershell.exe to pwsh.exe in the script since I'm using PowerShell Core. I suggest you should detect the current shell instead of forcing the vanilla powershell binary, e.g. with (Get-Process -Id $pid).ProcessName

  2. Got few errors for Invoke-WslCommand:

      --- Detecting default user in Ubuntu
      Invoke-WslCommand: <repo_path>\install.ps1:392
      Line |                                                                                                                   
      392 |      $User = Invoke-WslCommand -Command "whoami"                                                                     
          |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                                                      
          | Parameter set cannot be resolved using the specified named parameters. One or more parameters issued                  
          | cannot be used together or an insufficient number of parameters were provided.
    
      --- Ensuring  is a sudoer in Ubuntu                                                                                     
      Invoke-WslCommand: <repo_path>\install.ps1:398                                           
      Line |                                                                                                                   
      398 |  Invoke-WslCommand -User 'root' -Command "usermod -a -G sudo $User 2>/ …                                              
          |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                                
          | Parameter set cannot be resolved using the specified named parameters. One or more parameters issued                  
          | cannot be used together or an insufficient number of parameters were provided.
    
      Invoke-WslCommand: <repo_path>\install.ps1:399                                           
      Line |                                                                                                                   
      399 |  Invoke-WslCommand -User 'root' -Command "usermod -a -G wheel $User 2> …                                              
          |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                                
          | Parameter set cannot be resolved using the specified named parameters. One or more parameters issued                  
          | cannot be used together or an insufficient number of parameters were provided.
    
      --- Installing files in Ubuntu
      // and it goes on with the script

    When I tried those manually, they seemed to work fine though, so not sure what's the issue here.

  3. While trying to log into Ubuntu, I got this error: nsenter: failed to execute machinectl: No such file or directory and it exited the shell with the code 127.

Is it expected due to my build version being a stable one, or something else is the issue?

lucyllewy commented 3 years ago

No, that's a bug - I forgot to get the script to install systemd-container, which on Ubuntu is the package providing machinectl.

nezorflame commented 3 years ago

Nice, got it to boot with the fixed script. First boot log contains an error though: 2021/06/22 01:14:04 socat[447] E bind(5, {AF=1 "/home/nezorflame/.ssh/agent.sock"}, 34): No such file or directory Seems that agent wasn't started on Ubuntu side?