天天看點

Linux挂載Windows檔案夾

# sudo mount -t 
-o user=username  //Windows使用者名
-o uid=myname  //Linux使用者名
-o gid=users 
-o defaults 
$mount_source   //share/src_dir
$mount_point  //dest_dir
-o nounix 
-o noserverino           

輸入密碼(Windows登入密碼)挂載

舉例

#!/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=zhangxuechao

#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