Linux挂载Windows文件夹

本文介绍如何通过sudomount-tcifs命令在Linux环境下挂载Windows共享文件夹。具体步骤包括设置挂载所需的参数如Windows域账号、Linux用户名等,并提供了一个bash脚本示例来实现自动化挂载。当遇到挂载失败的问题时,文章还给出了安装cifs-utils作为解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

# 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
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值