-
Notifications
You must be signed in to change notification settings - Fork 114
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
A few suggestions to improve this #7
Comments
I've just tried to apply the workaround for the first time, already with your suggestions applied. I got WSL2 + Ubuntu 20.04. Far from being a Linux admin or anything. The trick for me is that whenever I'd launch wsl after changing the default user, I'd only get root user with regular bash in my terminal. systemctl would not work either. After checking the code a few times I figured that wsl could be somehow finding the user correctly - but when effectively launching with that user it would then grab the first in the list with that uid. In that case, the actual Out of that thought I went It kinda worked. After shutting wsl down and launching ubuntu again, I get the message:
Notice that I haven't tried up anything further than that, so I don't know for a fact if anything weird would come out of this. |
In 20.04, |
@esatapedico I was getting the same error. It happens when if [[ -z ${SYSTEMD_PID} ]]; then
# start systemd
/usr/bin/daemonize -l "${HOME}/.systemd.lock" /usr/bin/unshare -fp --mount-proc /lib/systemd/systemd --system-unit=basic.target
# wait for systemd to start
retries=50
while [[ -z ${SYSTEMD_PID} && $retries -ge 0 ]]; do
(( retries-- ))
sleep .1
SYSTEMD_PID=$(pgrep -xo systemd)
done
if [[ $retries -lt 0 ]]; then
>&2 echo "Systemd timed out; aborting."
exit 1
fi
fi |
Update instructions based on feedback from @scotte and @JohnTasto - Issue shayne#7
Based on the comments here - I modified the instructions - hopefully helpful for everyone |
@atiensivu Looks like the closing Are you going to submit a PR back to this repo? |
did you try running the command with elevated powershell prompt (right clicking on the powershell icon ? |
One question I'm hoping someone can answer; on step 3 it mentions to use both for the shadow file do I just copy the root line, and paste it below that, changing "root" to "rootwsl"? like this:
|
HALP!1 I just can't seem to get this working, can anyone please spot the problem for me? My /usr/local/bin/wsl2hack
Now when I try to set the default user to root, I get this: If I ty to open a new Ubuntu tab in Windows Terminal, it shows this (so it at least seems like it's reading the new wsl2hack file): Can anyone help me out? I'm pretty much a beginner at Linux so this may be something easy that I just don't know how to handle. |
UNAME="kacey" UUID=$(id -u "${UNAME}") I could be missing something here, but didnt you set the user to " kacey " ? should it be --default-user kacey ? |
Hi @wanfuse123
I am a bit confused about that too. I'm following these instructions: https://github.com/shayne/wsl2-hacks/blob/50d379fbc87f4ed9211c7682339cc75eadf1112e/README.md and it says at # 2:
My normal Ubuntu username is kacey. But further down at # 4 it says (btw, I'm using the direct ubuntu version from the store, so my ubuntu.exe has no version # in it):
Am I doing it wrong? |
Myself i found additional directions ( sorry don't remember where from) for
booting ubuntu under wsl2 from non root user
And just combined them.
Its possible it was directions from another fork of that project.
Search google for :
booting ubuntu under wsl2 from non root user
Also i dont think it should still be trying systemd if you have installed
daemonize instead
Note proper changes to /etc/passwd and the corresponding file bash script
file it points to.
As i recall daemonize was one of a few of the packages needing to be
installed and systemd was bot one of them.
Good luck!
…On Sat, Oct 17, 2020, 11:21 PM Kacey ***@***.***> wrote:
Hi @wanfuse123 <https://github.com/wanfuse123>
UNAME="kacey"
UUID=$(id -u "${UNAME}")
UGID=$(id -g "${UNAME}")
I could be missing something here, but didnt you set the user to " kacey "
?
should it be --default-user kacey ?
I am a bit confused about that too. I'm following these instructions:
https://github.com/shayne/wsl2-hacks/blob/50d379fbc87f4ed9211c7682339cc75eadf1112e/README.md
and it says at # 2:
Add the following, be sure to replace with your WSL2 Linux username
# your WSL2 username
UNAME="<YOURUSER>"
My normal Ubuntu username is kacey.
But further down at # 4 it says (btw, I'm using the direct ubuntu version
from the store, so my ubuntu.exe has no version # in it):
In a PowerShell terminal run:
ubuntu2004.exe config --default-user root
Am I doing it wrong?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#7 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADDBZWIA4PH5VYADG26SKATSLJNMPANCNFSM4M3O4OZQ>
.
|
Thanks for helping @wanfuse123 :) Being a almost total newbie with Linux, can you help me understand how doing a:
as a non-root user would be better (or work at all) over doing it as a root user? I'm a bit confused with that. The above commands I am running as the "true admin" user account in Windows (the hidden Administrator account); if I do this command from my regular windows user account that has Admin privileges, I get this: Also, is this what you meant? (and putting a non-root user for the user name? currently I use the user name 'root' just to be able to get back into my Ubuntu after I made all these changes).
AFAIK I copied the paths and script code verbatim. The only confusion I really have there is the shadow file (
Again, I'm just a newbie but I thought systemd was a default part of Ubuntu and didn't have to be installed via a package? (definitely could be wrong here). I'm not sure why the script tests for systemd; that's beyond my Linux knowledge for sure, lol! |
It seems like I'm "halfway" there at least. When I do:
It says:
It just seems that I can't switch it to using the default account "root", like the tutorial shows. Also, I used your tutorial @atiensivu , perhaps you can help? I'd also love some input from the others in this thread, as I have a feeling they know WAY more about this than I do, and probably already have thiers up and running. @scotte @esatapedico @JohnTasto I'd really genuinely appreciate the help so I can move on to the things I'm stuck holding off on until I can get this working. :) |
Well, I've come to the conclusion that this just doesn't work. I give up. Anyone else who may come across this, I'd suggest not wasting your time on it. |
@YouveGotMeowxy, I also struggled, but I managed to get this working for Ubuntu 20.04. I used the instructions on https://github.com/atiensivu/wsl2-hacks. The only part that was missing was the shadow file edit (which you highlighted above), and a closing
@atiensivu, please update your |
Following these instructions, when I start WSL, I'm root. Even though the default-user is rootwsl. The script successfully logs me in as myself if I run it manually, but it doesn't run on login (because it's set for rootwsl and I'm showing up as root?). What am I doing wrong? passwd: root:x:0:0:root:/root:/bin/bash
rootwsl:x:0:0:root:/root:/usr/local/bin/wsl2hack I've also tried My |
Thank you for this - it's great, but I have a few suggestions to improve this.
root
user. Instead create a second root user with same uid but a different username, such as:Don't edit
/etc/passwd
(or/etc/shadow
) directly, instead usevipw
andvipw -s
.Put the script in
/usr/local/bin/
and don't call itbash
(you can see what I did above in my passwd fragment).Don't swallow the output from
daemonize
and don't retry forever. Here's what I do (I also loosened up the sleep a bit, 100ms is fast enough for me):Just my suggestions, for what they are worth. Thanks again!
The text was updated successfully, but these errors were encountered: