Where is the C drive in the WSL?

66

10

Whenever I try to login to bash using the Windows Subsystem for Linux, I try to cd into C:\Users\, but all I get is directory not found.

Where is the C drive for the Windows Linux subsystem? Is it isolated?

Jeeter

Posted 2016-08-02T04:24:13.007

Reputation: 1 393

Question was closed 2016-08-02T17:17:47.497

For user folder type in, cd /mnt/c/Users ...to access desktop type in, cd /mnt/c/Users/my-name/Desktop ...case sensitive – kar – 2016-08-04T01:35:14.433

Answers

77

Taken from this website:

The WSL has access to your PC’s file system through /mnt/<drive letter>/ directories (or mount points). For example, your C:\ and D:\ root directories in Windows would be available through /mnt/c/ and /mnt/d/ respectively in the WSL

Just cd into the /mnt folder and you'll be fine

Jeeter

Posted 2016-08-02T04:24:13.007

Reputation: 1 393

17

/mnt/c or /mnt/<drive letter>/

you’ll find your local drives mounted under the /mnt folder.
For example, your C: drive is mounted under /mnt/c [msdn]

The Linux filesystem is a unique tree (there are not C:\, D:\...).
The root of this tree is / (note / not \).

All the units, partitions, pen drives, removable disks, CD, DVD... will be available when mounted on a point of this tree. Then you will see them as normal directories.

The usual place where the additional partitions are mounted is the /mnt directory.
This works under the windows-linux-subsustem too.

Note: under Linux you go to use this slash (/) instead of the backslash (\) to separate the directories in a path and usually a Linux File System is case sensitive (mydir and Mydir are two different things).

Hastur

Posted 2016-08-02T04:24:13.007

Reputation: 15 043

how do you access DVD from WSL? I only see /mnt/c in there – santiago arizti – 2019-09-24T21:12:28.583

1But this is another question ;-) (@santiagoarizti). BTW once mounted it should be in /mnt/d or similar. (Under pure Linux it may be under /media/YourUsername/TheLabelNameOfCd or similar). If you need to mount it before create a directory e.g. sudo mkdir /mnt/MyDVD then mount it with something like sudo mount -t drvfs D: /mnt/MyDVD or similar commands... – Hastur – 2019-09-25T12:18:54.163

6

Since the days of Windows NT, there has been another way to access drives. Instead of using a letter, you can bind a drive to a folder in the filesystem. Microsoft calls these mounted folders. As far as the end user is concerned, they work just like normal folders do: they happen to reside on another drive, but under most circumstances you don't notice. This can be useful in a number of scenarios, but it turns out to be critical if you happen to have so many drives mounted that you run out of drive letters, but need to add even more: mounted folders are how you can do that.

In Linux (and Unix, which inspired it), all drives work this way. There is only one filesystem, which starts at the empty path / (and is typically bound to a drive), and then you mount your other drives (or, sometimes, other things) using directories inside /. These are called mount points in Unix terminology (which Linux inherited). For example, user home directories are often in /home/username, but it's common to make /home a mount point for another drive entirely. That way if the drive you boot from fails for some reason, your home directories aren't affected. The users just go to /home/username like they always do; unless they're responsible for maintaining the machine, they don't have to know or care what drive their home directories are on.

The WSL tries to imitate Linux, so it does this too. To bridge the gap, it mounts your Windows drives in the folder '/mnt/', using the drive letter as the directory name. Your C: drive, for example, can also be found at /mnt/c, while your D: drive is at /mnt/d.

The Spooniest

Posted 2016-08-02T04:24:13.007

Reputation: 422