使用mount命令进行目录挂载
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用mount命令进行目录挂载相关的知识,希望对你有一定的参考价值。
参考技术A 在进行mount目录之前,先检查服务器是否已经启动rpcbind服务和nfs服务,mount命令是基于这两个服务实现目录挂载的。如果应用服务器需要mount其他的文件服务器共享目录,首先用root的用户登录文件服务器,
打开/etc/exports文件,添加
/data/app/tkmFile 132.12.30.222(rw,all_squash,anonuid=501,anongid=100)
其中anonuid=501是文件服务器有权限访问这个目录的用户ID,anongid=100是组ID
保存完后,执行exportfs -rv,
如果还是不生效可重启nfs服务
/etc/init.d/nfs restart
查看共享目录命令
showmount -e ip
然后用root的用户登录应用服务器,执行以下命令:
mount -t nfs -o rw 132.96.63.5:/data/app/tkmFile /data/app/tkmFile
#umount /mnt --mnt 文件夹
mount -t nfs -o rw 221.28.3.7:/data/szkmc /data/szkmc -v
(如果无法挂载成功检查防火墙问题,nfs服务,ip网段是否做了限制,即使ping得通)
mount命令
磁盘进行挂载一定是一个目录,这个目录就是进入该磁盘分区的一个入口。挂载命令mount,首先man mount查看技术文档。
mount - mount a filesystem 挂载文件系统
The standard form of the mount command, is mount -t type -o options device dir(标准语法)
-t type表示:指定要挂载的文件系统类型,ext2/ext3/ext4/vfat/iso9660...
-o options表示:额外的参数,如ro/rw,async/sync,auto/noauto...
device表示:是一个文件的名称或一个特殊的块设备,比如/dev/sda1,也可能是一个特殊的NFS设备名称可能是knuth.cwi.nl:/dir,这样就需要使用它的LABEL或UUID进行自动0挂载。
dir表示:挂载的目录
mount 的选项
[[email protected] ~]# mount -V 查看版本信息
mount from util-linux-ng 2.17.2 (with libblkid and selinux support)
[[email protected] ~]# mount -h 查看帮助信息
Usage: mount -V : print version
mount -h : print this help
mount : list mounted filesystems
mount -l : idem, including volume labels
So far the informational part. Next the mounting.
The command is `mount [-t fstype] something somewhere'.
Details found in /etc/fstab may be omitted.
mount -a [-t|-O] ... : mount all stuff from /etc/fstab
mount device : mount device at the known place
mount directory : mount known device here
mount -t type dev dir : ordinary mount command
Note that one does not really mount a device, one mounts
a filesystem (of the given type) found on the device.
One can also mount an already visible directory tree elsewhere:
mount --bind olddir newdir
or move a subtree:
mount --move olddir newdir
One can change the type of mount containing the directory dir:
mount --make-shared dir
mount --make-slave dir
mount --make-private dir
mount --make-unbindable dir
One can change the type of all the mounts in a mount subtree
containing the directory dir:
mount --make-rshared dir
mount --make-rslave dir
mount --make-rprivate dir
mount --make-runbindable dir
A device can be given by name, say /dev/hda1 or /dev/cdrom,
or by label, using -L label or by uuid, using -U uuid .
Other options: [-nfFrsvw] [-o options] [-p passwdfd].
For many more details, say man 8 mount .
[[email protected] ~]# mount -v 冗长格式,查看所有挂载的详细信息
/dev/sda5 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)
/dev/sda2 on /usr type ext4 (rw)
/dev/sdc4 on /home type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
L LABEL=指定label进行挂载
U UUID 指定UUID进行挂载
常用命令:
[[email protected] ~]# mount -a 依据/etc/fstab文件信息进行挂载所有
以上是关于使用mount命令进行目录挂载的主要内容,如果未能解决你的问题,请参考以下文章