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

WIndows directory of the linux subsystem #402

Closed
nguyenminhduc9988 opened this issue May 20, 2016 · 45 comments
Closed

WIndows directory of the linux subsystem #402

nguyenminhduc9988 opened this issue May 20, 2016 · 45 comments

Comments

@nguyenminhduc9988
Copy link

I cant find the windows path of the linux subsystem which is inconvenient as I want to copy files into the directory from windows.

@tills13
Copy link

tills13 commented May 20, 2016

It's located under /mnt/ i.e. /mnt/c is your C drive.

@nguyenminhduc9988
Copy link
Author

What I mean is the subsystem path in the C directory. I want to access the subsystem path in WIndows Explorer.

@tills13
Copy link

tills13 commented May 20, 2016

My mistake.

@ddfznt
Copy link

ddfznt commented May 20, 2016

Under C:\Users\**user**\AppData\Local\lxss.
You will find:
root folder
home folder
and a hidden rootfsfolder (\bin, \boot, \dev, \etc...)

DON'T CHANGE ANYTHINK INSIDE! SERIOUSLY! 🚨

Access Windows files via /mnt/**letter**/bla bla bla partition, then cp -R . ~

EDIT:

symlinks are suported since 14342.
you can try
ln -s /mnt/**letter**/... ~/winFiles

@aseering
Copy link
Contributor

aseering commented May 20, 2016

@ducminhnguyen -- copying directly into the Linux subsystem from Windows is not supported, according to discussion on other tickets. There is a directory under AppData somewhere (I forget where) that appears to contain the files for the WSL filesystem. But if you put new files there, or modify existing files there, your changes are not reflected correctly inside WSL.

My best guess is that Linux needs to store different metadata (and more caching information, etc, since its disk-buffering model is also different) about its files than Windows does, and that this is currently implemented by storing the master copy of the structure of the Linux filesystem in a database of some sort, and just using the Windows filesystem as a convenient BLOB-store for that database.

If you really need to do this, a workaround would be to write a drag'n'drop .bat script or somesuch that does bash.exe -c "mv %1 /home/$USER/". (You'll have to do some clever work with sed and tr, probably, to translate %1 to a valid WSL path.)

Alternatively -- could you put your files in a Windows directory and, within WSL, do "cd ~; ln -s /mnt/c/path/to/my/files" to make them appear to be in your WSL homedir?

@nguyenminhduc9988
Copy link
Author

@ddfznt yeah I wont change anything. I am just tired of typing cp command.
@aseering yeah that could work. I will try it later. Thanks for the suggestion.

@totalknowledge
Copy link

Are there any best practices around file storage when installing tools or programs that you want to be available in the wls?

@ghost
Copy link

ghost commented Aug 3, 2016

As of 1611, %localappdata%\lxss doesn't seem to exist

@DJviolin
Copy link

DJviolin commented Aug 3, 2016

What if someone is trashed his Ubuntu subsystem and wants a fresh start? Is it safe to remove C:\Users\**user**\AppData\Local\lxss then? Does this mean a "freash start" when I start again the Bash window?

@benhillis
Copy link
Member

If you want a fresh start use lxrun.exe /uninstall /full

Reinstall by running bash.exe when that completes.

@DJviolin
Copy link

DJviolin commented Aug 3, 2016

Thank You! Meanwhile I already found out this in the documentation. I'm using these commands:

# Windows folder:
# C:\Users\[user]\AppData\Local\lxss

# Uninstall with keeping root dir
# lxrun /uninstall

# Uninstall completely:
# lxrun /uninstall /full /y

# New install (root user created):
# lxrun /install /y

Is there any way to make a backup from an actual state (like before package installs)? If I zipping the C:\Users\**user**\AppData\Local\lxss folder that's enough for actual state backups?

@onomatopellan
Copy link

onomatopellan commented Aug 3, 2016

Only lxrun.exe can create that folder. It's a special folder with Extended Attributes so copying it manually won't work.
I also like to have a "base" backup without any package installed. You can do this.

  • close any bash window and go to %LocalAppData%
  • enable see hidden and system folders
  • rename folder lxss to lxss.base
  • now from an admin CMD type lxrun /uninstall and lxrun /install and add same username as before.

After finishing installing there will be lxss and lxss.base folders. If you want to use the "lxss.base" folder you just have to rename it back to lxss before launching bash.

@DJviolin
Copy link

DJviolin commented Aug 3, 2016

So what you saying is lxss folder can be copied but can't be zipped? I read somewhere symlinking this folder into a vmdk, which seems to be the best option if you cannot do any modification inside lxss from any windows text editors and you cannot copy any file into it.

For creating a new dev environment, I use a massive shell script, which is not nice, but I think this is the nearest let's say for a Dockerfile.

For a dev environment, BashOnWindows is great, but reading from so many people how many times they recreating this from scratch (including me), I definitely not want to store any database inside WSL.

EDIT:

Nope, you have to put the entire local folder into a new drive or a vmdk, which I definitely not want. Is there a way to put only lxss folder into a VMDK symlink?

If this file system so restricted and basically you cannot do anything inside it from Windows, why not packaged into a VHD(X) on the first-place? For maintaining it would be much better.

@onomatopellan
Copy link

onomatopellan commented Aug 3, 2016

lxss can't be a symlink anymore since build 14388. It will install but at launching bash it will show error 0x80070003.

Before that it was easy attaching a VHDX file to the lxss folder for example.

Anyway Microsoft knows about this problem and they are already thinking about different solutions.

Windows 10 Image System backup can create an image of the entire system drive with lxss folder and its attributes intact but of course it will be a huge image file that also contains Windows.

@fjanoos
Copy link

fjanoos commented Sep 28, 2016

is there a way to change the windows folder into which lxss installs ? my c:/ is running very low on space, I am trying to move all my stuff on to my d:

@ghost
Copy link

ghost commented Dec 27, 2016

Hi, I use Win10 and went to C:\Users\[user]\AppData\Local but couldn't find lxss folder. I am able to see hidden files. Where is the lxss folder than? Thanks,

@benhillis
Copy link
Member

It is marked as system as well. Keep in mind you should not modify anything in that directory.

@sourcevault
Copy link

@benhillis use command line to access it. Or type it in the address bar

@benhillis
Copy link
Member

@partially-applied - I don't follow your comment. I'm just warning people that they should not do it.

@davidalbertonogueira
Copy link

I agree with @benhillis. Don't edit files there or add new ones (it wouldn't be visible/accessible from ubuntu anyway). Access to that folder should be read-only.

@iFreilicht
Copy link

iFreilicht commented Mar 17, 2017

@partially-applied I think you meant to mention @Benosika. Thank you so much for this, I was going crazy over why I couldn't see this folder and the whole internet seemingly disagreeing with me on the existence of it.

@devloprs
Copy link

devloprs commented May 2, 2017

how do I get a windows program that requires node.js to use the wsl installed version? :) To clarify I have node installed in wsl and would like my windows programs, like sublime text to see it. It needs it to run prettify js amongst other things.

@aseering
Copy link
Contributor

aseering commented May 2, 2017

Folks here may have suggestions (I know this is discussed on other tickets and others have made it work in some cases), but you might also want to ask the Sublime developers. Linux interpreters may have behavior or features that are different from their Windows counterparts, so a really feature-complete integration would require them to know to use the interpreter's Linux interface.

@dreamcat4
Copy link

@aseering I have commented on the Sublime issue today.

@oneduality
Copy link

oneduality commented Jul 19, 2017

One option would be to install nfsd and export the rootfs on ubuntu, then you'd need to activate client for nfs under programs & features, configure the service and launch it.. well, you obviously need to know how to get the nfs daemon configured as well but there's plenty of documentation online for that.

I have toyed around and got apache2 with PHP and MySQL running, you just have to manually start the services and then remember to shut them down before you exit or you could have some database corruption... but that's entirely unrelated =)

UPDATE:

I gave it a shot, it doesn't work because the ubuntu kernel doesn't support it

@f0ster
Copy link

f0ster commented Aug 11, 2017

I have win10 Build 16241 , with ubuntu installed through the "store", and the lxss directory no longer exists in C:\Users\[user]\AppData\Local

@benhillis
Copy link
Member

benhillis commented Aug 11, 2017

@f0ster - Each distribution you install through the store is installed to that application's appdata directory. For example: C:\Users\<username>\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState

@AdrielleKiz
Copy link

AdrielleKiz commented Aug 24, 2017

I'm using the linux subsystem in windows 10 with ubuntu installed
Sorry,noob here
How do I access the Desktop
cd~/Desktop is not working for me
My current dir is at /home/USERNAME
Tried ls in the my current dir and it shows up nothing while ls -a got some hits but it seems that they're all hidden files ,not directories.

@sunilmut
Copy link
Member

@AdrielleKiz - Try "ls /mnt/<system drive>/Users/<user name>/Desktop"

@AdrielleKiz
Copy link

@sunilmut Thanks !

@cec
Copy link

cec commented Jan 11, 2018

@benhillis lifesaver

@danielschmitz
Copy link

danielschmitz commented Jan 29, 2018

Open a windows terminal and:

subst l: c:\Users\path\to\rootfs

result: a L: drive mapping to your linux root

image

@r3lik
Copy link

r3lik commented Apr 13, 2018

when I copy/move files in my home directory using the explorer, the changes aren't reflected in my terminal. Anyone know how to solve this?

@davidalbertonogueira
Copy link

@r3lik , you are now allowed to do that. You should access that folder in a read-only scope.

@r3lik
Copy link

r3lik commented Apr 14, 2018

@davidalbertonogueira it wasn't working for me when I wanted to edit things in c:\Users\path\to\rootfs. I ended up just setting HOME="/mnt/c/Users/r3lik" in my .profile as a workaround.

@shawnz
Copy link

shawnz commented May 31, 2018

Changing your home variable like that is strongly not recommended @r3lik. Why don't you just copy your files from inside WSL as recommended in the docs?

@jcklpe
Copy link

jcklpe commented Aug 7, 2018

I can't answer for him @shawnz but I can say that at least for myself it's a pain in the ass. Learned a lot of Linux stuff using WSL, now I'm starting to think that I should just go fully Linux and drop the windows thing all together, haha

@ctseto
Copy link

ctseto commented Nov 28, 2018

Open a windows terminal and:

subst l: c:\Users\path\to\rootfs

result: a L: drive mapping to your linux root

image

Would it make more sense to point to lxss than lxss/rootfs? from lxss/ can access /home directories and the such, though I remain wary of testing read/write through windows. I'll probably stick to copying stuff from linux to /mnt/c/Users/user/ for the time being.

@sorenwacker
Copy link

lxss does not exist in AppData....

@enricoreich
Copy link

enricoreich commented May 11, 2019

The lxss folder with wslhost.exe is located at: C:\Windows\System32\lxss

bash.exe comes from: C:\Windows\System32\

The rootfs for WSL's are located at:

Ubuntu:

C:\Users\{username}\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs\

access via explorer.exe: \\wsl$\Ubuntu

KALI:

C:\Users\{username}\AppData\Local\Packages\KaliLinux.54290C8133FEE_ey8k8hqnwqnmg\LocalState\rootfs\

access via explorer.exe: \\wsl$\kali-linux

Debian:

C:\Users\{username}\AppData\Local\Packages\TheDebianProject.DebianGNULinux_76v4gfsz19hv4\LocalState\rootfs\

access via explorer.exe: \\wsl$\Debian

@ytskuh

This comment has been minimized.

@mobilex1122
Copy link

The lxss folder with wslhost.exe is located at: C:\Windows\System32\lxss

bash.exe comes from: C:\Windows\System32\

The rootfs for WSL's are located at:

Ubuntu:

C:\Users\{username}\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs\

access via explorer.exe: \\wsl$\Ubuntu

KALI:

C:\Users\{username}\AppData\Local\Packages\KaliLinux.54290C8133FEE_ey8k8hqnwqnmg\LocalState\rootfs\

access via explorer.exe: \\wsl$\kali-linux

Debian:

C:\Users\{username}\AppData\Local\Packages\TheDebianProject.DebianGNULinux_76v4gfsz19hv4\LocalState\rootfs\

access via explorer.exe: \\wsl$\Debian

it is work!!!

@AndrewBogdanovTSS
Copy link

AndrewBogdanovTSS commented Sep 23, 2021

I only see one file in C:\Users\{username}\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc\LocalState
ext4.vhdx
image
it seems to be a virtual drive that can't be mounted
was it changed somehow?

@benhillis
Copy link
Member

@AndrewBogdanovTSS - you are using WSL2 which stores the files on an ext4-formatted vhd.

@AndrewBogdanovTSS
Copy link

So how than files can be viewed in WSL2?

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

No branches or pull requests