autofs 中文man頁面
名稱(NAME)
autofs - automounter maps的格式
描述(DESCRIPTION)
automounter maps 是一系列非主映射文件或者是NIS映射(NIS maps),它們被 automounter 的主映射文件(master map)具體調(diào)用(參看 auto.master(5))。 automounter maps 具體描述了在主映射文件(auto.master)中的列出掛載點是如何被掛載的。這份文檔只涉及類似于 sun 系統(tǒng) 下的非主映射文件格式; 如果指定了其它的格式 (例如:hesiod),那么這份文檔就不適用了。這些非主映射文件都能被修改而且 automounter 會在下一次處理這些映射文件時馬上認出它們。但是主映射文件 auto.master 做不到這一點。
格式(FORMAT)
這僅僅是該文本文件的一種格式,也許還存在其它的格式。所有的空行和以“#”字符開始的行都會被忽略掉。在一個映射文件中每一行的基本格式看起來如下: key [-options] location
key
是目錄名的一部分,位于掛載點和被掛載的文件系統(tǒng)路徑之間。通常你可以把“key”看作為一個位于掛載點下的子目錄。
options
options是可選的。它也能夠在 auto.master 中明確的給出。如果那樣的話,兩個選項能疊加起來(這一點與SunOS有所不同)。options是一組與 mount(8) 命令中的選項一樣的列表,以逗號分隔。不過,有個特殊選項 -fstype= ,它被用于指定一個文件系統(tǒng)的類型(如果要掛載的文件系統(tǒng)不是NFS的話)。這個特殊選項只能由 automounter來處理,mount是不能用的。(注:automounter通常用于NFS卷的自動掛載,但也可以用來在開機時掛載用戶自己的硬盤。個人感覺比在fstab中直接寫要方便。大家見仁見智,自選吧)
location
location指明將要掛載的文件系統(tǒng)是從哪來的。絕大多數(shù)情況下這將是個NFS卷,通常用 host:pathname 來指出將被掛載的遠程文件系統(tǒng)和路徑。如果要被掛載的文件系統(tǒng)是以“/”開頭的(例如本地文地文件系統(tǒng) /dev 或者是一個smb文件共享),那就需要在前面加一個“:”(例如 :/dev/sda1)。
范例
-
kernel -ro,soft,intr ftp.kernel.org:/pub/linux boot -fstype=ext2 :/dev/hda1 windoze -fstype=smbfs ://windoze/c removable -fstype=ext2 :/dev/hdd cd -fstype=iso9660,ro :/dev/hdc floppy -fstype=auto :/dev/fd0
第一行,我們把一個來自 ftp.kernel.org 的內(nèi)核目錄掛載為遠程NFS卷。這是只讀安裝。第二行掛載了一個本地ide磁盤上的ext2分區(qū)。第三行掛載了一個Windows系統(tǒng)上的samba共享目錄。剩下的應該是不言而喻的了。
特性(FEATURES)
映射替換(Map Key Substitution)
在 location 里的“&”字符可被用來代替 key 值,“&”會被自動展開為跟 key 一樣的值 (這個字符可能只有必要和下面的通配符一起用)
通配符(Wildcard Key)
在 key 里的“*“字符可匹配所有的key。下面是個很有用的范例:
-
* &:/home/&
這使你能夠以 /mountpoint/hostname/local-path 這種方式進入所有本地主機的主目錄。
變量替換(Variable Substitution)
下列這些特殊變量若出現(xiàn)在key或location中并且前面有個”$“,就能被相應的內(nèi)容替換,就像是在 shell腳本里一樣??梢杂靡粚?rdquo;{ }“ (curly braces)來分隔”字段名“(fieldname)
-
ARCH Architecture (uname -m) CPU Processor Type HOST Hostname (uname -n) OSNAME Operating System (uname -s) OSREL Release of OS (uname -r) OSVERS Version of OS (uname -v)
用 automount(8) -D variable=Value 還能定義更多的替換項。
可執(zhí)行的映射(Executable Maps)
一個映射能被標記為可執(zhí)行。傳遞主映射文件(auto.master)的初始化腳本會把這個可執(zhí)行映射作為一個 程序映射 送給automounter。 程序映射 將會像一個shell腳本那樣被執(zhí)用,”key“作為參數(shù)。如果找不到key,腳本會只輸出腳本文件的一行或者干脆什么都沒有。 要想像上面這么做的話, automount(8) daemon 必須以程序形式起動,而不是以文件形式。在automount的初始化腳本里包含有這條設定。 一個可執(zhí)行的映射能返回一個錯誤代碼來指出錯誤,或者什么都不顯示。所有送到標準錯誤輸出的內(nèi)容都被系統(tǒng)日志記錄在案。
不支持的功能(UNSUPPORTED)
automounter不支持直接掛載(注:實用時發(fā)現(xiàn)automount必須要有一個key才行,如果省略的話就不能安裝成功)或是掛載樹(用一個指定的自動掛載點來掛裝超過一個文件系統(tǒng)),以及不支持處理 SunOS類型的可復用文件系統(tǒng)(replicated filesystem)。這只有 mount(8) 才支持。
參看(SEE ALSO)
automount(8), auto.master(5), autofs(8), mount(8).
#p#
NAME
autofs - Format of the automounter maps
DESCRIPTION
The automounter maps are files or NIS maps referred to by the master map of the automounter (see auto.master(5)). The automounter maps describe how file systems below the mountpoint of the map (given in the auto.master file) are to be mounted. This describes the sun map format; if another map format is specified (e.g. hesiod), this documentation does not apply.
Maps can be changed on the fly and the automouter will recognize those changes on the next operation it performs on that map. This is not true for the auto.master map!
FORMAT
This is a description of the text file format. Other methods of specifying these files may exist. All empty lines or lines beginning with # are ignored. The basic format of one line in such maps is: key [-options] location
key
For indirect mounts this is the part of the pathname between the mountpointi and the path into the filesystem mounted. Usually you can think about the key as a subdirectory name below the mountpoint.
For direct mounts this is the full path of the mountpoint. This map is always associated with the /- mountpoint in the master map.
options
Options are optional. Options can also be given in the auto.master file in which case both values are cumulative (this is a difference from SunOS). The options are a list of comma separated options as customary for the mount(8) command. There are two special options -fstype= used to specify a filesystem type if the filesystem is not of the default NFS type. This option is processed by the automounter and not by the mount command. -strict is used to treat errors when mounting file systems as fatal. This is important when multiple file systems should be mounted (`multimounts'). If this option is given, no file system is mounted at all if at least one file system can't be mounted.
location
The location specifies from where the file system is to be mounted. In the most cases this will be an NFS volume and the usual notation host:pathname is used to indicate the remote filesystem and path to be mounted. If the filesystem to be mounted begins with a / (such as local /dev entries or smbfs shares) a : needs to be prefixed (e.g. :/dev/sda1).
EXAMPLE
-
kernel -ro,soft,intr ftp.kernel.org:/pub/linux boot -fstype=ext2 :/dev/hda1 windoze -fstype=smbfs ://windoze/c removable -fstype=ext2 :/dev/hdd cd -fstype=iso9660,ro :/dev/hdc floppy -fstype=auto :/dev/fd0 server -rw,hard,intr / -ro myserver.me.org:/ \ /usr myserver.me.org:/usr \ /home myserver.me.org:/home
In the first line we have a NFS remote mount of the kernel directory on ftp.kernel.org. This is mounted read-only. The second line mounts an ext2 volume on a local ide drive. The third makes a share exported from a Windows machine available for automounting. The rest should be fairly self-explanatory. The last entry (the last three lines) is an example of a multi-map (see below).
If you use the automounter for a filesystem without access permissions (like vfat), users usually can't write on such a filesystem because it is mounted as user root. You can solve this problem by passing the option gid=<gid>, e. g. gid=floppy. The filesystem is then mounted as group floppy instead of root. Then you can add the users to this group, and they can write to the filesystem. Here's an example entry for an autofs map:
-
floppy-vfat -fstype=vfat,sync,gid=floppy,umask=002 :/dev/fd0
FEATURES
Map Key Substitution
An & character in the location is expanded to the value of the key field that matched the line (which probably only makes sense together with a wildcard key).
Wildcard Key
A * in the key field of indirect maps matches all keys. An example for the usefulness is the following entry:
-
* &:/home/&
This will enable you to access all the home directory of local hosts using the path /mountpoint/hostname/local-path.
Variable Substitution
The following special variables will be substituted in the key and location fields of an automounter map if prefixed with $ as customary from shell scripts (Curly braces can be used to separate the fieldname):
-
ARCH Architecture (uname -m) CPU Processor Type HOST Hostname (uname -n) OSNAME Operating System (uname -s) OSREL Release of OS (uname -r) OSVERS Version of OS (uname -v)
Additional entries can be defined with the -Dvariable=Value map-option to automount(8).
Executable Maps
A map can be marked as executable. The init script that parses the auto.master map will pass this as a program map to the automounter. A program map will be called as a script with the key as an argument. It may return no lines of output if there's an error, or one or more lines containing a map (with \ quoting line breaks). To use a program map, the automount(8) daemon has to be started with the program type instead of the file type. This is implemented in the initialization script. A executable map can return an errorcode to indicate the failure in addition to no output at all. All output sent to stderr is logged into the system logs.
Multiple Mounts
A multi-mount map can be used to name multiple filesystems to mount. It takes the form:
-
key [-options] [mountpoint [-options] location...]...
This may extend over multiple lines, quoting the line-breaks with `\'. If present, the per-mountpoint mount-options are appended to the default mount-options.
Replicated Server
-
Multiple replicated hosts, same path: <path> host1,host2,hostn:/path/path Multiple hosts, some with same path, some with another <path> host1,host2:/blah host3:/some/other/path Multiple replicated hosts, different (potentially) paths: <path> host1:/path/pathA host2:/path/pathB Mutliple weighted, replicated hosts same path: <path> host1(5),host2(6),host3(1):/path/path Multiple weighted, replicated hosts different (potentially) paths: <path> host1(3):/path/pathA host2(5):/path/pathB Anything else is questionable and unsupported, but these variations will also work: <path> host1(3),host:/blah
UNSUPPORTED
This version of the automounter supports direct maps for FILE, NIS and LDAP maps only and handles SunOS-style replicated filesystems only to the extent that mount(8) does.
CAVEATS
Unlike Sun's multi-mount syntax, the mountpoint is mandatory for all mounts.
SEE ALSO
automount(8), auto.master(5), autofs(8), mount(8).