当前位置:   article > 正文

如何将局域网中的windows硬盘挂载到 linux系统中_windows 机械硬盘挂在linux下

windows 机械硬盘挂在linux下

目录

一 、准备两台机器

1.1 windows 7 系统

IP地址:192.168.2.93
在这里插入图片描述

1.2 linux Centos7.2 系统

IP地址:192.168.2.250

在这里插入图片描述

1.3 保证两台机器网络可以ping通

在这里插入图片描述
在这里插入图片描述

二 、共享windows上的F盘中的特定文件夹

共享账号:ad
共享密码:sharepasswd

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
共享成功之后,可以通过\\192.168.2.93的方式连接到共享文件夹。

三 、linux上执行挂载命令

3.1 创建文件夹作为挂载点(也可以用已经存在的)

注意:挂载点是必须先存在的。

[root@dscq-250 ~]# pwd
/root
[root@dscq-250 ~]# mkdir /root/test
[root@dscq-250 ~]# ll
总用量 4
-rw-------. 1 root root 1000 8月   4 10:50 anaconda-ks.cfg
drwxr-xr-x. 2 root root    6 9月   9 15:05 test
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
3.2 在挂载点文件夹中创建文件
[root@dscq-250 test]# pwd
/root/test
[root@dscq-250 test]# touch from_linux_before_mount.log
[root@dscq-250 test]# ll
总用量 0
-rw-r--r--. 1 root root 0 9月   9 15:08 from_linux_before_mount.log
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
3.3 在windows共享文件夹中创建文件

在这里插入图片描述

3.4 在linux上执行挂载命令
[root@dscq-250 test]# cd ../   #挂载时一定不要在挂载点当前目录,否则容易挂载失败
[root@dscq-250 ~]# mount //192.168.2.93/share /root/test -o username=ad,,password=sharepasswd
[root@dscq-250 ~]# df -h
文件系统                 容量  已用  可用 已用% 挂载点
/dev/mapper/centos-root   50G  6.7G   44G   14% /
devtmpfs                 3.8G     0  3.8G    0% /dev
tmpfs                    3.8G     0  3.8G    0% /dev/shm
tmpfs                    3.8G   89M  3.8G    3% /run
tmpfs                    3.8G     0  3.8G    0% /sys/fs/cgroup
/dev/mapper/centos-home  146G  680M  146G    1% /home
/dev/xvda1               497M  125M  373M   26% /boot
tmpfs                    730M     0  730M    0% /run/user/0
//192.168.2.93/share     430G   40G  390G   10% /root/test   ##看到这一行表示挂载成功##

[root@dscq-250 ~]# cd /root/test/
[root@dscq-250 test]# ll
总用量 0
drwxr-xr-x. 2 root root 0 9月   9 11:41 12233
-rwxr-xr-x. 1 root root 0 9月   9 11:42 from windows before mount.txt
-rwxr-xr-x. 1 root root 0 9月   9 11:42 欢迎来到共享文件夹.txt
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20

注意:

  • 挂载成功之后,查看windows共享文件夹发现并没有新增挂载前在linux挂载点创建的文件(夹);
  • 挂载成功之后,查看linux挂载点发现已经新增挂载前在windows共享文件夹创建的文件(夹);
  • 挂载成功之后,查看linux挂载点并未看到挂载前在linux挂载点文件夹创建的文件(夹);
3.5 在linux挂载点文件夹内创建新文件(夹)
[root@dscq-250 test]# pwd
/root/test
[root@dscq-250 test]# ll
总用量 0
drwxr-xr-x. 2 root root 0 9月   9 11:41 12233
-rwxr-xr-x. 1 root root 0 9月   9 11:42 from windows before mount.txt
-rwxr-xr-x. 1 root root 0 9月   9 11:42 欢迎来到共享文件夹.txt
[root@dscq-250 test]# touch from_linux_after_mount.log
[root@dscq-250 test]# ll
总用量 0
drwxr-xr-x. 2 root root 0 9月   9 11:41 12233
-rwxr-xr-x. 1 root root 0 9月   9 15:40 from_linux_after_mount.log   ##### 
-rwxr-xr-x. 1 root root 0 9月   9 11:42 from windows before mount.txt
-rwxr-xr-x. 1 root root 0 9月   9 11:42 欢迎来到共享文件夹.txt
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

注意:挂载成功之后,若在linux挂载点创建新文件(夹)是可以在windows共享文件夹中查看到的;
在这里插入图片描述

3.6 在windows共享文件夹内创建新文件(夹)

在这里插入图片描述

[root@dscq-250 test]# ll
总用量 0
drwxr-xr-x. 2 root root 0 9月   9 11:41 12233
-rwxr-xr-x. 1 root root 0 9月   9 15:40 from_linux_after_mount.log
drwxr-xr-x. 2 root root 0 9月   9 15:42 from windows after mount   #######
-rwxr-xr-x. 1 root root 0 9月   9 11:42 from windows before mount.txt
-rwxr-xr-x. 1 root root 0 9月   9 11:42 欢迎来到共享文件夹.txt
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

注意:挂载成功之后,若在windows共享文件夹创建新文件(夹)还是可以在linux挂载点文件夹中查看到的;

3.7 在linux挂载点文件夹内删除文件(夹)
[root@dscq-250 test]# ll
总用量 0
drwxr-xr-x. 2 root root 0 9月   9 11:41 12233
-rwxr-xr-x. 1 root root 0 9月   9 15:40 from_linux_after_mount.log
drwxr-xr-x. 2 root root 0 9月   9 15:42 from windows after mount
-rwxr-xr-x. 1 root root 0 9月   9 11:42 from windows before mount.txt
-rwxr-xr-x. 1 root root 0 9月   9 11:42 欢迎来到共享文件夹.txt
您在 /var/spool/mail/root 中有新邮件
[root@dscq-250 test]# rm -rf 12233
[root@dscq-250 test]# ll
总用量 0
-rwxr-xr-x. 1 root root 0 9月   9 15:40 from_linux_after_mount.log
drwxr-xr-x. 2 root root 0 9月   9 15:42 from windows after mount
-rwxr-xr-x. 1 root root 0 9月   9 11:42 from windows before mount.txt
-rwxr-xr-x. 1 root root 0 9月   9 11:42 欢迎来到共享文件夹.txt
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

在这里插入图片描述

注意:挂载成功之后,若在linux挂载点删除新文件(夹)是可以在windows共享文件夹中看到变化的;

3.8 在windows共享文件夹内删除文件(夹)

操作删除文件夹from windows after mount
在这里插入图片描述

[root@dscq-250 test]# pwd
/root/test
[root@dscq-250 test]# ll
总用量 0
-rwxr-xr-x. 1 root root 0 9月   9 15:40 from_linux_after_mount.log
-rwxr-xr-x. 1 root root 0 9月   9 11:42 from windows before mount.txt
-rwxr-xr-x. 1 root root 0 9月   9 11:42 欢迎来到共享文件夹.txt
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

注意:挂载成功之后,若在windows共享文件夹删除新文件(夹)是可以在linux挂载点文件夹中看到变化的;

四、取消挂载

[root@dscq-250 test]# umount /root/test
umount: /root/test:目标忙。
        (有些情况下通过 lsof(8) 或 fuser(1) 可以
         找到有关使用该设备的进程的有用信息)
[root@dscq-250 test]# cd ../
[root@dscq-250 ~]# umount /root/test
[root@dscq-250 ~]# df -h
文件系统                 容量  已用  可用 已用% 挂载点
/dev/mapper/centos-root   50G  6.7G   44G   14% /
devtmpfs                 3.8G     0  3.8G    0% /dev
tmpfs                    3.8G     0  3.8G    0% /dev/shm
tmpfs                    3.8G   89M  3.8G    3% /run
tmpfs                    3.8G     0  3.8G    0% /sys/fs/cgroup
/dev/mapper/centos-home  146G  680M  146G    1% /home
/dev/xvda1               497M  125M  373M   26% /boot
tmpfs                    730M     0  730M    0% /run/user/0

[root@dscq-250 ~]# cd /root/test/
[root@dscq-250 test]# ll
总用量 0
-rw-r--r--. 1 root root 0 9月   9 15:34 from_linux_before_mount.log
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21

注意:取消挂载之后,原来在/root/test文件夹中的文件(夹)又可以看到了;

本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/93457
推荐阅读
相关标签
  

闽ICP备14008679号