Install
$ sudo apt-get install cifs-utils
$ sudo apt-get install smbclient
Usage
# 一次性访问
$ smbclient -L 192.168.18.67 -U sw
# 挂载访问
$ sudo mkdir myBlogV2
$ sudo mount -t cifs -o username=sw_NAS_smb_user //192.168.18.67/SWPoolSSD/myBlogV2 myBlogV2
# unmount
$ sudo umount /mnt/temp
# 查看所有mount
$ mount -v
WSL 中访问 SMB
Old WSL Version
Mounting DrvFs
In order to mount a Windows drive using DrvFs, you can use the regular Linux mount command. For example, to mount a removable drive D: as /mnt/d
directory, run the following commands:
$ sudo mkdir /mnt/d$ sudo mount -t drvfs D: /mnt/d
Now, you will be able to access the files of your D: drive under /mnt/d
. When you wish to unmount the drive, for example so you can safely remove it, run the following command:
$ sudo umount /mnt/d
Mounting network locations
When you wish to mount a network location, you can of course create a mapped network drive in Windows and mount that as indicated above. However, it’s also possible to mount them directly using a UNC path:
$ sudo mount -t drvfs '\\server\share' /mnt/share
Note the single quotes around the UNC path; these are necessary to prevent the need to escape the backslashes. If you don’t surround the UNC path with single quotes, you need to escape the backslashes by doubling them (e.g. \\\\server\\share
).
WSL does not have any way to specify which credentials to use to co
将disk挂载到本地
$ sudo mkdir myBlogV2
$ sudo mount -t cifs -o username=sw //192.168.18.67/SWPoolSSD/myBlogV2 myBlogV2
New WSL Version
# 挂载访问
$ sudo mkdir myBlogV2
$ sudo mount -t cifs -o username=sw_NAS_smb_user //192.168.18.67/SWPoolSSD/myBlogV2 myBlogV2
Reference
WSL (Ubuntu) Access SMB
- https://docs.microsoft.com/en-us/archive/blogs/wsl/file-system-improvements-to-the-windows-subsystem-for-linux
- https://superuser.com/questions/1128634/how-to-access-mounted-network-drive-on-windows-linux-subsystemv
- https://www.tenforums.com/windows-10-news/164233-you-can-now-access-linux-filesystems-windows-10-wsl-2-a.html
- https://stackoverflow.com/questions/45244306/mounting-a-windows-share-in-windows-subsystem-for-linux/46968030
- https://docs.microsoft.com/en-us/windows/wsl/wsl2-mount-disk
Ubuntu Access SMB
- https://askubuntu.com/questions/1050460/how-to-mount-smb-share-on-ubuntu-18-04/1050499#1050499
- https://askubuntu.com/questions/915549/16-04-cifs-host-is-down-but-they-are-not
- https://docs.oracle.com/cd/E19120-01/open.solaris/820-2429/unmountsharetask/index.html