0

I am currently using wsl2 on windows and I use MS OneDrive locally in parallel for my studies. Actually I sync each file with my OneDrive account. AS my Onedrive folder's name is like :

Onedrive - SchoolName

And that for my courses I need to use WSL2 and I want to acceed to my windows file without the spaces in the path. The solution I found is to use mount bind command :

sudo mount --bind /mnt/c/Users/MyName/OneDrive\ -\ SchoolName/Project ~/Project/

This is actually working but I want to edit my fstab to not type the command each time I start my WSL. And I do not know how to do because each tuto I found wasn't working.

Thank you for your tips !

1

3 Answers 3

0

fstab(5) documents that \040 can be used to substitute a space… but only in the second field; you have it in the first field.

A quick workaround is to make a symlink to the source directory somewhere, then bind-mount that:

sudo ln -s /mnt/c/Users/MyName/OneDrive\ -\ SchoolName/Project /.onedrive-link

Then you can bind-mount /.onedrive-link to ~/Project/.


At this point, the obvious question is, do you still need the bind mount? You can just do:

sudo rmdir ~/Project
ln -s /mnt/c/Users/MyName/OneDrive\ -\ SchoolName/Project ~/Project

You’ll end up with a symlink that’s even owned by your regular user and doesn’t need superuser privilegues to be modified.

-1

try this:

what I did on my fedora 35 was open disks and edit their mount options. unfortunately, wsl doesn't provide GUI so I'll do my best to give you an example based on my own fstab

/mnt/c/Users/MyName/OneDrive / ntfs-3g defaults,bind 0 0

the bind option should do the trick

3
  • Thank you for your answer, actually I have a gui using a server X. Is there a gui solution ?
    – Clément
    Jan 13 at 16:09
  • install disks, go to your partition, right-click and choose edit mount options, disable User Session Defaults, check mount at system startup, check show in user interface, add defaults,bind to options which should be the one above Mount Point and edit Mount Point as well to get the results you need
    – mohsentux
    Jan 13 at 23:31
  • Actually I have this error when trying to acceed gnome-disks (gnome-disks:60): GNOME-Disks-ERROR **: 10:05:36.329: Error getting udisks client: Could not connect: No such file or directory Trace/breakpoint trap Do you have a solution ?
    – Clément
    Jan 18 at 9:06
-1

if you can't use disks, you have use terminal file editor nano

$ sudo nano /etc/fstab
#at the end of document
/source /destination none defaults,bind 0 0

I myself don't use defaults option I recommend these:

/mnt/c/Users/MyName/OneDrive /home/(your username)/Project nosuid,nodev,nofail,x-gvfs-show,uid=1000,gid=1000,dmask=027,fmask=137,bind 0 0

if it worked make sure to tell us.

EDIT 1:

I know it's been a long time but I think The Situation does not need an interference anymore. right now I'm an windows 11 insider (Build 25115) and with Hyper-V active and Hypervisor Disabled. I can see my Ubuntu WSL on explorer and if I have permissions I can write to it. and the drives are automatically mounted. this is my fstab (almost empty):

LABEL=cloudimg-rootfs   /    ext4   defaults    0 1

and this is my /mnt (using ls command from Ubuntu WSL):

mohsentux@LovelyBloom:/mnt$ ls
c  d  e  f  wsl  wslg

so the situation has officially resolved itself so to speak.

2
  • Actually it is not working, I have search for solutions but I think it is a particular behavior of Ubuntu in WSL2
    – Clément
    Jan 30 at 18:22
  • Can you explain the line you recommended ? Thank you. Apr 13 at 21:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.