挂载和自动挂载的使用(实例论证) 一、挂载: 挂载需要有挂载源和挂载点。 1、常用挂载命令: mount -a :重新挂载/etc/fstab 配置文件中的文件系统。 mount /dev/hdc /mnt:将设备/dev/hdc挂载到/mnt目录。 mount -o remount,rw /data :重新挂载/data的文件系统为可读可写。 -o:表示选项; remount:重新挂载选项; rw:挂载目标成可读可写选项;ro:应该知道了吧。 卸载umount:将挂载源和挂载点分离,分离后只有重新挂载我们才可以对目标挂载源进行操作。 umount [挂载源|挂载点] 上例:mount /dev/hdc /mnt 卸载:umount /dev/hdc umount /mnt (这两个命令都可以) 关于时挂载点在重启系统之后仍然后效的方法: /etc/fstab 是Linux系统启动时要挂载的列表配置文件。我们只要将挂在信按照/etc/fstab文件的格式写到里面就可以实现重启后挂载仍然有效了。 /etc/fstab文件格式介绍: -------------------------------------------- [root@rhce ~]# vim /etc/fstab /dev/VolGroup00/LogVol00 LABEL=/boot tmpfs devpts sysfs proc /dev/VolGroup00/LogVol01 192.168.1.10:/nfs ------------------------------------------- 每一个文件系统用一行来描述:
-------------------------------------------------
[root@station ~]# vim /etc/auto.master
# # $Id: auto.master,v 1.4 2005/01/04 14:36:54 raven Exp $ # /misc /etc/auto.misc
/mnt /etc/auto.cdrom
//新增加行,auto.cdrom是针对于这个实例的一个配置文件,需要手动建立,这里配置文件的名字可以随便起。
--------------------------------------------------
--------------------------------------------------
[root@station ~]# cp /etc/auto.misc /etc/auto.cdrom
--------------------------------------------------[root@station ~]# vim /etc/auto.cdrom cdrom -fstype=iso9660 :/dev/hdc //新增加 自动挂载到的目录 挂载的系统类型 设备 //目录是虚拟的不能建立,如果创建将会出错。 重新启动autofs服务,并测试:
--------------------------------------------------
[root@station ~]# service autofs restart
--------------------------------------------------停止 automount: [确定] 启动 automount: [确定] [root@station ~]# ls /mnt/cdrom -------------------------------------------------- [root@station ~]# vim /etc/auto.master # # $Id: auto.master,v 1.4 2005/01/04 14:36:54 raven Exp $ # /misc /etc/auto.misc /- -------------------------------------------------- -------------------------------------------------- [root@station ~]# cp /etc/auto.misc /etc/auto.cdrom [root@station ~]# vim /etc/auto.cdrom /cdrom 自动挂载到的目录 挂载的系统类型 设备 //这里目录也是虚拟的不能建立,如果创建将会出错,这里的/cdrom是绝对路径。 --------------------------------------------------
--------------------------------------------------
[root@station ~]# service autofs restart
--------------------------------------------------停止 automount: [确定] 启动 automount: [确定] [root@station ~]# ls /cdrom 三、基于NIS及NFS的自动挂载的实现:
-------------------------------------------------
[root@station ~]# vim /etc/auto.master# # $Id: auto.master,v 1.4 2005/01/04 14:36:54 raven Exp $ # /misc /etc/auto.misc /home /etc/auto.nfs ------------------------------------------------- ------------------------------------------------- [root@station ~]# cp /etc/auto.misc /etc/auto.cdrom [root@station ~]# vim /etc/auto.cdrom [root@station ~]# vim /etc/auto.cdrom * 自动挂载到的目录 挂载的系统类型 -------------------------------------------------
-------------------------------------------------
[root@station ~]# service autofs restart
停止 automount: [确定] 启动 automount: [确定] [root@station ~]#su - ------------------------------------------------- |
|