Every so often I find that I want to access a Micro SD card from within Linux on my Windows WSL2 setup. I put the card in my laptop and am pleased when Windows announces the new D: drive is available. And then the confusion begins: how do I access this drive from a WSL2 Ubuntu session?
The C: drive is automatically available to me in /mnt/c; not so with D: and /mnt/d.
A Google search inevitably takes me this page which talks about using wsl --mount. While promising, this never works for me.
Often, by now, I've decided I didn't really need to access the SD card *that* badly and give up.
But, it turns out there's a trivial solution! The following mount command is all I need:
sudo mount -t drvfs 'D:' /mnt/d
Once that command is issued, the SD card files are available under /mnt/d, and are accessible like any other files on Linux. This works for any drive letter, not just 'D'.
Notably, this isn't SD card specific. I just connected an Adafruit ESP32-S2 TFT Feather micro-controller to my laptop and Windows recognized it as a drive.
I issued the same mount command to make this visible to Linux:
$ ls /mnt/d ls: cannot access '/mnt/d': No such device $ sudo mount -t drvfs 'D:' /mnt/d $ ls /mnt/d 'System Volume Information' boot_out.txt code.py lib settings.toml
And success! Now, if I can just remember to check the blog for this solution before I give up...
No comments:
Post a Comment