Linux挂载Windows文件夹

# sudo mount -t cifs \
-o user=username \ //Windows用户名
-o uid=myname,password=pass \ //Linux用户名,密码
-o gid=users \
-o defaults \
$mount_source \  //share/src_dir
$mount_point \ //dest_dir
-o nounix \
-o noserverino

举例

#!/bin/bash
#before mount,you should set the 4 item below

#1.your chian domain account,eg *wx*****
mount_user=china/ThomasZhang

#2.you account for linux
myname=zxc

#3.the dir you shared on your windows machine,the ip is windows ip
mount_source=//share/hg_10.0

#4.the path on linux
mount_point=/home/$myname/hg_10.0

if [ ! -d $mount_point ] ; then
echo "create directory $mount_point"
mkdir -p $mount_point
fi

sudo mount -t cifs \
-o user=$mount_user \
-o uid=$myname \
-o gid=users \
-o defaults \
$mount_source \
$mount_point \
-o nounix \
-o noserverino 

if [ $? = 0 ] ; then
echo "success mount to $mount_point :-)"
exit 0
else
echo "mount $mount_source fail."
exit 1
fi

报错

mount: /mnt: bad option; for several filesystems (e.g. nfs, cifs) you might need a /sbin/mount.<type> helper program.

解决办法:

apt-get install cifs-utils

版权声明:本文为zhangxuechao_原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。