microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.42k stars 822 forks source link

WSL2 --mount is caching/buffering with no chance of flushing immediately #9299

Open Svetoslav92 opened 1 year ago

Svetoslav92 commented 1 year ago

Hi all, As the title suggests this seems to be important feature request. I want to mount ext2 partition which is inaccessible from Windows. Yes, you discovered the --mount option but it is lacking the ability to disable caching. If I edit text file from wsl shared path from windows it does not get reflected until some kind of buffer fills up. Because I edit only text files this buffer will fill up in a year time in order to flush it to the disk - just unusable. That's why I tried to mount the drive from within WSL with the mount statement (plus -o sync) but since the disk in windows is detected as unformatted it wants me to initialize it first before be able to assign a drive letter (which will format the disk unwantedly). A drive letter which is a must inside WSL mount. So I am stuck with the --mount option without a chance to remove the buffer/cache. Does anyone know if it is possible to use mount() which is as I can see the base function behind the linux mount and use it, by providing hard disk address etc but not drive letter? I played around with (linux) mount statement and a hacky driver that enforces a drive letter in windows but after trying to apply it I get ERROR: MountWithRetry:306: mount(drvfsa, /mnt/e, 9p, 0x00000010, cache=mmap,msize=262144,trans=virtio,aname=drvfs;path=e:;uid=0;gid=0;metadata;symlinkroot=/mnt/) failed: Invalid argument which makes me think that mount really can accept hard disk address (in this case broken from hacky driver - 0x00000010) one ?

Thanks

OneBlue commented 1 year ago

@Svetoslav92: You can specify mount options via --options. See: Specifying mount options

Sadly the 'sync' option isn't supported at the moment so another way you can do this is via:

sudo mount -o remount,sync <device>

After mounting the disk

Svetoslav92 commented 1 year ago

"isn't supported at the moment" - well that's why it is important feature request lol Anyway the remount seems smart workaround option. I will try it and report back. But chances are high :)

Svetoslav92 commented 1 year ago

I didn't had the chance to test it but I trust that it works this way as it seems logical. The bigger issue is now that my VirtualBox doesn't work as expected because of WSL2 by Hyper-V bug already listed. You can close this if you wish or retain it as feature request.