• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: | 推荐给好友 上一篇 | 下一篇

[原]sa239学习笔记之三mount 和umount

发布: 2007-6-08 22:43 | 作者: seanhe | 来源: | 查看: 23次 | 进入软件测试论坛讨论

领测软件测试网
Moduel 4   Performing Mounts and Umounts
 
    Note – While system administrators typically use the /usr/sbin/mount
command, the system boot scripts use the /sbin/mount command.
 
     介绍/etc/vfstab文件:
 
        /etc/vfstab列出系统启动时自动mount的文件, 除/etc/mnttab和/var/run之外;
        /etc/vfstab文件分出七个区域:
            device to mount    被mount的设备和伪设备
            device to fsck     The raw or character device e.g. /dev/rdsk下的
                                对于伪设备如:/proc 或 fd 这项可写  -  
            mount point        mount 的路径
            FS type            文件系统类型
            fsck pass          指示在系统启动时是否fsck检测;0不检1表示fsck为系统正常启动运行
                                大于1时表示把此设备加入fsck运行列表,fsck可同时检测8个设备,
                                mountall命令忽略此项
            mount at boot       yes 要求启动时自动mount,no 则不
            
    Note – For / (root), /usr, and /var (if it is a separate file system) file
systems, the mount at boot field value is specified as no. The kernel
mounts these file systems as part of the boot sequence before the
mountall command is run. The mount command explicitly mounts the
file systems / (root) and /usr as specified in the
/etc/rcS.d/S30rootusr.sh script and the /var file system as specified
in the /etc/rcS.d/S70buildmnttab script.
 
            mount options        A comma-separated list of options passed to the
                                mount command. A dash (-) indicates the use of
                                default mount options.
 
 
    介绍/etc/mnttab文件:
        此文件是一个只读文件,当mount一项时,会在此文件中入一条,umount后也会在此文件中删除相应项;
 
        包括五项区域:
 
            mount point    挂接点    
            Device Name    设备名,块设备是文件系统的物理名称;
            Mount Options              文件系统上生效的挂载选项列表  
            dev=number                主从设备号
            Date and time mounted     mount的日期时间
 
 
    使用mount
        
        mount /dev/dsk/c#d#t#s# /mountpoint 
            不加参数时,使用以下默认属性:
 
            read/write     Indicates whether reads and writes are allowed on
                            the file system.
            setuid         Permits the execution of setuid programs in the
                            file system.
            intr/nointr     Allows and forbids keyboard interrupts to kill a
                            process that is waiting for an operation on a locked
                            file system.
            nologging       Indicates that logging is not enabled for the ufs file
                            system.
            largefiles      Allows for the creation of files larger than 2 Gbytes.
                            A file system mounted with this option can contain
                            files larger than 2 Gbytes.
            xattr           Supports extended attributes not found in
                            standard UNIX attributes.
            onerror=action     Specifies the action that the ufs file system should
                                take to recover from an internal inconsistency on a
                                file system. An action can be specified as:
                            panic—Causes a forced system shutdown. This is
                                    the default.
                            lock — Applies a file system lock to the file
                                    system.
                            umount — Forcibly unmounts the file system.
------------------------------------------------------------------------------
Note – Due to file system overhead, the largest file size that can be created
is approximately 866 Gbytes.
------------------------------------------------------------------------------
 
    使用mount命令的option
        Some options used to mount local file systems include: ro, nosetuid,
noatime, nolargefiles, and logging.
 
格式:    mount -o option,option,... device_name mount_point
    
        # mount -o ro /dev/dsk/c0t0d0s6 /usr        -------设成只读
        下面是使用多个参数,设成只读以及不允许执行setuid进程,但并不限制生成setuid
        # mount -o ro,nosuid /dev/dsk/c0t0d0s7 /export/home
        为提高磁盘访问性能,文件系统访问频繁,最后访问时间并不计较的可以
        # mount -o noatime /dev/dsk/c0t0d0s7 /export/home
        防止成生超过2G的文件,
        # mount -o nolargefiles /dev/dsk/c0t0d0s7 /export/home
        如果文件系统已经存在超过2G的大文件,mount会挫败,如果想成功mount,则必须删除相关大文件,
        并且删除后必须用fsck来更新超级块的信息,如果一次运行fsck还不能成功mount则必须用fsck
        来清除超级块的信息;
 
        使UFS文件系统写日志;
        # mount -o logging /dev/dsk/c0t0d0s7 /export/home
        
        存放日志文件的大小,大约是每1G分配1M的大小,最大不超过64M字节;
        当UFS日志达其最大时,它就开始将事务记录到文件系统中。文件系统被卸载时,整个UFS日志
        都被清空,所有事务都被写入文件系统。 
        UFS日志有两个好处。一,它文件系统的不一致性,也就不再需要长时间运行fsck扫描。
        二,可以跳过fsck扫描,这就减少了系统在被以非正常的关闭方法关闭时,重启的时间,
 
    使用mountall命令:
        mountall -l 只mount本地的所有文件系统;
        mountall命令读取/etc/vfstab文件内容,当device to fsck 项大于0时,fsck会检测文件系统是否完好,以致于安全挂接.当系统文件坏掉,fsck会试图修复,mountall会mount其它挂接点,和device to fsck 项等于0的挂接点.
 
    mount一个新的文件系统:
        八步:
        1.把硬盘放入服务器,
        2.重启或devfsadm让系统识别硬盘;
        3.format把硬盘分区;
        4.newfs在磁盘slice上生成新的文件系统;
        5.在/目录下用mkdir 生成一个新的挂接点;
        6.mount文件系统到挂接点;
        7.用mount命令查看是否mount成功;
        8.修改/etc/vfstab文件,让系统下次重启时自动加载;
 
    mount不同类型的文件系统:
        
        如果mount时没有以mount -F fstype指明的话,mount会以ufs来作为默认的类型,mount根据设备名, 块名,或挂接点来判断文件类型;
 
        mount 不能从/etc/vfstab的fs entry来判断,会以/etc/default/fs file 或
/etc/dfs/fstypes来决定文件的挂接类型,如果是本地文件系统则是/etc/default/fs 文件中一行
LOCAL=ufs  来确定挂接类型;
        如果是远程文件系统,则从/etc/dfs/fstypes第一行来确定
nfs NFS Utilities
autofs AUTOFS Utilities
cachefs CACHEFS Utilities
        
     Using the fstyp Command来查看文件类型:
 
        # fstyp /dev/rdsk/c0t0d0s7
        ufs
    指定一下hsfs文件系统:
        当volume manage停止时,用hsfs来指定一个cdrom
        # mount -F hsfs -o ro /dev/dsk/c0t6d0s0 /cdrom
    指定一个pcfs文件系统:
        当卷管理停止时,挂接一个驻留在diskette(软盘)的文件系统
        
        # mkdir /pcfs
        # mount -F pcfs /dev/diskette /pcfs
 
 
    执行umount命令:
        提示:在umount文件系统前,都是先从/etc/mnttab文件种删除相应行;
 
        从挂接点删除:
        #umount /export/home
        从逻辑硬件文件名删除:
        # umount /dev/dsk/c0t0d0s7
 
    执行umountall命令:
        /usr/sbin/umountall命令会在系统关闭或在命令输入umountall时读取/etc/mnttab文件,然后umount
    vfstab文件中除/ (root), /usr, /proc, /dev/fd, /var,/var/run, and /tmp.之外所有行;
        
        umount所有文件系统:
        #umountall 
        umount所有本地的文件系统:
        #umountall -l
 
    umountall状态为busy的系统:
        
        以下四种情况,文件系统都会显示:umount: file_system_name busy
 
        1 A program is accessing a file or directory in the file system
        2 A user is accessing a directory or file in the file system
        3 A program has a file open in that file system
        4 The file is being shared
 
        有两种方法解决:
        (1) 使用fuser命令来确认挂接点有那些进程在访问,然后杀掉
        (2) 用umount -f 强制umount;
 
        用fuser命令的四步:
        1.确认挂接点有那些进程需要杀掉
        #fuser -cu /mount_point 
        2.向进程发出SIGKILL信号:
        #fuser -ck /mount_point
        3.确认看是否还有进程在访问挂接点
        #fuser -c /mount_point
        4.umount挂接点
        #umount /mount_point
 
        umount -f 丢失数据,僵死进程,但比较适合远程共享时,远程没有响应.
 
    在启动失败时,修复重要文件:
 
        1.插入solaris 9 1 of 2 cd-rom
        2.OBP下运行:
        oK>boot cdrom -s
        3.用fsck来检测修复/ 根目录:
 
        # fsck /dev/rdsk/c0t0d0s0
 
        4.如果检测成功,把根目录的挂接点挂到一个新建的目录上:
        # mount /dev/dsk/c0t0d0s0 /a
        5.设置TERM参数,使vi能正常工作:
        # TERM=sun
        # export TERM
        6.编辑/a/etc/vfstab,
        7.umount文件系统:
        # cd /
        # umount /a
        8.重启系统init 6
 
 
    访问mount 软盘和光盘
        
        volume management提供两大益处:
            1.对于root用户和非root用户,都提供diskettes and CD-ROMs的自动mount
            2.能上其它网上系统访问本系统的移动存储设备;
 
        volume management自动检测CD-ROM,但不检测diskette,除非用volcheck. volcheck检测diskette和其它可移动设备.
        volume management能mount以下文件系统:
            
            ufs, pcfs, hsfs, udfs
        
 
        用卷管理:
            如是vold检测到软件或光盘并且发现其中包含文件系统会把它们mount到相应位置:
 
             First diskette drive     /floppy/floppy0
   First CD-ROM or DVD drive          /cdrom/cdrom0
             First Jaz drive          /rmdisk/jaz0
             First Zip drive          /rmdrive/zip0
             First PCMCIA card        /pcmem0
 
            如果没有发现文件系统:
 
            First diskette drive            /vol/dev/aliases/floppy0
            First CD-ROM or DVD drive       /vol/dev/aliases/cdrom0
            First Jaz drive                 /vol/dev/aliases/jaz0
            First Zip drive                 /vol/dev/aliases/zip0
            First PCMCIA card               /vol/dev/aliases/pcmem0
 
           当volume management 启动时,一个普通用户访问cdrom或diskette时需要以下几步:
 
            1.插入相应设备,光盘或软盘;
            2.如是软盘需要volcheck
            3.cd 到相应目录
            4.在目录操作
            5.umount 目录
            6.eject出设备
 
            volume management两个重要文件:
 
                /etc/vold.conf   volume management配置文件,配置一些条目,如插入,弹出设备时的动作,
                                  那些设备被volume management管理,那些设备是不安全弹出等.
            
                /etc/rmmount.conf  rmmount命令的配置文件,rmmount是一个被volume management在光盘或
                                   软盘弹出时执行的命令;
 
 
        限制mount光盘或软盘:
            停止卷管理服务:
            # /etc/init.d/volmgt stop  或   # pkill -9 vold
            启动卷管理服务:
            # /etc/init.d/volmgt start
        
        没有卷管理服务时访问光盘或软盘:
            普通用户需要以下九步:
            1.插入光盘或软盘;
            2.su到root用户;
            3.如果需要 ,生成一个挂接点.
            4.判断设备上文件系统类型;
            5.用mount和其属性把设备mount
            6.在设备下操作处理,
            7.工作完后umount设备;
            8.弹出设备
            9.退出root session
 
        mount一个光盘:
        # mount -F hsfs -o ro /dev/dsk/c0t6d0s0 /cdrom
        mount一个软盘:
        # mkdir /pcfs
        # mount -F pcfs /dev/diskette /pcfs

  回复于:2005-01-25 23:36:42
>>>/etc/vfstab列出系统启动时自动mount的文件, 除/etc/mnttab和/etc/run之外; 
还有个/etc/run?

>>>介绍/etc/mntfs文件: 
此文件是一个只读文件,当mount一项时,会在此文件中入一条,umount后也会在此文件中删除相应项; 
晕!/etc/mntfs我这里也没有?

补充一句,After system is installed, swap slices and files are listed in the /etc/vfstab file and are activiated by the /sbin/swapadd script when the system is booted.

 wjg023 回复于:2005-01-26 09:22:15
/etc/run打错了,应该是/var/run ,是一个tmpfs挂接点.存放临时文件系统,It is mounted as a
pseudo file system rather than a disk-based file system.


.>>>>/etc/mntfs 不好意思,更是打错了.是/etc/mnttab,sorry !!!


谢谢这位老兄的指出,我马上改更过来.谢谢了.

 wjg023 回复于:2005-01-26 09:33:15
怎么没给成原创精华,打击积极性,唉!!

 songyupo 回复于:2005-01-26 09:37:31
搂主那sa239的笔记别的章节那,收下

 wjg023 回复于:2005-01-26 09:45:05
后面的待发,前面的都在了.

 wjg023 回复于:2005-01-26 09:51:58
不知道版主原创精华到底是个啥标准,前面两篇都贴成原创精华了,怎么到这里了,不给了,唉..... ..... 有点气馁.有点郁闷.

难道就是因为俺长的有点丑,原来也这样呀,咋原就贴成精华了呢,那为啥呀,俺天生就这样呀.

 飞天二狭 回复于:2005-01-29 19:32:20
[quote:3fedda28e4="wjg023"]不知道版主原创精华到底是个啥标准,前面两篇都贴成原创精华了,怎么到这里了,不给了,唉..... ..... 有点气馁.有点郁闷.

难道就是因为俺长的有点丑,原来也这样呀,咋原就贴成精华了呢,那为啥呀,俺天生就这样呀.[/quote:3fedda28e4]

我认为你的头像太吓人,建议更换,帖子的内容很好,就是一看头像就不想看了,长的是那样,可是头像不一定非放上。

 race 回复于:2005-01-29 19:57:43
这个是我加的精彩帖子,你以前的笔记是别的斑竹加的原创。可能版主之间对这个理解不一样。
我的理解是原创是自己写出来的,而不是学习心得。这些资料很多,你按自己的理解归档了一下。
你这种学习精神还是值得提倡和表扬的。不要因为计较这些精华和精彩的帖子而打消你的积极性,以前有人就是因为计较这些而大发议论,最后离开论坛。

  回复于:2005-01-30 12:45:28
斑竹说得好,顶。
不过呢,搂住想加精,我看主要也是为了大家着想,毕竟进了精华,大家看到的机会多一些,是吧?

关于,/var/run和/etc/mnttab我也copy点东西,算是个补充:

The /var/run File System
A new TMPFS-mounted file system, /var/run, is the repository for temporary system files that are not needed across system reboots in this Solaris release and future releases. The /tmp directory continues to be repository for non-system temporary files.

Because /var/run is mounted as a memory-based file system rather than a disk-based file system, updates to this directory do not cause unnecessary disk traffic that would interfere with systems running power management software.

The /var/run directory requires no administration. You may notice that it is not unmounted with the umount -a or the umountall command.

For security reasons, /var/run is owned by root.

Mount Table Changes (/etc/mnttab)
In previous Solaris releases, /etc/mnttab was a text-based file that stored information about mounted file systems. The downside of being a file was that it could get out of sync with the actual state of mounted file systems. 

Now the /etc/mnttab file is a MNTFS file system that provides read-only information directly from the kernel about mounted file systems for the local system.

Note the following mnttab behavior changes:

Programs or scripts attempting to write to /etc/mnttab will fail. 

The mount -m option for faking mnttab entries no longer works.

No administration is required for the /etc/mnttab mount table. 

See mnttab(4) for more information.

最后再唠叨2句,我也是个初学者,来这里本来是想请教一些百思不得其解的问题,当然对各位高手来说,可能都是小case。
可是,发现,很多朋友问的问题,比我还,怎么说呢,sun的网站上document很全,大家只要去看看,就会发现,有些问题实在是不必问。
http://docs.sun.com/app/docs/prod/4797#hic
我把链接放在这里,感兴趣的朋友还是去看看为好。当然,不愿意看得,算我没说,赫赫。
请大家不要一看是英文的就打鼓,其实IT行业对语言要求是最低的,你看一阵子就会发现,就那几个单词,不断重复。
我敢保证,如果大家都这么学的话,这里的水量会减少60%。希望斑竹不要怪我。

 .netfrihor 回复于:2005-01-30 16:57:22
不错分析的汉详细

延伸阅读

文章来源于领测软件测试网 https://www.ltesting.net/


关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备10010545号-5
技术支持和业务联系:info@testage.com.cn 电话:010-51297073

软件测试 | 领测国际ISTQBISTQB官网TMMiTMMi认证国际软件测试工程师认证领测软件测试网