Accessing the WSL file-system from within Windows is not supported. As soon as you do anything more than just reading those files from within the Windows environment, things will go wrong.
But the following part of the question is not impossible and easily supported, so I'll answer this:
I would like to be able to write files in Bash that are accessible from Windows too
You can't (should not) access the Linux filesystem from within Windows, but you can quite easily access the Windows file-system from within WSL. You will find all your fixed lettered Windows NTFS drives mounted under /mnt/*
, so your "C-Drive"
is mounted on /mnt/c
, and so on.
For example your Windows home user path will be something like /mnt/c/Users/<usernamehere>
Mounting removable drives
You can mount some filesystems yourself: MSDN Blog
sudo mkdir /mnt/sdcard
sudo mount -t drvfs U: /mnt/sdcard
Note that the actual filesystem is in this case was exFAT, so you just use drvfs
as long as Windows can read the actual file system.
More info
Did you Google first? – phuclv – 2016-08-06T08:52:33.500
@LưuVĩnhPhúc yes, and all I could find were articles about where the C drive is located inside the Bash script, but nothing the other way around – Patrick – 2016-08-06T20:09:54.693
really? I copied your question into Google and this appears on top
– phuclv – 2016-08-07T14:26:03.007Possible duplicate of How to access linux/Ubuntu files from Windows 10 WSL?
– Bob – 2019-08-28T04:59:22.843(I am suggesting to close as dupe in reverse-chronological order as the other question is both more general and has far better and more up-to-date answers.) – Bob – 2019-08-28T05:00:01.423