Linux subsystem for windows location

Infrastructure

Here, I delve into the process of installing the Windows Subsystem for Linux (WSL) on a custom location on your Windows 10 machine, making it easier for developers to manage and access their Linux environment.

Installing WSL to a Custom Location

Photo by Lukas / Unsplash

WSL is simply amazing! Providing you the power of Linux all within a Windows environment. Allowing us to switch seamlessly between OS using VSCode (since Linux development is so much easier).

But if you are like me and you are running WSL, you don’t always want to install it to the C:\ drive (which is what you get when installing it from the Windows Store) but you want to be able to pick your own Drive. So how can we do this?

Finding our Distro

First find the link to the distro you want from this page: https://learn.microsoft.com/en-us/windows/wsl/install-manual#downloading-distributions

E.g., for Ubuntu 22.04 you can use: https://aka.ms/wslubuntu2204

Downloading and Installing WSL to your Drive

Next, read through the following using the link above for your distro:

# Navigate to the destination directory
cd E:\WSLTest

# Enable WSL
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

# Downloading Ubuntu 22.04
Invoke-WebRequest -Uri https://aka.ms/wslubuntu2004 -OutFile Ubuntu.appx -UseBasicParsing

# Open the .AppxBundle in 7Zip and Extract the x86.appx file

# Unpack
move .\Ubuntu.appx .\Ubuntu.zip
Expand-Archive .\Ubuntu.zip

# Install
.\Ubuntu\ubuntu.exe

# Verify
wsl --list --all

Summary

When you now use wsl -l you will see your own installed

Windows stores the Linux files in the directory. You will need to enter C:/Users/NAME/App, and data/local/packages. Alternatively, you can navigate manually here in File Explorer and view hidden folders.

A query we ran across in our research was “Where is windows subsystem for linux stored?”.

The Windows Subsystem for Linux only runs on your system drive (usually this is your C: drive). Make sure that distributions are stored on your system drive: Open Control Panel -> Programs and Features -> Turn Windows Feature on or off -> Check Windows Subsystem for Linux or using the Power. Shell cmdlet mentioned at the beginning of this article.

Another frequently asked query is “Where is the Linux Subsystem for Windows located?”.

Not that I’d really ever want to—I’m just trying to get a feel for how Windows is organizing this Subsystem for Linux thing. In WSL, all the linux filesystem is located under a Windows folder. The location of the folder depends on the version of Windows and of the WSL distribution you are using.

In earlier iterations of Windows Subsystem for Linux, the Ubuntu file system was at %localappdata%\Lxss (e. g, C:\Users\Username\App. Data\Local\Lxss – replace the Username with your Username on Windows). See the WSL blog post on File System Support: The primary file system used by WSL is Vol, and fs.

One common answer is, yes, you can access Windows files from the Linux subsystem and vice versa. It is possible to share and access Windows files from the Linux subsystem using the WSL terminal. You need to open the File Explorer in the terminal.

For WSL2 you can access to home directory from windows (Windows 10 build 18342) like this : In earlier iterations of Windows Subsystem for Linux, the Ubuntu file system was at %localappdata%\Lxss (e. g, C:\Users\Username\App. Data\Local\Lxss – replace the Username with your Username on Windows).

Where does WSL store the Linux filesystem?

Initial versions of WSL store the linux filesystem in %LOCALAPPDATA%Lxssrootfs. WSL distributions installed from the Windows Store, starting in Windows Build 16215 (mid of 2017), use a folder like %LOCALAPPDATA%Packages Local, and staterootfs.

You can also access them directly at a \wsl$ path. In File Explorer or any other Windows application that can browse files, navigate to the following path: \wsl$. You’ll see the folders for all your installed Linux distributions, which are exposed as if they were network shares.

Another frequently asked question is “Where can I find the location of each filesystem on Windows?”.

The location of each filesystem can be obtained from the Windows Registry. The data is located under Lx, run Offline is a tool for managing linux distributions installed on WSL.

Where can I find the Linux file system?

If you have installed, moved or duplicated a linux distribution using Lx, run Offline or any version of the WSLDistro. Launcher, the filesystem can be located in any folder of your computer. The location of each filesystem can be obtained from the Windows Registry.

How do I open a Linux file system?

There are two ways to access your Linux files. First, the easy one. From within the Windows Subsystem for Linux environment you want to browse, run the following command: explorer., and exe. This will launch File Explorer showing the current Linux directory—you can browse the Linux environment’s file system from there.

  • Where is WSL located on my computer?
  • Where is the Linux Subsystem’s filesystem located in Windows 10?
  • Where are the files inside wsl2 physically stored? [closed]
  • What is the home directory on Windows Subsystem for Linux?
  • How to Access Your Linux (WSL) Files in Windows 10
  • Where is WSL located on my computer?
  • Directory locations when using WSL

Where is WSL located on my computer?

People also askHow to install the Windows Subsystem for Linux?How to install
the Windows Subsystem for Linux?To get started, first you need to enable the
Windows Subsystem for Linux (WSL) on your PC:

Get-ChildItem "HKCU:\Software\Microsoft\Windows\CurrentVersion\Lxss" -Recurse



{cff9bfd6-39db-42af-a85b-d6fca State              : 1
94beff8}                       DistributionName   : Ubuntu
                               Version            : 2
                               BasePath           : C:\Users\krutik\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState
                               Flags              : 15
                               DefaultUid         : 1000
                               PackageFamilyName  : CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc
                               KernelCommandLine  : BOOT_IMAGE=/kernel init=/init
                               DefaultEnvironment : {HOSTTYPE=x86_64, LANG=en_US.UTF-8, PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games, TERM=xterm-256color}



ls /mnt/c/Users
ls /mnt/c

Where is the Linux Subsystem’s filesystem located in Windows 10?

If you install some linux distributions from the Windows Store, the
filesystems are located under
%USERPROFILE%\AppData\Local\Packages\\LocalState\rootfs If you have
installed, moved or duplicated a linux distribution using LxRunOffline or any
version of the WSLDistroLauncher , the filesystem can be located in any folder
of your computer.

%LOCALAPPDATA%\Lxss\rootfs



%LOCALAPPDATA%\Packages\<distribution_specific_name>_<random_string>\LocalState\rootfs


CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc


\\wsl$



HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss



PS> (Get-ChildItem HKCU:\Software\Microsoft\Windows\CurrentVersion\Lxss | ForEach-Object {Get-ItemProperty $_.PSPath}) | select DistributionName, @{n="Path";e={$_.BasePath + "\rootfs"}}



DistributionName Path
---------------- ----
Ubuntu           C:\Users\Jaime\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs
Ubuntu-18.04     C:\Users\Jaime\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\LocalState\rootfs
mydistro         C:\wsl\mydistro\rootfs



# lxrunoffline get-dir -n <name of the distro>

C:\> lxrunoffline get-dir -n backup
c:\wsl\installed\backup

C:\> lxrunoffline get-dir -n Ubuntu
C:\Users\Jaime\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState



C:\Users\myUserName\AppData\Local\Packages\UbuntuLinux.someUID\LocalState\rootfs\root



C:\Users\myUserName\AppData\Local\Packages\UbuntuLinux.someUID\LocalState\rootfs\home\myLinuxUserName

Where are the files inside wsl2 physically stored? [closed]

move the LocalState folder to another location like Z:\wsl\Ubuntu\ create
symbolic link with mklink /J LocalState Z:\WSL\Ubuntu\LocalState I would also
edit/create the .wslconfig file from your user folder to move the swap file to
the folder where you store your WSL vm’s and maybe edit/add options for CPU
cores and RAM assignment

PS C:\Users\smarc> mkdir D:\wsl-ubuntu  (create new location)
PS C:\Users\smarc> wsl -l -v            (list wsl distros)
NAME                   STATE           VERSION
Ubuntu                 Running         2
PS C:\Users\smarc> wsl --shutdown
PS C:\Users\smarc> wsl -l -v            (verify if is stopped)
NAME                   STATE           VERSION
Ubuntu                 Stopped         2
PS C:\Users\smarc> wsl --export Ubuntu ubuntu.tar  
PS C:\Users\smarc> wsl --unregister Ubuntu
PS C:\Users\smarc> wsl --import Ubuntu D:\wsl-ubuntu\ .\ubuntu.tar --version 2



[wsl2]
memory=4GB
processors=2
swap=1GB
swapFile=Z:\\WSL\\swap.vhdx

What is the home directory on Windows Subsystem for Linux?

Not that I’d really ever want to—I’m just trying to get a feel for how
Windows is organizing this Subsystem for Linux thing. In WSL, all the linux
filesystem is located under a Windows folder. The location of the folder
depends on the version of Windows and of the WSL distribution you are using.

/mnt/c/Users/<username>



/home/<username>



# \\wsl$\<Distribution>:

\\wsl$\Ubuntu



%LOCALAPPDATA%\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs



%LOCALAPPDATA%\Packages\



explorer.exe .



## You can use lxrunoffline to check which WSL distributions have installed
## using:   lxrunoffline list

C:\> lxrunoffline list
backup
Ubuntu-18.04    

## And you can use it to get the location of any of these WSL installations
## using:   lxrunoffline get-dir -n <name of distribution>

C:\> lxrunoffline get-dir -n backup
c:\wsl\installed\backup

C:\> lxrunoffline get-dir -n Ubuntu
C:\Users\Jaime\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState



C:\Users\USER_NAME\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu16.04onWindows_79rhkp1fndgsc\LocalState\rootfs\etc\environment



$ sudo cat /mnt/c/Users/USER_NAME/AppData/Local/Packages/CanonicalGroupLimited.Ubuntu16.04onWindows_79rhkp1fndgsc/LocalState/rootfs/etc/environment

PATH="/mnt/e/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
export LIBGL_ALWAYS_INDIRECT=Yes
export DISPLAY=localhost:0.0



C:\ProgramData\chocolatey\lib\wsl-<distribution-name>\tools\unzipped\rootfs\home



C:\ProgramData\chocolatey\lib\wsl-ubuntu-1804\tools\unzipped\rootfs\home

How to Access Your Linux (WSL) Files in Windows 10

In File Explorer or any other Windows application that can browse files,
navigate to the following path: \\wsl$. You’ll see the folders for all your
installed Linux distributions, which are exposed as if they were network
shares. For example, Ubuntu 22.04 usually is available at
\\wsl$\Ubuntu-22.04.

explorer.exe .


\\wsl$

Where is WSL located on my computer?

When you enable it, the applicable binaries are found under
C:\Windows\System32\lxss. You’ll rarely need to worry about this folder, but
there are some times when it comes in handy. The WSL2 kernel is also located
in this folder, and you can back up older kernels if you want to rollback more
than one release.

Get-ChildItem "HKCU:\Software\Microsoft\Windows\CurrentVersion\Lxss" -Recurse



{cff9bfd6-39db-42af-a85b-d6fca State              : 1
94beff8}                       DistributionName   : Ubuntu
                               Version            : 2
                               BasePath           : C:\Users\krutik\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState
                               Flags              : 15
                               DefaultUid         : 1000
                               PackageFamilyName  : CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc
                               KernelCommandLine  : BOOT_IMAGE=/kernel init=/init
                               DefaultEnvironment : {HOSTTYPE=x86_64, LANG=en_US.UTF-8, PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games, TERM=xterm-256color}



ls /mnt/c/Users
ls /mnt/c

Directory locations when using WSL

1 Answer. Sorted by: 0. You have Windows Subsystem for Linux which runs
Ubuntu, different from a dual-boot installation where you are running either
the Windows OS or the Ubuntu OS. WSL stores anything you make into a directory
somewhere under your User directory. That’s why your directory placed under …

mkdir Submarine



cd Documents/

WSL (Windows Subsystem for Linux) is a specially created software layer by Microsoft to run Linux binary executables natively on Windows 11 or 10. When you install a Linux distribution on WSL, it creates a Linux environment within Windows, with its own file system and home directory. However, how to find this directory using Graphical File Explorer of Windows? If you don’t know that then in this article, we learn about it.

The default home directory for the user account in WSL is located at /home/<username> which can be accessed using the Command line interface of WSL running bash.

For example, if your username is H2s, your home directory in WSL would be located at /home/h2s. By default, when we start the WSL Linux app, we are in our Home directory. You can switch to that using:

cd /home

The working of the home directory in WSL Linux is similar to the traditional Linux distros we are running on virtual machines, containers, or bare systems. It holds all files related user’s personal files and configuration settings. All the files of the home directory are only meant to use for your WSL instance and will not interfere with the Windows file system or vice versa…

Although we are showing this tutorial using for Ubuntu subsystem, the process will be the same for others too such as OpenSUSE, Kali, and Debian installed on WSL. 

Steps to Find the WSL home directory using the GUI file explorer of Windows 

  1. On your Windows 10 or 11, go to File Explorer or simply open MyPC to get it for finding the WSL Linux app home folder.
  1. After that from the left side panel scroll down to the end.
  1. Open WSL Linux File Explorer: There you will see the Linux Penguin icon, click that.
  1. Now, all the installed Linux apps such as Ubuntu, Debian, Kali, etc. on your WSL will show in the folder.
  1. For example, if we open the Ubuntu folder then inside that we will have a directory called ‘home‘. Open that and you will find the user of that WSL Linux app along with other files.
Find Ubuntu WSL Linux home user files

  1. After selecting the Linux WSL app, open the Home directory you want to explore manually using the GUI.
Find the Home directory

Open WSL Linux File Explorer

Additional tip:

To access all Windows 11 or 10 system drives under the Command Terminal of Ubuntu or another Linux environment installed on Windows WSL; we need to follow the mounting command of Linux.

Note: One thing to be mentioned is that the Bash Shell of the Linux environment should be launched under the Administrative right to access the system folders of Windows. To give administrative permission just right-click on the installed Linux environment such as Ubuntu and select “Run as Administrator”.

From your Linux Bash Shell type the following command to mount C: Drive:

cd /mnt/c
ls

In the same way for D: drive type 

cd /mnt/d
ls

In this way, we can also mount both internal and external drives attached to our Windows 11 or 10 systems including the network drives.

Other Articles:

  • Install Git LFS on WSL2 – Windows 11 or 10?
  • How to install Anaconda on WSL Windows 10/11 using Ubuntu Linux App
  • How to install Oracle Linux on Windows 10 or 11 WSL – Subsystem
  • Install WSL- Windows Subsystem for Linux on Windows 11

Понравилась статья? Поделить с друзьями:
0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Windows 10 не включаются необязательные диагностические данные
  • Windows xp какой год выпуска
  • Windows xp themes style xp
  • Как определить выпуск windows
  • Приложение сканер для windows 10 на русском