linux如何挂载windows下的共享文件

说明:

windows下有一共享文件夹APP,windows本地ip是192.168.9.155

现在需要在linux服务器上挂载这个APP文件夹,linux服务器ip是192.168.9.200

操作记录如下:

1)windows上的准备工作

首先将windows上D盘下的APP文件夹设置为共享。右击APP文件夹的“共享”属性.

选择“特定用户”共享,添加共享用户。如下

 这样,APP文件夹就设置为共享文件夹了,上面的O3zyrm2d4gnp5j2是windows的机器名。查看APP下里面的文件

查看共享文件夹和停止共享:

我的电脑:右键->管理->共享文件夹

2)linux服务器上的操作

创建挂载目录/mnt/APP

[root@dev ~]# mkdir /mnt/APP

需要安装:cifs-utils

使用mount.cifs或者mount -t cifs进行挂载操作:(下面的用户名和密码是登陆windows的)

[root@dev ~]# mount.cifs //192.168.9.155/APP /mnt/APP/ -o user=administrator,pass=dsff#$TTT

[root@dev ~]# mount -t cifs -o user=administrator,pass=dsff#$TTT //192.168.9.155/APP /mnt/APP/

查看下,发现已经挂在上了

[root@dev ~]# ls /mnt/APP/

2.sql 3.sql 8633上线sql.zip

[root@dev mnt]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/sda2 450G 97G 331G 23% /

tmpfs 3.9G 228K 3.9G 1% /dev/shm

/dev/sda1 194M 34M 150M 19% /boot

//192.168.9.155/APP 123G 12G 111G 10% /mnt/APP

[root@dev mnt]# mount

/dev/sda2 on / type ext4 (rw)

proc on /proc type proc (rw)

sysfs on /sys type sysfs (rw)

devpts on /dev/pts type devpts (rw,gid=5,mode=620)

tmpfs on /dev/shm type tmpfs (rw)

/dev/sda1 on /boot type ext4 (rw)

none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)

gvfs-fuse-daemon on /root/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev)

//192.168.9.155/APP on /mnt/APP type cifs (rw)

卸载

[root@dev mnt]# umount /mnt/APP

[root@dev mnt]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/sda2 450G 97G 331G 23% /

tmpfs 3.9G 228K 3.9G 1% /dev/shm

/dev/sda1 194M 34M 150M 19% /boot

注意:

出错:mount error(112): Host is down

是版本的问题,解决方法如下:

mount -t cifs -o user=administrator,pass=dsff#$TTT,vers=2.0 //192.168.9.155/APP /mnt/APP/

如果提示target is busy 说明你是在当前目录下卸载当前目录,肯定不行,得退出当前路径再去unmout

如果提示dervice is busy 可选择强制卸载 umount -f /home/lxd

安装好Win10操作系统之后,使用ssh mount -t cifs //IP/共享目录 /mount挂载点的命令时候,提示

mount error(112): Host is down

Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

解决方案如下:

在控制面板->程序和功能->启动或关闭windows更能中勾选SMB的相关项,之后重启电脑即可

主机Win10, 虚拟机Ubuntu15.04.   在Ubuntu 下编译共享目录中的C代码出现 “Value too large for defined data type”。

结合一些资料,找到了解决办法(mount的时候加上“nounix,noserverino”参数):

具体操作为,编辑文件 “/etc/init.d/vmware-tools”, 查找字符串 “vmhgfs_mnt”

将下面函数:

# Mount all hgfs filesystems

vmware_mount_vmhgfs() {

  if [ "`is_vmhgfs_mounted`" = "no" ]; then

    if [ "`vmware_vmhgfs_use_fuse`" = "yes" ]; then

      mkdir -p $vmhgfs_mnt

      vmware_exec_selinux "$vmdb_answer_BINDIR/vmhgfs-fuse \

         -o subtype=vmhgfs-fuse,allow_other $vmhgfs_mnt"

    else

      vmware_exec_selinux "mount -t vmhgfs .host:/ $vmhgfs_mnt"

    fi

  fi

}

修改为:

# Mount all hgfs filesystems

vmware_mount_vmhgfs() {

  if [ "`is_vmhgfs_mounted`" = "no" ]; then

    if [ "`vmware_vmhgfs_use_fuse`" = "yes" ]; then

      mkdir -p $vmhgfs_mnt

      vmware_exec_selinux "$vmdb_answer_BINDIR/vmhgfs-fuse \

         -o subtype=vmhgfs-fuse,allow_other $vmhgfs_mnt"

    else

      vmware_exec_selinux "mount -t vmhgfs .host:/ $vmhgfs_mnt -o nounix,noserverino"

    fi

  fi

}

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐