sa239学习笔记之三mount 和umount

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,则必须删除相关大文件,

推荐阅读