Skip to content
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

Linux home folder to be the same as windows home folder. #5090

Open
dyanakiev opened this issue Apr 15, 2020 · 8 comments
Open

Linux home folder to be the same as windows home folder. #5090

dyanakiev opened this issue Apr 15, 2020 · 8 comments
Labels

Comments

@dyanakiev
Copy link

Is your feature request related to a problem? Please describe.
I need to manage .ssh keys both on windows and linux, this will help that, and other stuff.

Describe the solution you'd like
Allow using windows home folder as linux home folder.

@ad-on-is
Copy link

You can set mnt/c/Users/xxx as your home-folder in /etc/passwd.

@dseynhae
Copy link

The solution indicated by @ad-on-is (clever name!) is what I have done:

  1. Before changing the /etc/passwd file, copy ALL the files from your initial home /home/<user_name> (especially the startup files like .bashrc, and the administration directories like .ssh) to the future new home /mnt/c/Users/<user_name>.
  2. Edit the /etc/passwd file (you will need administration/sudo privileges);
  3. Locate the line that begins with your <user_name>. That same line should have 1000:1000 as your UID (User ID) and GID (Group ID): that is what WSL assigns as the default account when you first install the distro.
  4. The last field in that line is your home directory (should be :/home/<user_name>). Change that to the mounted directory /mnt/c/Users/<user_name>.
  5. Reboot WSL; This is probably easiest to do in a CMD administration window:
sc stop LxssManager
sc start LxssManager

At this point, your WSL window should come up exactly as before, but with the new directory as the home directory.

NOTES:

  • The original home directory uses a VoIFs file system (assuming you're still using WSL, and not WSL2. )
  • The the updated home directory is on a drivefs file system. This might seem transparent to most people, but it is what allows you to work on the file system in both Windows and WSL...
  • I hung on to my old home directory (didn't delete it). It was very minimalist, as I made the switch to my new home directory right after I created the distro. A long time has passed since, and I never once needed to swap back... but you never know...
  • That being said and done, if enough people do this, maybe it should be an option when installing a distro? Which means that the original feature request might make sense (and the solution described by @ad-on-is should be considered a great work around).

@dseynhae
Copy link

dseynhae commented Apr 15, 2020

One more remark: if you want to KEEP your home in /home/<username>, but make it CORRESPOND to your /mnt/c/Users/<user_name>, you could bind it in your /etc/fstab...
Let me know if that needs to be explained in more detail.

Come to think of it, if this feature does get approved and implemented, that's probably how it should be done:

  1. When first starting the distro, create the /home/<user_name> directory.
  2. Bind /mnt/c/Users/<user_name> to it in /etc/fstab.
  3. Mount everything in the /etc/fstab.
  4. Populate the home directory with the template startup files...

@ad-on-is
Copy link

Since there are still I/O performance issues with /mnt, I personally wouldn't want this to be the default setup when installing a distro.

@beltaurus Thx, I carry that nickname since the early 2000s, being that nerdy friend who's always ON-line.

@dyanakiev
Copy link
Author

Currently im not using WSL 1 or 2, im waiting for the new stable windows update with WSL 2 to be released and then i will play with that. In the past i used my windows home folder with the /etc/passwd path change method, there where some permissions issues that i solved by modifying the wsl conf.
Mainly i stopped using WSL because of some performance issues, but i will give it a try again with WSL2.

@ad-on-is
Copy link

As I mentioned, performance issues are due to I/O speeds on /mnt, which are not better in WSL2, some say it's even worse compared to WSL1.

But when working with WSL2, it's recommended to store your work-files inside /home/user, where performance is nearly bare-metal.

@trajano
Copy link

trajano commented May 18, 2020

I would like it to be configurable to make it the default to save the hassle of modifying the /etc/passwd file. It would also make it a more seamless experience for most people who are dabbling on it.

@isimmons
Copy link

So, not complaining because I knew I'd screw something up here. I did the above mentioned solution and broke docker desktop. I think it was because I copied all (I mean ALL) files and folders over blindly. When I installed docker, it created a .docker folder in my windows home dir and in the wsl home dir. Apparently they have different contents or the permissions to the directory might be a problem. But when I copied, it overwrote the existing one. To fix it I did a full purge and reset on docker, renamed the .docker folder, restarted windows and then all was good. Docker re-created the .docker folder and I opened a terminal (wsl working on new home directory) and recreated all my images and deployments.

All this just so I could have

isimmons33@xpsdt:~/code/node/udemy_steven_grider/microservice_course/blog/infra/k8s$

instead of

isimmons33@xpsdt:/mnt/c/Users/isimm/code/node/udemy_steven_grider/microservice_course/blog/infra/k8s$

It helps keep the long path from wrapping in terminal inside vscode

I should probably move work like this into /home/user anyway and then use \wsl$ if I need to access the files in explorer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants