Меню

Accessing windows files from linux

Access Linux filesystems in Windows and WSL 2

September 10th, 2020

Starting with Windows Insiders preview build 20211, WSL 2 will be offering a new feature: wsl —mount . This new parameter allows a physical disk to be attached and mounted inside WSL 2, which enables you to access filesystems that aren’t natively supported by Windows (such as ext4).

So, if you’re dual booting with Windows & Linux using different disks, you can now access your Linux files from Windows!

Getting started

To mount a disk, open a PowerShell window with administrator privileges and run:

To list the available disks in Windows, run:

To unmount and detach the disk from WSL 2, run

The disks paths are available under the ‘DeviceID’ columns. Usually under the \\.\\\.\PHYSICALDRIVE* format. Below is an example of mounting a specific partition of a given hard disk into WSL and browsing its files.

Accessing these files with File Explorer

Once mounted, it’s also possible to access these disks through the Windows explorer by navigating to \wsl$ and then to the mount folder.

Limitations

By default, wsl —mount attempts to mount the disk as ext4. To specify a filesystem, or for more advanced scenarios, check out Mount a disk in WSL 2.

Also please note that this feature comes with the limitation that only physical disks can be attached to WSL 2. At this time, it’s not possible to attach a single partition. More details on the limitations here.

Give us your feedback!

If you run into any issues, or have feedback for our team please file an issue on our Github , and if you have general questions about WSL you can find all of our team members that are on Twitter on this twitter list.

How to access Windows system files from Ubuntu subsystem Linux terminal

To give native compatibility for Linux operating systems such as Ubuntu, Debian, OpenSuse, Kali, and more… Microsoft has added a layer or feature which is known as Windows Subsystem for Linux (WSL). The Windows 10 or 8 users including the latest Windows servers users can activate this feature from the control panel Turn and off windows feature option. The WSL on Windows 10/8 gives us an ability to run a different native command on Linux command-line tools or Bash environment just like a headless server running on some VirtualMachine.

However, we cannot install the Distros ISOs as we do on VirtualBox or any other virtualization software. Here, what we get is a pre-build headless Linux app available on Microsoft Windows 10 App store. Just go to the store and click on the Linux environment app and installed it on the system automatically.

Читайте также:  Индексация файлов windows ssd

Now after the installation of the Linux environments the thing which comes in mind is that after installing the Linux environment, for example, Ubuntu; where its files get saved by the Windows system. I mean if you want to just access the windows files from the Linux subsystem manually, how would you do that. Plus, is this possible to access the Windows files and drives such as C, D, E… directly from the Ubuntu Linux Subsystem? In this article, we will give answers to these questions…

Note: Until and unless you don’t know what are doing, please refrain yourself from modifying the files of your Linux subsystem manually. It could harm your Linux environment. This is the reason, why Microsoft has stored them in a hidden folder to make sure, the user couldn’t doctor them without knowing actually what he/she is doing?

How to Access Ubuntu files (windows subsystem) from windows 10

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

The address where Windows 10 WSL store the Linux environment file: %userprofile%\AppData\Local\Packages

Step 1: MyComputer

Go to MyComputer and open the C: Drive where all your Windows plus program files are stored.

Step 2: Show Hidden files and folders

By Default all crucial or core data files and folders in Windows are hidden and we need to unhide them manually. To do this click on the File option given in the menu of Windows Explorer.

From Folder options window click on the View tab and then under the Hidden files and folders select the Show hidden files, folders and drives.

Step 3: Access the ubuntu subsystem files from windows 10

Inside the Local Disk C: of the Windows, there is a folder –Users, click on that.

Step 4: Double click on your Windows username to open it (mine is Raj). After that, open the AppData folder which is basically a hidden folder.

Step 5: Inside the folder double click to open the LocalState->rootfs. All the files and folders of Ubuntu Linux environment will show there.

Now click on the Home folder where you will find the UNIX username.

How to access Windows files from Ubuntu terminal

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

By default, we can only use the Bash environment to access Windows files as we do in the Ubuntu/Linux headless servers.

Читайте также:  Плохо читаются шрифты windows

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

In the same way for D: drive type

In this way, we can also mount both internal and external drives attached to our Windows 10 or 8 systems including the network drives. Also, one thing to be noted that the Bash Shell of 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”.

Other Useful Resources

How do I access Windows files from Linux Mint (and vice-versa if possible)? I have dual boot

I have dual boot with Windows 10 and Linux Mint 19.1

3 Answers 3

In Linux: Open your file manager. The side-bar should display the Windows partitions. Click on them.

In Windows: I recommend EXT2FSD as mentioned here or here.

In the long run, I recommend creating a partition specifically for sharing files between operating systems. For this task, I prefer UDF as a file-system as it supports symlinks in both os’es, but exFAT and NTFS are fine, too.

As Hermann said in linux you can check it from your file manager, however you need to turn off the fast start up from windows otherwise it give you an error that cannot mount the partition.

In windows i use DiskInternals Linux Reader which is really friendly.

First off all check the available storage devices with the following command:

You can identify the file system with option -f:

Identify the storage device that corresponds with your Windows.

Create a directory to access the content of your Windows partition or disk:

Then you should mount the partition doing something similar to the the following:

Where sda3 is the partition and could be different in your case, and /media/windows is the mountpoint that we just created.

If you encounter a problem, can try using the explicit options:

First you need to validate your id with id command:

Then could do something like:

This solution is temporary. If you want to automount your file system when the system boots you must modify the file:

If you are from the GUI you can also use try choosing the partition in the file manager.

How to access windows file server from linux

We have a windows file server with an address like this:

How can I access it from Linux?

On a Ubuntu 14.04 I tried to access this through nautilus, but it crashed. Here is the crash report:

3 Answers 3

Assuming a recent Linux, do this:

Which will mount it at /mnt . You will need sufficient privilege (or be root).

Читайте также:  Как совместить диски при установке windows

If you need to add credentials, try:

You may need to install a package from your distro’s repository called cifs-utils but, hopefully, it would already be there as part of the standard install.

I’d suggest adding it to your /etc/fstab , so it’s online as soon as you boot. Mine has a (long) line reading:

  • The first field is the address and share name.
  • The second field is the mount point on your system (the folder must exist).
  • cifs is the type of the file system for any Windows share.
  • uid=1000,guid=1000,rw means that anyone on the system can access this share
  • credentials=/etc/cifspasswd means that that credentials found in /etc/cifspasswd will be used to authenticate access to the share on the Windows server.

This credential file should contain the username and password necessary for accessing the Windows share, i.e.

As /etc/fstab is (usually) readable by other users of the system, you can create the file as root and chmod go-=rwx to remove access for other users, to protect your password.

Caveat If you boot your system and the server isn’t available, Linux will wait a bit during the boot sequence before giving up.

How do I access the WSL Linux file system from Windows?

I found that static files served from a Rails application running in /home/pupeno/projectx take more or less half as much time than the ones served from /mnt/c/Users/pupeno/projectx . It’s almost acceptable. I tried webrick and puma (as well as passenger and unicorn, which don’t work yet).

So, if I’m going to host my source code in /home/pupeno , how do I access from Windows applications such as RubyMine?

For the record, this is the application being served from the Windows file system:

and this is the Linux file system:

6 Answers 6

PM for Windows Command-Line here:

However, as of Windows 10 build 1903 (March 2019), we (finally!) exposed your distros’ filesystems to Windows!

Look forward to hearing how you get on with this feature. If you find any problems, please file issues on the WSL GitHub repo here: https://github.com/microsoft/wsl.

WSL mounts Windows partitions under /mnt . For example, you can modify files in c:\work on the mounted Windows filesystem by referencing them as /mnt/c/work .

Windows apps (cmd, file manager, etc), can access files in WSL in read-only mode by prepending with %LocalAppData%\lxss . Copying a file from the Windows filesystem to the WSL directories renders it unreadable, with a cryptic general I/O error . Files created in %LocalAppData%\lxss from Windows are not visible to WSL. Files created from WSL can be modified in Windows, and the modified file can subsequently be accessed by WSL.

Adblock
detector