WSL icon indicating copy to clipboard operation
WSL copied to clipboard

WIndows directory of the linux subsystem

Open nguyenminhduc9988 opened this issue 10 years ago • 45 comments

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

nguyenminhduc9988 avatar May 20 '16 04:05 nguyenminhduc9988

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

tills13 avatar May 20 '16 04:05 tills13

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

nguyenminhduc9988 avatar May 20 '16 05:05 nguyenminhduc9988

My mistake.

tills13 avatar May 20 '16 05:05 tills13

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! :rotating_light:

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

ddfznt avatar May 20 '16 11:05 ddfznt

@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?

aseering avatar May 20 '16 11:05 aseering

@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.

nguyenminhduc9988 avatar May 20 '16 13:05 nguyenminhduc9988

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

totalknowledge avatar Jul 15 '16 12:07 totalknowledge

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

ghost avatar Aug 03 '16 08:08 ghost

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?

LantosIstvan avatar Aug 03 '16 12:08 LantosIstvan

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

Reinstall by running bash.exe when that completes.

benhillis avatar Aug 03 '16 14:08 benhillis

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?

LantosIstvan avatar Aug 03 '16 16:08 LantosIstvan

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.

onomatopellan avatar Aug 03 '16 17:08 onomatopellan

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.

LantosIstvan avatar Aug 03 '16 21:08 LantosIstvan

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.

onomatopellan avatar Aug 03 '16 21:08 onomatopellan

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:

fjanoos avatar Sep 28 '16 04:09 fjanoos

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,

ghost avatar Dec 27 '16 07:12 ghost

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

benhillis avatar Dec 27 '16 15:12 benhillis

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

sourcevault avatar Feb 02 '17 10:02 sourcevault

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

benhillis avatar Feb 02 '17 16:02 benhillis

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.

davidalbertonogueira avatar Feb 15 '17 19:02 davidalbertonogueira