Linux开机挂载windows共享文件夹

https://blog.csdn.net/zhaogang1993/article/details/79573271  (可行)

1.     背景

前博 介绍了如何配置Linux的Samba服务以便Windows系统能映射Linux的共享文件夹,因此我们提出疑问:Linux如何访问其他系统的共享文件夹呢?答案也就是本文介绍的:挂载。

2.     原理

对于Linux系统,根文件系统“/”之外的其他文件要想能够被访问,都必须通过“关联”至根文件系统上的某个目录来实现,此关联操作即为“挂载”,此目录即为“挂载点”,解除此关联关系的过程称之为“卸载”。

注意点:挂载点必须是一个目录。

3.     操作

说明:笔者有两台电脑,linux(192.168.1.6)  ------ windows(192.168.1.7),此测试例就是Linux挂载Windows的共享目录:e盘

不管是开机自动挂载还是手动挂载,我们都首先在/mnt目录下创建一个文件夹,也就是挂载点。

zglinux mnt # mkdir windows

zglinux mnt # ls

windows

1)    手动挂载

手动挂载就是采用Linux的mount命令,终端输入如下命令:

mount.cifs //192.168.1.7/e /mnt/windows/ -o user=administrator,pass=******(windows的登录密码)

说明:

1.      第一个字段mount.cifs表示采用CIFS(Common Internet File System:通用网络文件系统)挂载将要挂载的目录,linux支持多种文件系统,如ext4,  xfs, btrfs,f2fs, vfat, ntfs,CIFS是其中一种,具体可以看man 8 mount手册;

2.      第二个字段表示将要挂载的文件系统路径或块设备;

3.      第三个字段表示Linux的挂载点,也就是我们刚才创建的/mnt/windows目录;

4.      最后一个字段-o 以及后面的所有内容表示挂载选项,各个选项以“,”分隔。比如此挂载需要知道Windows的用户名和密码;

5.      操作可能需要root权限,可以在命令前面加sudo;

2)    自动挂载

自动挂载即Linux开机启动时自动挂载所需的分区,所有需要挂载的分区通过文件/etc/fstab描述。因而,我们只需要修改此文件即可完成自动挂载。通过cat /etc/fstab 和man fstab可以查看典型的挂载信息条目:

LABEL=t-home2   /home     ext4   defaults,auto_da_alloc      0  2

其中:

第一个字段:This field describes the block special device or remote filesystemto be mounted. (描述将要挂载的特定块设备或远程文件系统);

第二个字段:This field describes the mount point for the filesystem. (描述挂载点);

第三个字段:This field describes the type of the filesystem. (描述挂载文件系统);

第四个字段:This field describes the mount options associated with thefilesystem.(描述文件系统相关联的挂载选项);

第五个字段:This field is used by dump(8) to determine which filesystems need tobe dumped.(针对ext2/3/4文件系统,是否要备份,防止因异常断电导致的数据丢失。具体可以查看man 8 dump,如果没有此命令,请先用apt-get install dump安装。此字段默认填0,不需要dump);

第六个字段:This field is used by fsck(8) to determine the order in whichfilesystem checks are  done at  boot time.(意思是:指定系统启动时通过fsck检查文件系统的顺序,根文件系统检查顺序为1,其他为2。默认为0表示不执行检查,由于我们要挂载网络文件,此处填0,不进行检查);

有了上述分析,我们通过 vi 打开/etc/fstab,在文件末尾添加如下行即可实现Linux系统开机自动挂载

//192.168.1.7/e /mnt/windows/ cifs username=administrator,password=****(windows密码) 0 0

4.  测试

编辑好/etc/fstab文件后,我们重启Linux系统,查看是否成功挂载。结果表明:挂载成功。以后就可以把Windows的共享目录当作Linux的一个盘来访问了。

5. 参考

http://blog.csdn.net/hello_word___/article/details/77300279

$man 8 mount

$man mount.cifs

原文地址:https://www.cnblogs.com/yaok430/p/9282156.html

时间: 2024-08-01 16:20:44

Linux开机挂载windows共享文件夹的相关文章

在Linux上挂载Windows共享文件夹,如何开机自动挂载(mount)

使用mount命令在Ubuntu上挂接Windows的共享文件夹 sudo mount //192.168.0.1/linux /mnt/win -o username=user,password=pass dir_mode=777 file_mode=777 说明://192.168.0.1/linux      windows共享文件夹路径/mnt/win                 ubuntu中的挂载点 ----------------------------------------

linux cifs挂载windows共享文件夹

#mount -t cifs -o username=Administrator,password=123456 192.168.1.12/shared  /mnt/work (注:红色部分为windows的用户名和密码) #mount -t cifs -o username=Administrator,password= 192.168.1.12/shared /mnt/work (默认用户名为Administrator,密码为空) mount -t cifs 192.168.50.34:te

linux挂载windows共享文件夹的方法

对于linux的初级使用阶段,都会Windows中使用linux虚拟机VMWare或者其它的.在Windows与linux之间互传文件是一个问题.本方法介绍的是在linux下挂载Windows共享文件夹的方法来实现的 本方法是以win7,VMware9.0.1 ,centos6.4为基础实验的. 1.首先安装VMware Tools(如果已经安装过了就不用安装了) (1)挂载VMware Tools 先点击虚拟机中菜单栏的VM,下拉菜单中的settings,然后弹出下面这张图,按顺序选择. 在第

linux 挂载windows 共享文件夹

mount -t cifs -o username=administrator,password=123 //$IP/ /mnt linux 挂载windows 共享文件夹,布布扣,bubuko.com

samba 挂载windows共享文件夹

先转载一片文章     centOS下yum安装配置samba 地址 http://blog.csdn.net/linglongwunv/article/details/5212875 遇到问题1 # smbpasswd -a username 创建用户不成功 Failed to add entry for user usernamessss.     解决  创建系统管理员,就是登录服务器时候的那个. 有了系统管理员aaa  才能创建samba管理员aaa 从Windows 客户端连接到Sam

烂泥:CentOS6.5挂载windows共享文件夹

本文由秀依林枫提供友情赞助,首发于烂泥行天下. 由于工作需要,需要把本机的文件夹共享出去,然后让CentOS服务器临时使用下. 服务器使用的是CentOS系统,而本机使用的win7系统.考虑到是临时使用,所以就不打算搭建FTP和Samba服务器,直接通过CentOS挂载windows共享文件夹的方式来达到此目的. 既然是使用windows共享文件夹的方式,那么我们必须先在本机创建一个共享目录.如下: 在此需要注意下,我们给administrator管理员的共享权限是可读写权限.等下我们会在Cen

详述在Linux上挂载window共享文件夹

需求 Linux系统由于和Windows系统文件格式不一样,导致很多文件不能直接通用.如果要将linux的数据拷贝到win版本需要挂载硬盘或者通过下载比较麻烦,通过挂载windows的共享文件夹来传输文件那就比较方便了. 解决方案 在window上文件设置共享权限 在Linux上在 使用mount 命令挂载 Windows 共享文件夹 试验环境 redhat linux 6.56.5操作系统 服务器IP 192.168.100.8 window 7操作系统 window 7 IP 192.168

mount挂载windows共享文件夹

今天在centos 7下挂载windows共享文件夹遇到报错 mount error(115): Operation now in progress Refer to the mount.cifs(8) manual page (e.g. man mount.cifs) 折腾了半天才去看了一眼日志 messages内 Oct 28 03:17:59 localhost kernel: CIFS VFS: Error connecting to socket. Aborting operation

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

环境:windows8.1 with update (IP:192.168.80.135) centos6.5 最小化安装的系统 步骤: 1.在windows的E盘创建了一个文件夹myhome,在myhome下随便新建一个文件,然后把该文件夹设置共享.windows下如何共享文件夹步骤请自行百度. 2.在linux下安装cifs软件 yum install cifs-utils 3.挂载命令 mount.cifs -o username="administrator",password