##挂载网络共享###

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

[root@localhost 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!

[root@localhost 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

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

[root@localhost 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

[root@localhost ~]# mount //172.25.254.250/westos1 /mnt -o username=guest

[root@localhost ~]# touch xiao

[root@localhost ~]# cd mnt/

[root@localhost mnt]# touch xiao

[root@localhost mnt]# rm -f  xiao

[root@localhost 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

[root@localhost mnt]# touch file1

[root@localhost mnt]# touch file2

[root@localhost mnt]# exit

 

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

[root@localhost ~]# vim /etc/fstab

Linux 2 unit7 挂载网络共享_网络共享

[root@localhost ~]# 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

[root@localhost ~]# mount -a

[root@localhost ~]# 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

 

 

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

[root@localhost ~]# vim /etc/fstab

[root@localhost ~]# mount -a

[root@localhost ~]# umount /mnt/

[root@localhost ~]# 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共享软件

[root@localhost ~]# 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!

[root@localhost ~]# 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

[root@localhost ~]# mount 172.25.254.250:/nfsshare/nfs1 /mnt/  

[root@localhost ~]# 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

[root@localhost ~]# cd /mnt/

[root@localhost mnt]# ls

[root@localhost mnt]# touch xiaoxiaoxiao

[root@localhost mnt]# ls

 xiaoxiaoxiao

[root@localhost mnt]# rm -fr xiaoxiaoxiao

[root@localhost mnt]# cd

[root@localhost ~]# umount /mnt

[root@localhost ~]# vim /etc/fstab

Linux 2 unit7 挂载网络共享_Linux_02

[root@localhost ~]# mount -a

[root@localhost ~]# 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

[root@localhost ~]# 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    ##自动挂载脚本

 

 

[root@localhost ~]# 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!

[root@localhost ~]# systemctl start autofs

[root@localhost ~]# cd /net

[root@localhost net]# ls

[root@localhost net]# cd 172.25.254.250

[root@localhost 172.25.254.250]# ls

content  nfsshare

[root@localhost 172.25.254.250]# pwd

/net/172.25.254.250

[root@localhost 172.25.254.250]# cd nfsshare/

[root@localhost nfsshare]# ls

nfs1  nfs2  nfs3  nfs4  nfs5

[root@localhost nfsshare]# cd nfs3

[root@localhost nfs3]# ls

[root@localhost nfs3]# touch xiao

[root@localhost nfs3]# rm -fr xiao

[root@localhost nfs3]# ls

[root@localhost 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

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

[root@localhost nfs3]# umount /mnt

[root@localhost 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

 

[root@localhost ~]# mkdir /westos

[root@localhost ~]# vim /etc/auto.master

[root@localhost ~]# vim /etc/auto.westos

[root@localhost ~]# 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

[root@localhost ~]# cat /etc/auto.westos

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

[root@localhost ~]# systemctl restart autofs.service

[root@localhost ~]# cd /westos

[root@localhost westos]# ls

[root@localhost westos]# cd nfs1

[root@localhost nfs1]# pwd

/westos/nfs1

[root@localhost 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

[root@localhost nfs1]# cd

[root@localhost ~]# cd /westos/nfs2

[root@localhost 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