How to Mount Removable Drives and Network Locations in the Windows Subsystem for Linux

Starting with Windows 10’s Fall Creators Update, the Windows Subsystem for Linux now allows you to manually mount drives. It still automatically mounts all internal NTFS drives. However, now you can manually mount external drives and network folders using the Linux mount command.

How to Mount External Devices

The Windows Subsystem for Linux still automatically mounts fixed NTFS drives. So, if you have an internal C: drive and let's say an E: or a D: drive, you’ll see them at /mnt/c and /mnt/d in the Linux environment.
DrvFs now allows you to mount external drives like USB sticks, CDs, and DVDs. These devices must use a Windows file system like NTFS, ReFS, or FAT. However, you still can’t mount devices formatted with a Linux file system like ext3 or ext4.
Like with internal drives, these external drives will still remain accessible in Windows after you’ve mounted them in the Linux environment. Mounting them also makes them accessible from the shell environment.
Let’s say you have an external drive G: that represents either a USB drive or an optical disc drive. To mount it, you’ll have to run the following commands:
sudo mkdir /mnt/g

sudo mount -t drvfs G: /mnt/g
Of course you don’t really have to mount the drive at /mnt/g. You can mount it wherever you want. Just replace both instances of /mnt/g in the commands with your desired path.
To unmount the drive later so you can safely remove it, run the standard umount command:
sudo umount /mnt/g/
When working with an external device formatted with a FAT file system or any network file system, there are some limitations. The file system will not be case sensitive and you can’t create symbolic links or hard links on it.

How to Mount Network Locations

You can also mount network locations. Any network location you can reach from within Windows, you can mount from the Linux shell.
Network locations can be mounted in two simple ways. You can either map a network drive to a drive letter to mount it using the same options as above. This would give you an opportunity to easily sign into the network share and enter your credentials in File Explorer. For example, if your mapped network drive is H:, you could run the following commands to mount it:
sudo mkdir /mnt/h

sudo mount -t drvfs H: /mnt/h
Likewise, you can also specify a drive using its UNC (Universal Naming Convention) path. For example, if the path to the network share is \\server\folder , you’ll have to run the following command. 
sudo mkdir /mnt/folder
sudo mount -t '\\server\folder' /mnt/folder
The Windows Subsystem for Linux environment does not provide any way to specify the credentials you want to use. You can specify the credentials by navigating to the folder in File Explorer in Windows, entering them via the Credential Manager, or by directly using the net-use command.
You can run the net-use command from within the Linux environment, as the Windows Subsystem for Linux allows you to launch Windows software from the Linux command line. The command is as follows:
net.exe use
Let's just say, the following command would connect to \\server\folder with the username Ani and the password LetMeIn and map it to your F: drive. Here’s how you'll run the command:
net.exe use f: \\server\folder /user:Ani LetMeIn
After you connect once, Windows would remember this username and password and automatically use them, even when you use the mount command within the Linux environment.
To unmount a network location, you can again use the umount command:
sudo umount /mnt/folder
DrvFs doesn’t set the Linux permissions accurately when you mount a network location. Instead, all files on the network file system appear to have the full access permission (0777) and you can only see if you have access to a file by trying to open it. The file system will also not be case sensitive and you can’t create symbolic links on them.

Comments

Popular posts from this blog

Matrix Falling Code Effect

The Windows 10 Fall Creator's Update: What's new?

Why should you Disable 2.4 GHz Wi-Fi on your Network and How