Где находятся файлы ubuntu в bash для windows 10

Добрый день. Подскажите пожалуйста , в какой папке находится ubuntu.
  • Remove From My Forums
  • Вопрос

  • Добрый день. Подскажите пожалуйста , в какой папке находится ubuntu. 

    В папке C:Usersимя_пользователяAppDataLocallxss отсутствует lxss папка (включено отображение скрытых файлов )

Ответы

  • Это так должно выглядеть :) ?

    Добрый день.

    Думаю да.

    Нет возможности проверить так как нет под рукой ос Windows 10.

    По технологию понятно, но Поясните зачем вам данные файлы?

    Если вопрос решен, пометьте сообщения которые вам помогли в качестве ответа


    Я не волшебник, я только учусь
    MCP, MCTS. Мнения, высказанные здесь, являются отражением моих личных взглядов, а не позиции работодателя. Вся информация предоставляется как есть без каких-либо гарантий.
    Блог IT Инженера и
    IT Reviews

    • Изменено

      13 сентября 2016 г. 21:43
      Дополнил

    • Помечено в качестве ответа
      artemgauch
      13 сентября 2016 г. 21:50

For Ubuntu installed from the Windows store:

Each distribution you install through the store is installed to that
application’s appdata directory. For example:
C:Users<username>AppDataLocalPackagesCanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgscLocalState — benhillis

For WSL2 you can access to home directory from windows (Windows 10 build 18342) like this :

\wsl$

In earlier iterations of Windows Subsystem for Linux, the Ubuntu file system was at %localappdata%Lxss (e.g., C:UsersUsernameAppDataLocalLxss — 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 VolFs. It is used to store the
Linux system files, as well as the content of your Linux home
directory. As such, VolFs supports most features the Linux VFS
provides, including Linux permissions, symbolic links, FIFOs, sockets,
and device files.

VolFs is used to mount the VFS root directory, using
%LocalAppData%lxssrootfs as the backing storage. In addition, a
few additional VolFs mount points exist, most notably /root and
/home which are mounted using %LocalAppData%lxssroot and
%LocalAppData%lxsshome respectively. The reason for these separate
mounts is that when you uninstall WSL, the home directories are not
removed by default, so any personal files stored there will be
preserved.

CAUTION

Creating/modifying any files within the Linux subsystem using Windows apps & tools can cause Data corruption and data loss in Ubuntu subsystem! (Thanks to Rich Turner for suggesting these words of caution!) This is absolutely not supported. From the same blog post:

Interoperability with Windows

While VolFs files are stored in regular files on Windows in the
directories mentioned above, interoperability with Windows is not
supported. If a new file is added to one of these directories from
Windows, it lacks the EAs needed by VolFs, so VolFs doesn’t know what
to do with the file and simply ignores it. Many editors will also
strip the EAs when saving an existing file, again making the file
unusable in WSL.


Your Windows file system is located at /mnt/c in the Bash shell environment.

enter image description here

Source: Dustin Kirkland’s blog, howtogeek

I’ve installed wsl2 on my windows machine and I was not able to figure out where the files are actually stored.
Note, that I don’t mean that I wanna browse them inside the file explorer — I know it can be done by typing in the explorer \wsl$.
If I would have to guess I would say the files are stored in the same hard-drive that the os is stored.

So actually I have two related questions.

  1. Where the files are stored?
  2. If they are stored in the hard drive of my os, can I somehow relocate my wsl to another hard drive?

EDIT:
I was able to locate the installation path, in my machine the path is:
C:UsersEliranAppDataLocalPackagesCanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgscLocalState

Is there a way to mount this to another location?

Dweeberly's user avatar

Dweeberly

4,5782 gold badges21 silver badges39 bronze badges

asked Oct 3, 2020 at 14:56

Eliran Turgeman's user avatar

Eliran TurgemanEliran Turgeman

1,4442 gold badges11 silver badges28 bronze badges

6

All the files are stored in a ext4.vhd files in the installation directory, which you can’t mount directly onto windows as it is in ext4 (obv)

There’s two ways to change the location of the above mentioned vhd file the official, tedious way and an unofficial quick and dirty way

The official tedious way

  1. Export the distro to a location with wsl.exe --export <Distro> <FileName> from CMD/PowerShell
  2. Import the distro to a different location with wsl.exe --import <Distro> <InstallLocation> <FileName> [Options]

The problems with this is it’s quite time consuming and after you do this, pray that it exported and imported several gigabytes worth of thousands of files without any problems

The quick and dirty way

This involes an unofficial opensource WSL manager called lxrunoffline

To install it (takes like a min at max) read through the instructions by the dev here

If you installed it by manually downloading the binaries from the release page, make sure to install it to a directory in PATH, like C:Windows

Now the process is simple as lxrunoffline move -n <distroname> -d <destination-folder>

For example lxrunoffline move -n Ubuntu-20.04 -d G:wsl

Hope I helped

Edit: typo

answered Oct 6, 2020 at 5:31

zwxi's user avatar

1

I executed these commands in PowerShell to move my Ubuntu distro from C: to drive D:wsl-ubuntu :

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

and reboot the computer at the end.

The only problem I have is that the default user when I started the Ubuntu application is the root. I need to execute $ su sergio to enter in my personal user.

You can delete the ubuntu.tar at the end of process.

#edit 2021-04-13: As pointed out in the comments, I had forgotten the «—export» command.

answered Apr 12, 2021 at 20:51

Sergio Marcelo C Figueiredo's user avatar

6

This is an answer to your last question: use symbolic links

  • open command prompt as administrator
  • shut down wsl vm using wsl --shutdown
  • change folder to C:UsersEliranAppDataLocalPackagesCanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc
  • move the LocalState folder to another location like Z:wslUbuntu
  • create symbolic link with mklink /J LocalState Z:WSLUbuntuLocalState

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

[wsl2]
memory=4GB
processors=2
swap=1GB
swapFile=Z:\WSL\swap.vhdx
  • memory is the maximum amount your ram that WSL will use;
  • processors is the alocated cores to your WSL vm;
  • swap is the size of the swap file;
  • swapFile is the location of your swap and to my knowledge is used by all WSL vm’s; notice the double slashes in the path, they are mandatory for the path.

Start your WSL VM as you normally would.

answered Apr 30, 2021 at 18:18

Gregory Butler's user avatar

1

I’ve installed wsl2 on my windows machine and I was not able to figure out where the files are actually stored.
Note, that I don’t mean that I wanna browse them inside the file explorer — I know it can be done by typing in the explorer \wsl$.
If I would have to guess I would say the files are stored in the same hard-drive that the os is stored.

So actually I have two related questions.

  1. Where the files are stored?
  2. If they are stored in the hard drive of my os, can I somehow relocate my wsl to another hard drive?

EDIT:
I was able to locate the installation path, in my machine the path is:
C:UsersEliranAppDataLocalPackagesCanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgscLocalState

Is there a way to mount this to another location?

Dweeberly's user avatar

Dweeberly

4,5782 gold badges21 silver badges39 bronze badges

asked Oct 3, 2020 at 14:56

Eliran Turgeman's user avatar

Eliran TurgemanEliran Turgeman

1,4442 gold badges11 silver badges28 bronze badges

6

All the files are stored in a ext4.vhd files in the installation directory, which you can’t mount directly onto windows as it is in ext4 (obv)

There’s two ways to change the location of the above mentioned vhd file the official, tedious way and an unofficial quick and dirty way

The official tedious way

  1. Export the distro to a location with wsl.exe --export <Distro> <FileName> from CMD/PowerShell
  2. Import the distro to a different location with wsl.exe --import <Distro> <InstallLocation> <FileName> [Options]

The problems with this is it’s quite time consuming and after you do this, pray that it exported and imported several gigabytes worth of thousands of files without any problems

The quick and dirty way

This involes an unofficial opensource WSL manager called lxrunoffline

To install it (takes like a min at max) read through the instructions by the dev here

If you installed it by manually downloading the binaries from the release page, make sure to install it to a directory in PATH, like C:Windows

Now the process is simple as lxrunoffline move -n <distroname> -d <destination-folder>

For example lxrunoffline move -n Ubuntu-20.04 -d G:wsl

Hope I helped

Edit: typo

answered Oct 6, 2020 at 5:31

zwxi's user avatar

1

I executed these commands in PowerShell to move my Ubuntu distro from C: to drive D:wsl-ubuntu :

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

and reboot the computer at the end.

The only problem I have is that the default user when I started the Ubuntu application is the root. I need to execute $ su sergio to enter in my personal user.

You can delete the ubuntu.tar at the end of process.

#edit 2021-04-13: As pointed out in the comments, I had forgotten the «—export» command.

answered Apr 12, 2021 at 20:51

Sergio Marcelo C Figueiredo's user avatar

6

This is an answer to your last question: use symbolic links

  • open command prompt as administrator
  • shut down wsl vm using wsl --shutdown
  • change folder to C:UsersEliranAppDataLocalPackagesCanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc
  • move the LocalState folder to another location like Z:wslUbuntu
  • create symbolic link with mklink /J LocalState Z:WSLUbuntuLocalState

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

[wsl2]
memory=4GB
processors=2
swap=1GB
swapFile=Z:\WSL\swap.vhdx
  • memory is the maximum amount your ram that WSL will use;
  • processors is the alocated cores to your WSL vm;
  • swap is the size of the swap file;
  • swapFile is the location of your swap and to my knowledge is used by all WSL vm’s; notice the double slashes in the path, they are mandatory for the path.

Start your WSL VM as you normally would.

answered Apr 30, 2021 at 18:18

Gregory Butler's user avatar

1

https://alexsf.ru/my_img/img/2016/07/12/c6077.jpg

Устанавливая Bash для Windows 10, вы получаете практически полноценный дистрибутив Ubuntu с необходимым пользовательским окружением. При желании доступ к файлам Linux можно получить прямо из Проводника Windows.

Файлы Bash on Ubuntu on Windows доступны в папке C:Usersимя_пользователяAppDataLocallxss. По умолчанию эта папка скрыта, для доступа к ней придётся предварительно включить отображение скрытых файлов (Вид → Скрытые элементы).

Как вы наверное уже поняли, эта папка создаётся для каждого пользователя Windows в отдельности, Так что подсистема Linux у каждого из них своя, при поиске или модификации файлов это нужно учитывать.

 К слову, из Bash получить доступ к файлам в Windows даже проще: все диски компьютера автоматически монтируются в привычную для любого пользователя Linux директорию — /mnt. То есть для просмотра содержимого диска С: достаточно ввести команду ls /mnt/c, например.

https://alexsf.ru/my_img/img/2016/07/12/db597.jpg

В этом случае нужно помнить о том, что Bash запускается с правами текущего пользователя Windows. То есть если для управления некоторыми файлами или папками вам потребовались права администратора системы, то и Bash нужно перезапустить от имени администратора.

 [Ссылки могут видеть только зарегистрированные пользователи. ]

Linux environments you install from the Store (like Ubuntu and openSUSE) keep their files in a hidden folder. You can access this folder to back up and view files. You can also access your Windows files from the Bash shell.

Update: Starting with Windows 10’s May 2019 Update, there’s now an official, safe way to access your Linux files from Windows applications.

Don’t Modify Linux Files With Windows Tools

Microsoft strongly warns against adding or modifying Linux files with Windows software. This could cause metadata problems or file corruption, and may force you to uninstall and reinstall your Linux distribution to fix it. However, you can still view and back up your Linux files using Windows software, and that won’t cause any problems.

In other words, treat the Linux folder as if it were read-only from within Windows. Don’t use any Windows tool, including graphical apps or command line tools, to modify them. Don’t create new files within these folders using Windows tools, either.

If you do want to work with a file from both the Linux and Windows environments, you should create it in your Windows file system. For example, if you have a folder at C:project in Windows, you could also access it at /mnt/c/project in the Linux environment. Because it’s stored on the Windows file system and is accessed under /mnt/c, it’s safe to modify the file with either Windows or Linux tools.

Where Windows Stores the Linux Files

Your Linux file system is stored in a hidden folder for a reason, as Microsoft doesn’t want you tampering with it. But, if you need to view or back up some files, you’ll find them stored in a hidden folder. To access it, open File Explorer and plug the following address into the address bar:

%userprofile%AppDataLocalPackages

(This takes you to C:UsersNAMEAppDataLocalPackages . You can also show hidden folders in File Explorer and navigate here manually, if you prefer.

In this folder, double-click the folder for the Linux distribution whose files you want to view:

  • Ubuntu: CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc
  • openSUSE Leap 42: 46932SUSE.openSUSELeap42.2_022rs5jcyhyac
  • SUSE Linux Enterprise Server 12: 46932SUSE.SUSELinuxEnterpriseServer12SP2_022rs5jcyhyac

The names of these folders may change slightly in the future. Just look for a folder named after the Linux distribution.

In the Linux distribution’s folder, double-click the “LocalState” folder, and then double-click the “rootfs” folder to see its files.

In other words, the files are stored at:

C:UsersNAMEAppDataLocalPackagesDISTRO_FOLDERLocalStaterootfs

Note: In older versions of Windows 10, these files were stored under C:UsersNameAppDataLocallxss. This changed starting with the Fall Creators Update.

To view the files stored in your home folder, double-click the “home” folder, and then double-click your UNIX username.

Remember, don’t modify any of these files or add files to these folders from File Explorer!

Where Your Windows System Drive Appears in Linux

The Windows Subsystem for Linux makes your full Windows system drive available so you can work with the same files in both environments. However, the Bash environment doesn’t just dump you in your C: drive. Instead, it places you in your UNIX account’s home directory within the Linux environment’s file system.

Your Windows system drive and other connected drives are exposed in the /mnt/ directory there, where other drives are traditionally made available in the Linux directory structure. Specifically, you’ll find the C: drive at the following location in the Bash environment:

/mnt/c

To change to this directory with the cd command, just type:

cd /mnt/c

If you have a D: drive, you’ll find it located at /mnt/d, and so on.

For example, to access a file stored at C:UsersChrisDownloadsFile.txt, you’d use the path /mnt/c/Users/Chris/Downloads/File.txt in the Bash environment. And yes, it’s case-sensitive, so you need “Downloads” and not “downloads.”

RELATED: How to Mount Removable Drives and Network Locations in the Windows Subsystem for Linux

You can also mount external drives and network locations to access more files from within the Linux environment.

Note that, when accessing Windows system files, your Bash shell environment has the permissions it was launched with. If you launched it normally from the shortcut, it will have the same file access permissions your Windows user account does.

For example, if you want to access a system folder your user account doesn’t have permission to access, you’d need to right-click the Bash shell shortcut and select “Run as Administrator” to launch the Bash shell with Windows Administrator privileges.

This works just like the Command Prompt, which needs to be launched as Administrator if you need write access to Administrator-only files, or write access to system files. You can’t just use sudo in the Bash environment.

READ NEXT

  • › Everything New in Windows 10’s April 2018 Update, Available Now
  • › Everything You Can Do With Windows 10’s New Bash Shell
  • › How to Mount Removable Drives and Network Locations in the Windows Subsystem for Linux
  • › What’s the Difference Between Ubuntu, openSUSE, and Fedora on Windows 10?
  • › How to Create and Run Bash Shell Scripts on Windows 10
  • › How to Access Your Linux (WSL) Files in Windows 10
  • › How to Quickly Launch a Bash Shell From Windows 10’s File Explorer
  • › How to Add Text to a Cell With a Formula in Excel

Like this post? Please share to your friends:
  • Где находятся файлы print screen в windows 10
  • Где находятся сохранения для игр на windows 10
  • Где находятся файлы outlook в windows 10
  • Где находятся сохранения гта вайс сити windows 10
  • Где находятся файлы minecraft windows 10 edition