Linux 2 unit7 挂载网络共享

##挂载网络共享###

###文件的共享(samba)###

[[email protected] mnt]# yum install samba-client.x86_64 -y   ##

Loaded plugins: langpacks

Resolving Dependencies

--> Running transaction check

---> Package samba-client.x86_64 0:4.2.3-10.el7 will be installed

--> Processing Dependency: samba-common = 4.2.3-10.el7 for package: samba-client-4.2.3-10.el7.x86_64

--> Processing Dependency: samba-common = 4.2.3-10.el7 for package: samba-client-4.2.3-10.el7.x86_64

Installed:

samba-client.x86_64 0:4.2.3-10.el7

Dependency Installed:

samba-client-libs.x86_64 0:4.2.3-10.el7

samba-common-libs.x86_64 0:4.2.3-10.el7

samba-common-tools.x86_64 0:4.2.3-10.el7

Complete!

[[email protected] mnt]# smbclient -L //172.25.254.250    ##共享此ip下的文件

Enter root‘s password:

Domain=[MYGROUP] OS=[Unix] Server=[Samba 4.1.1]

Sharename       Type      Comment

---------       ----      -------

westos1         Disk      test share

westos2         Disk      test share

westos3         Disk      test share

westos4         Disk      test share

westos5         Disk      test share

westos6         Disk      test share

westos7         Disk      test share

westos8         Disk      test share

westos9         Disk      test share

westos10        Disk      test share

IPC$            IPC       IPC Service (Samba Server Version 4.1.1)

Domain=[MYGROUP] OS=[Unix] Server=[Samba 4.1.1]

Server               Comment

---------            -------

Workgroup            Master

---------            -------

[[email protected] mnt]# smbclient //172.25.254.250/westos1  ##进入到westos1

Enter root‘s password:

Domain=[MYGROUP] OS=[Unix] Server=[Samba 4.1.1]

smb: \> ls

.                                   D        0  Sun Apr 30 01:32:45 2017

..                                  D        0  Wed Dec  2 20:43:01 2015

100221120 blocks of size 1024. 21820400 blocks available

smb: \> !ls    ##查看本机有什么

creat_user.sh  passwd  userfile

file.sh        rule    westos

smb: \> put file.sh

putting file file.sh as \file.sh (32.7 kb/s) (average 32.7 kb/s)

smb: \> exit

[[email protected] ~]# mount //172.25.254.250/westos1 /mnt -o username=guest

[[email protected] ~]# touch xiao

[[email protected] ~]# cd mnt/

[[email protected] mnt]# touch xiao

[[email protected] mnt]# rm -f  xiao

[[email protected] mnt]# df

Filesystem               1K-blocks     Used Available Use% Mounted on

/dev/vda1                 10473900  4230560   6243340  41% /

devtmpfs                    922268        0    922268   0% /dev

tmpfs                       942660       84    942576   1% /dev/shm

tmpfs                       942660    17028    925632   2% /run

tmpfs                       942660        0    942660   0% /sys/fs/cgroup

/dev/sr0                   3654720  3654720         0 100% /run/media/root/RHEL-7.0 Server.x86_64

//172.25.254.250/westos1 100221120 78405328  21815792  79% /mnt

[[email protected] mnt]# touch file1

[[email protected] mnt]# touch file2

[[email protected] mnt]# exit

###开机自动挂载###

[[email protected] ~]# vim /etc/fstab

[[email protected] ~]# df

Filesystem               1K-blocks     Used Available Use% Mounted on

/dev/vda1                 10473900  4230600   6243300  41% /

devtmpfs                    922268        0    922268   0% /dev

tmpfs                       942660       84    942576   1% /dev/shm

tmpfs                       942660    17028    925632   2% /run

tmpfs                       942660        0    942660   0% /sys/fs/cgroup

/dev/sr0                   3654720  3654720         0 100% /run/media/root/RHEL-7.0 Server.x86_64

//172.25.254.250/westos1 100221120 78407756  21813364  79% /mnt

[[email protected] ~]# mount -a

[[email protected] ~]# df

Filesystem               1K-blocks     Used Available Use% Mounted on

/dev/vda1                 10473900  4230600   6243300  41% /

devtmpfs                    922268        0    922268   0% /dev

tmpfs                       942660       84    942576   1% /dev/shm

tmpfs                       942660    17028    925632   2% /run

tmpfs                       942660        0    942660   0% /sys/fs/cgroup

/dev/sr0                   3654720  3654720         0 100% /run/media/root/RHEL-7.0 Server.x86_64

//172.25.254.250/westos1 100221120 78407756  21813364  79% /mnt

做下次实验室时保证实验环境干净##

[[email protected] ~]# vim /etc/fstab

[[email protected] ~]# mount -a

[[email protected] ~]# umount /mnt/

[[email protected] ~]# df

Filesystem     1K-blocks    Used Available Use% Mounted on

/dev/vda1       10473900 4230584   6243316  41% /

devtmpfs          922268       0    922268   0% /dev

tmpfs             942660      84    942576   1% /dev/shm

tmpfs             942660   17028    925632   2% /run

tmpfs             942660       0    942660   0% /sys/fs/cgroup

/dev/sr0         3654720 3654720         0 100% /run/media/root/RHEL-7.0 Server.x86_64

###nfs-utils共享软件

[[email protected] ~]# yum install nfs-utils.x86_64 -y    ##安装nfs共享软件

Loaded plugins: langpacks

Resolving Dependencies

--> Running transaction check

---> Package nfs-utils.x86_64 1:1.3.0-0.el7 will be updated

---> Package nfs-utils.x86_64 1:1.3.0-0.21.el7 will be an update

--> Processing Dependency: gssproxy >= 0.3.0-0 for package: 1:nfs-utils-1.3.0-0.21.el7.x86_64

Dependencies Resolved

===================================================

Package       Arch   Version       Repository

Size

===================================================

Updating:

nfs-utils     x86_64 1:1.3.0-0.21.el7

rhel_dvd 370 k

Installing for dependencies:

gssproxy      x86_64 0.4.1-7.el7   rhel_dvd  84 k

libbasicobjects

x86_64 0.1.1-25.el7  rhel_dvd  25 k

libcollection x86_64 0.6.2-25.el7  rhel_dvd  40 k

libini_config x86_64 1.2.0-25.el7  rhel_dvd  59 k

libpath_utils x86_64 0.2.1-25.el7  rhel_dvd  27 k

libref_array  x86_64 0.1.5-25.el7  rhel_dvd  26 k

libverto-tevent

x86_64 0.2.5-4.el7   rhel_dvd 9.0 k

Updating for dependencies:

krb5-libs     x86_64 1.13.2-10.el7 rhel_dvd 837 k

Transaction Summary

===================================================

Install             ( 7 Dependent packages)

Upgrade  1 Package  (+1 Dependent package)

Total size: 1.4 M

Downloading packages:

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

Updated:

nfs-utils.x86_64 1:1.3.0-0.21.el7

Dependency Updated:

krb5-libs.x86_64 0:1.13.2-10.el7

Complete!

[[email protected] ~]# showmount -e 172.25.254.250

Export list for 172.25.254.250:

/nfsshare/nfs5 *

/nfsshare/nfs4 *

/nfsshare/nfs3 *

/nfsshare/nfs2 *

/nfsshare/nfs1 *

/content       172.25.0.0/255.255.0.0

[[email protected] ~]# mount 172.25.254.250:/nfsshare/nfs1 /mnt/

[[email protected] ~]# df

Filesystem                    1K-blocks     Used Available Use% Mounted on

/dev/vda1                      10473900  4231560   6242340  41% /

devtmpfs                         922268        0    922268   0% /dev

tmpfs                            942660       84    942576   1% /dev/shm

tmpfs                            942660    17032    925628   2% /run

tmpfs                            942660        0    942660   0% /sys/fs/cgroup

/dev/sr0                        3654720  3654720         0 100% /run/media/root/RHEL-7.0 Server.x86_64

172.25.254.250:/nfsshare/nfs1 100221952 78403584  21818368  79% /mnt

[[email protected] ~]# cd /mnt/

[[email protected] mnt]# ls

[[email protected] mnt]# touch xiaoxiaoxiao

[[email protected] mnt]# ls

xiaoxiaoxiao

[roo[email protected] mnt]# rm -fr xiaoxiaoxiao

[[email protected] mnt]# cd

[[email protected] ~]# umount /mnt

[[email protected] ~]# vim /etc/fstab

[[email protected] ~]# mount -a

[[email protected] ~]# df

Filesystem                    1K-blocks     Used Available Use% Mounted on

/dev/vda1                      10473900  4231600   6242300  41% /

devtmpfs                         922268        0    922268   0% /dev

tmpfs                            942660       84    942576   1% /dev/shm

tmpfs                            942660    17032    925628   2% /run

tmpfs                            942660        0    942660   0% /sys/fs/cgroup

/dev/sr0                        3654720  3654720         0 100% /run/media/root/RHEL-7.0 Server.x86_64

172.25.254.250:/nfsshare/nfs1 100221952 78411776  21810176  79% /mnt

[[email protected] ~]# cat /etc/fstab

#

# /etc/fstab

# Created by anaconda on Wed May  7 01:22:57 2014

#

# Accessible filesystems, by reference, are maintained under ‘/dev/disk‘

# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info

#

UUID=9bf6b9f7-92ad-441b-848e-0257cbb883d1 /                       xfs     defaults        1 1

172.25.254.250:/nfsshare/nfs1 /mnt nfs defaults 0 0    ##自动挂载脚本

[[email protected] ~]# yum install autofs.x86_64 -y

Loaded plugins: langpacks

Resolving Dependencies

--> Running transaction check

---> Package autofs.x86_64 1:5.0.7-54.el7 will be installed

--> Processing Dependency: libhesiod.so.0()(64bit) for package: 1:autofs-5.0.7-54.el7.x86_64

--> Running transaction check

---> Package hesiod.x86_64 0:3.2.1-3.el7 will be installed

--> Finished Dependency Resolution

Dependencies Resolved

===================================================

Package Arch    Version           Repository

Size

===================================================

Installing:

autofs  x86_64  1:5.0.7-54.el7    rhel_dvd  793 k

Installing for dependencies:

hesiod  x86_64  3.2.1-3.el7       rhel_dvd   30 k

Transaction Summary

===================================================

Install  1 Package (+1 Dependent package)

Total download size: 823 k

Installed size: 5.1 M

Downloading packages:

(1/2): hesiod-3.2.1-3.el7.x86 |  30 kB   00:00

(2/2): autofs-5.0.7-54.el7.x8 | 793 kB   00:00

---------------------------------------------------

Total                 3.0 MB/s | 823 kB  00:00

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

Installing : hesiod-3.2.1-3.el7.x86_64       1/2

Installing : 1:autofs-5.0.7-54.el7.x86_64    2/2

Verifying  : 1:autofs-5.0.7-54.el7.x86_64    1/2

Verifying  : hesiod-3.2.1-3.el7.x86_64       2/2

Installed:

autofs.x86_64 1:5.0.7-54.el7

Dependency Installed:

hesiod.x86_64 0:3.2.1-3.el7

Complete!

[[email protected] ~]# systemctl start autofs

[[email protected] ~]# cd /net

[[email protected] net]# ls

[[email protected] net]# cd 172.25.254.250

[[email protected] 172.25.254.250]# ls

content  nfsshare

[[email protected] 172.25.254.250]# pwd

/net/172.25.254.250

[[email protected] 172.25.254.250]# cd nfsshare/

[[email protected] nfsshare]# ls

nfs1  nfs2  nfs3  nfs4  nfs5

[[email protected] nfsshare]# cd nfs3

[[email protected] nfs3]# ls

[[email protected] nfs3]# touch xiao

[[email protected] nfs3]# rm -fr xiao

[[email protected] nfs3]# ls

[[email protected] nfs3]# df

Filesystem                    1K-blocks     Used Available Use% Mounted on

/dev/vda1                      10473900  4237048   6236852  41% /

devtmpfs                         922268        0    922268   0% /dev

tmpfs                            942660       84    942576   1% /dev/shm

tmpfs                            942660    17044    925616   2% /run

tmpfs                            942660        0    942660   0% /sys/fs/cgroup

/dev/sr0                        3654720  3654720         0 100% /run/media/root/RHEL-7.0 Server.x86_64

172.25.254.250:/nfsshare/nfs1 100221952 78411776  21810176  79% /mnt

172.25.254.250:/nfsshare/nfs3 100221952 78411776  21810176  79% /net/172.25.254.250/nfsshare/nfs3

[[email protected] nfs3]# vim /etc/sysconfig/autofs   ##在配置文件中更改自动挂载不使用卸载时间

[[email protected] nfs3]# umount /mnt

[[email protected] nfs3]# df

Filesystem                    1K-blocks     Used Available Use% Mounted on

/dev/vda1                      10473900  4237068   6236832  41% /

devtmpfs                         922268        0    922268   0% /dev

tmpfs                            942660       84    942576   1% /dev/shm

tmpfs                            942660    17044    925616   2% /run

tmpfs                            942660        0    942660   0% /sys/fs/cgroup

/dev/sr0                        3654720  3654720         0 100% /run/media/root/RHEL-7.0 Server.x86_64

[[email protected] ~]# mkdir /westos

[[email protected] ~]# vim /etc/auto.master

[[email protected] ~]# vim /etc/auto.westos

[[email protected] ~]# head -10 /etc/auto.master

#

# Sample auto.master file

# This is a ‘master‘ automounter map and it has the following format:

# mount-point [map-type[,format]:]map [options]

# For details of the format look at auto.master(5).

#

/misc/etc/auto.misc

/westos /etc/auto.westos

#

# NOTE: mounts done from a hosts map will be mounted with the

[[email protected] ~]# cat /etc/auto.westos

* 172.25.254.250:/nfsshare/&    ##将任意挂载到/nfsshare/下面

[[email protected] ~]# systemctl restart autofs.service

[[email protected] ~]# cd /westos

[[email protected] westos]# ls

[[email protected] westos]# cd nfs1

[[email protected] nfs1]# pwd

/westos/nfs1

[[email protected] nfs1]# df

Filesystem                    1K-blocks     Used Available Use% Mounted on

/dev/vda1                      10473900  4237068   6236832  41% /

devtmpfs                         922268        0    922268   0% /dev

tmpfs                            942660       84    942576   1% /dev/shm

tmpfs                            942660    17048    925612   2% /run

tmpfs                            942660        0    942660   0% /sys/fs/cgroup

/dev/sr0                        3654720  3654720         0 100% /run/media/root/RHEL-7.0 Server.x86_64

172.25.254.250:/nfsshare/nfs1 100221952 78409728  21812224  79% /westos/nfs1

[[email protected] nfs1]# cd

[[email protected] ~]# cd /westos/nfs2

[[email protected] nfs2]# df

Filesystem                    1K-blocks     Used Available Use% Mounted on

/dev/vda1                      10473900  4237068   6236832  41% /

devtmpfs                         922268        0    922268   0% /dev

tmpfs                            942660       84    942576   1% /dev/shm

tmpfs                            942660    17048    925612   2% /run

tmpfs                            942660        0    942660   0% /sys/fs/cgroup

/dev/sr0                        3654720  3654720         0 100% /run/media/root/RHEL-7.0 Server.x86_64

172.25.254.250:/nfsshare/nfs2 100221952 78413824  21808128  79% /westos/nfs2

时间: 2024-08-25 23:04:44

Linux 2 unit7 挂载网络共享的相关文章

linux系统下挂载windows共享目录

在工作中有时我们需要在linux上挂载windows共享目录.首先我们需要学会在linux上查看windows共享了那些目录.查看操作需要安装samba-client. [[email protected]5201351 ~]# yum install samba-client -y //安装samba客户端 安装好samba-client之后,接下来就是查看windows主机上的共享资源,查看的命令如下: [[email protected]5201351 ~]# smbclient -L 1

linux通过cifs挂载windows共享目录

1.在linux上执行以下命令: [[email protected] ~]# mount -t cifs -o username=shenhb,password=111111,iocharset=gb2312 //192.168.4.211/book /opt/xdata mount: //192.168.2.193/xshare 写保护,将以只读方式挂载 mount: 无法以只读方式挂载 //192.168.2.193/xshare [[email protected] ~]# 查看wind

Linux系统中如何挂载windows共享(cifs),NFS共享,以及挂载ISO文件

# 在Linux系统中挂载Windows中共享的文件夹: mount -t cifs //192.168.1.102/studyshare /mnt -o username=chocolee,password=YOURPASSWD # 在Linux系统中挂载NFS共享的文件夹: mount -t nfs SERVICE_IP:/home/song/nfs /mnt/nfs # 在Linux系统中挂载光盘镜像(ISO文件): mount -t iso9660 -o loop XXX.iso /mn

如何在 Linux 上永久挂载一个 Windows 共享

导读 如果你已经厌倦了每次重启 Linux 就得重新挂载 Windows 共享,读读这个让共享永久挂载的简单方法. 在 Linux 上和一个 Windows 网络进行交互从来就不是件轻松的事情.想想多少企业正在采用 Linux,需要在这两个平台上彼此协作.幸运的是,有了一些工具的帮助,你可以轻松地将 Windows 网络驱动器映射到一台 Linux 机器上,甚至可以确保在重启 Linux 机器之后共享还在. 在我们开始之前 要实现这个,你需要用到命令行.过程十分简单,但你需要编辑 /etc/fs

window主机访问Linux主机通过samba服务共享的目录 和Linux主机挂载window主机共享目录到本地

一.window主机访问Linux主机通过samba服务共享的目录 1.测试环境 物理主机: win8 虚拟主机: rhel 5.8 网络模式: 桥接 安装方式采用本地配置的yum源安装samba 关闭了selinux 2.配置好yum源 mount -r /dev/cdrom /media/cdrom   //挂载光盘镜像 3.首先安装samba3x samba3x-client samba3x-common samba3x-swat yum -y install samba3x samba3

Linux下挂载Windows共享目录

$ sudo mount.cifs //windows-ip/shared  /media/ -o user=username password=password 该命令挂载Windows下的shared共享目录到本地/media目录下. Windows的用户名是username, 密码是password (作相应的修改) 这里的CIFS(Common Internet File System)协议是SMB协议的后续版本. Linux下挂载Windows共享目录,布布扣,bubuko.com

Linux挂载windos共享提示error

1.当在Linux中挂载windos共享时,提示: 2.说明少了一个支持nfts格式的插件,这个只需要安装即可: yum -y install cifs-utils #用yum安装不会出现下面的问题 2.若从光盘手动安装cifs-utils-4.8.1-10.el6.x86_64.rpm单个软件包的过程提示: rpm -ivh cifs-utils-4.8.1-10.el6.x86_64.rpm warning: cifs-utils-4.8.1-10.el6.x86_64.rpm: Heade

linux上挂载windows共享目录

linux上挂载windows共享目录 1.共享windows文件夹 挂载之前得创建一个有密码的用户(当前用户也可以),并将你要挂载的文件夹进行共享,并赋予读写权限 如图, 2. 挂载windows共享目录 命令: mount -t cifs -o username=zhz,password=123456 //10.0.10.1/trunk  /data/developer/test 3. 使用 mount -l 查看是否挂载成功 4. 卸载已经挂载的共享目录 umount /data/deve

How To mount/Browse Windows Shares【在linux{centos}上挂载、浏览window共享】

How to mount remote Windows shares Contents Required packages Basic method Better Method Even-better method Yet Another Even-better method OK, we live in the wonderful world of Linux. BUT, for many of us, having to deal with Windows is a fact of life