Automount mini-Howto <author><tt/don@sabotage.org/ <date>v0.4, 17 April 1999 <trans>早川 仁 <tt>cz8cb01@linux.or.jp</tt> <tdate>v0.4j, 1999年10月 2日 <abstract> <!-- This file describes the autofs automounter, how to configure it, and points out some problems to avoid. --> このファイルは autofs オートマウンタとその設定方法、 そしていくつかの避けるべき問題点について説明します。 </abstract> <!-- Table of contents --> <toc> <!-- Begin the document --> <sect> <!-- Introduction --> イントロダクション <sect1> <!-- Automount - what and why --> オートマウント - どうしてこれが必要になるの? <p> <!-- Automouting is the process where mounting (and unmounting) of certain filesystems is done automatically by a daemon. If the filesystem is unmounted, and a user attempts to access it, it will be automatically (re)mounted. This is especially useful in large networked environments and for crossmounting filesystems between a few machines (especially ones which are not always online). It may also be very useful for removable devices, or a few other uses, such as easy switching between a forced-on ascii conversion mount of a dos filesystem and a forced-off ascii conversion mount of the same dos fs. --> オートマウンティングとはデーモンによって自動的に実行される、ファイルシステムのマウンティング(及びアンマウンティング)のプロセスの事です。もしアンマウントされているファイルシステムにユーザーがアクセスをしようとした場合、自動的に再マウントされます。この動作は大規模なネットワーク化された環境や複数のマシン間(特に常時オンラインではないマシン間)での相互マウントしたファイルシステムの場合に非常に便利です。これはまたリムーバブルな機器の場合や、マウントしたDOS ファイルシステムとの文字コードや改行コードなどの変換といった使用方法の場合に非常に便利かもしれません。 <sect1> <!-- Types of automounting --> オートマウントの種類 <p> <!-- There are two types of automounters in linux; <em>AMD</em> and <em>autofs</em>. AMD is the automount daemon, and supposedly works like the SunOS AMD. It is implemented in user space, meaning it's not part of the kernel. It's not necessary for the kernel to understand automounting if you NFS mount to the local host, through the AMD daemon, which routes all automount filesystem traffic through the NFS system. Autofs is a newer system assisted by the kernel, meaning that the kernel's filesystem code knows where the automount mount points are on an otherwise normal underlying fs, and the automount program takes it from there. Only autofs will be described in this mini-howto. --> linux のオートマウンタには <em>AMD</em> と <em>autofs</em> の2種類があります。AMD はオートマウントデーモンで、おそらく SunOS の AMD と同じ様に動作します。このデーモンはユーザー空間に実装されます。この事は、カーネルの一部では無いという事を意味します。AMD デーモン(このデーモンは NFS システム経由で、全てのオートマウントされるファイルシステムのトラフィックをルーティングします)を使用して NFS でローカルホストのマウントを行えば、カーネルのオートマウンティングに対する設定は必要ありません。Autofs はカーネルにアシストされる新しいシステムです。この意味は、カーネルのファイルシステムのコードはオートマウントポイントが他の通常のファイルシステムのどこにあるかを知っているという事で、オートマウントプログラムはそのマウントポイントを使用します。この mini-howto では、autofs のみを説明します。 <sect> <!-- Installation --> インストール <p> <!-- Because autofs is implemented in kernel-space, your kernel must have support compiled in. In 2.0.xx it is an experimental option, but appears to be quite stable. In 2.2.xx it is a normal option. --> autofs はカーネル空間に実装されていますので、カーネルはそれをサポートするようにコンパイルされている必要があります。カーネル2.0.xxでは、実験的オプションでしたが、非常に安定しているようでしたので、2.1.xx(おそらく 2.2.xxでも)では普通のオプションとなりました。 <p> <!-- The automount program and its configuration files are also necessary; using the rpms (from RedHat, as part of the install) is a great way to go. The automount program should be started by an rc script under the <tt>/etc/rc.d/init.d</tt> directory . The rpm installs this, but you will need to make sure it gets started, either by linking it from your rc?.d directory, using Redhat's control-panel, or on another distribution by getting the thing started anyway you care to. Non-rpm distros will have to do whatever's applicable to their system. And don't look too hard at what the rc script does; if you're reading this howto you probably don't want to know. --> また、オートマウントプログラムとその設定ファイルも必要となります。rpms(RedHat のパッケージ形式です)を使用するのは非常に良い方法です。オートマウントプログラムは <tt>/etc/rc.d/init.d</tt> ディレクトリの rc スクリプトによって起動されるはずです。rpm はそのスクリプトをインストールしますが、起動されたかどうかは Redhat のコントロールパネルを使用してあなたのrc?.d ディレクトリからリンクするか、又は(他のディストリビューションの場合)他の好きな方法でそれを起動させて、確認する必要があります。rpm を使用していないディストリビューションの場合はそのシステムに適切な方法で行ってください。ただし、rcスクリプトが行う事をあまり真剣に読まないで下さい。この howto を読んでいる方達は知りたくもないでしょうが。 <sect> <!-- Configuration --> 設定 <p> <!-- Installing the RPM's will get you to this point easily enough, but here's the part you might not be sure about if you haven't done this before. --> RPM をインストールする事によって簡単に設定を行う事が可能ですが、以前に設定を行ったことがない場合は、あまり自信が無い所かもしれません。 <p> <!-- There are two files in /etc, one called <tt>auto.master</tt> and one called <tt>auto.misc</tt>. My auto.master looks like this: --> /etc の下には <tt>auto.master</tt> と <tt>auto.misc</tt> という2つのファイルがあります。私の auto.master はこのようになっています。 <verb> /auto /etc/auto.misc --timeout 60 </verb> <p> <!-- The first entry is not the mount point. It's where the set of mount points (found in the second entry) are going to be. The third option says that the mounted filesystems can try to unmount themselves 60 seconds after use. They can't unmount if being used, of course. --> 最初のエントリーはマウントポイントではなく(二番目のエントリーのファイル内にある)、いくつかのマウントポイントが設定される場所です。三番目のオプションはマウントされたファイルシステムが、使用された後 60 秒経つと自分自身をアンマウントしようとすることを示しています。もちろんその時に使用中であればアンマウントされません。 <p> <!-- Auto.misc is a "map file". The map file can have any name; this one is named auto.misc because it originally controlled /misc. Multiple map files can be defined in auto.master. My auto.misc looks like this: --> Auto.misc とは"マップファイル"の事です。マップファイルはどのような名前でもかまいません。この例ではもともと /misc を操作するものだったので auto.misc にします。複数のマップファイルを auto.master の中に定義することもできます。私の auto.misc はこのようになっています: <verb> kernel -ro,soft,intr ftp.kernel.org:/pub/linux cd -fstype=iso9660,ro :/dev/cdrom zip -fstype=auto :/dev/hdd4 floppy -fstype=vfat :/dev/fd0 </verb> <p> <!-- The first column (the "key") is the mount point. In this case it would be /auto/floppy or whatever. The middle set are the options; read the mount manpage for details on this. And the last column specifies where the fs comes from. The "kernel" entry is supposed to be an NFS mount. The : on all the other lines means its a local device. --> 最初のカラム(これはキーです)はマウントポイントです。上記の場合 /auto/floppy などです。二番目はオプションの指定です。詳細は mount の manpage を参照して下さい。最後のカラムはファイルシステムの場所を示しています。上記の "kernel" エントリーは NFS マウントとなっています。その他の行の':'はローカル上のデバイスを意味します。 <sect> <!-- That long wait to unmount --> アンマウントまでの長い待ち時間 <p> <!-- Some of you may be eyeing that 60 second timeout and thinking, <em>that's a long time to wait to eject a floppy.. Maybe I'll just sync the disks and pop it out mounted and nobody will notice.</em> Let me suggest <tt>saner alternatives</tt>. First of all, you can change the timeout. But that could be a little inefficient; telling the system to unmount stuff after only 15 seconds or whatever. Depending on your setup, you may be able to simply run the umount command as a normal user. But there is actually a way to ask the automount program to umount. If you send (with the program kill) the signal <tt>SIGUSR1</tt> to the automount process, it will unmount everything it can. But before people start making unmount buttons on their window managers, there's a little problem. --> タイムアウトまでの 60 秒間、じっと待っているの人もいるかもしれませんが、<em>フロッピーが出てくるのを待っているのには長すぎる時間ですね。たぶん私は単に sync してマウントされているフロッピーを取り出しちゃいますが、そのことに誰も気がつかないでしょう。</em><tt>正しい代替方法</tt>を提案させて下さい。まず、タイムアウト時間は変更する事ができます。ですが、システムに 15 秒やそこらの時間でアンマウントするように指定したからといって、役に立つとも思われません。実はオートマウントプログラムにアンマウントするように指定する方法があります。kill コマンドで <tt>SIGUSR1</tt> シグナルが送られると、オートマウントプロセスはアンマウント可能なもの全てをアンマウントします。でもウィンドウマネージャ上にアンマウントボタンを作りはじめるのはちょっと待ってください。多少の問題があります。 <p> <!-- The automount process is run by root, and it will only accept signals from root. Half of the reason you're probably doing automounting is so you can mount an unmount *without* being root. It would be easy to make a suid-root C program which does the dirty deed. However, by using sudo it is possible to allow users to send the proper kill signal. The only problem is that sudo will not let you use ` to process subcommands, which you would have to do to find the current PID. You should have a program called killall, which will let you do this: (thanks for the suggestions) --> オートマウントのプロセスは root によって実行されますので、root からの signal しか受け取りません。ですが、あなたがオートマウンティングをしている理由の半分は、root にならずにアンマウントされているファイルシステムをマウントできるからだと思われます。強引にアンマウントさせるために suid-root した C プログラムを作るのも簡単なことでしょうけれど、sudo をうまく使えば適切な kill シグナルをユーザーが送ってアンマウントさせることもできるようになります。この方法のただ一つの問題は、sudo はサブコマンドを実行する為に ` を使用することを許可しないことです。ですから ` で現在の PID を見つけることはできません。あなたはたぶん killall というこの動作を実行してくれるプログラムを持っているはずです (「これを使うと良い」と教えてくれた提案に感謝します)。 <verb> ALL ALL=NOPASSWD:/usr/bin/killall -USR1 automount </verb> (訳注:この行を /etc/sudoers に書いておくと、誰でも automount にパスワード無しで SIGUSR1 を送れる、ということです。詳しくは man sudo を参照してください。ちなみに killall コマンドは Plamo Linux 1.3(Slackware) ではコマンドの置き場所が /bin/killall ですが、RedHatとDebian 2.0 (hamm) では /usr/bin/killall のようです) <!-- Otherwise, you would have to allow your users to send -SIGUSR1 to all processes. That has various effects on programs; it will recycle some window managers, but kills xemacs. So here's hoping there's no buffer overruns in killall... --> さもなければユーザー全員に、全てのプロセスに対して -SIGUSR1 を送る許可を与える必要があるでしょう。それはプログラムに色々な影響を与えます。いくつかのウインドウマネージャが再起動や、xemacs が kill されてしまうことなどです。killall にバッファオーバーランが存在しない事を祈ります。 (訳注: sudo では foo `bar` (bar コマンドの出力を foo コマンドの引数にする)ができないので automount の PID を狙い撃ちできません。ですから sudo+kill では "すべてのプロセスに SIGUSR1 を送れる権限" を各ユーザに与えなければなりませんが、そうすると間違えて SIGUSR1 を WM に送ってしまった場合に recycle してしまうし、xemacs だと死んでしまうということでしょう。また killall にバッファオーバーランがあると sudo 経由で root 権限を与えられた killall コマンドがセキュリティホールになる危険性が生じてくるので、そういうことが無いように祈ると書かれているのでしょう) <sect>Questions <p> <sect1> <!-- I don't see /auto/floppy, or whatever mountpoint I'm looking for. --> /auto/floppy のようなマウントポイントが見つかりません <p> <!-- If automount is setup properly, whatever mount point you're looking for will be there if you try and use it, even though you don't see it when not in use. If you're browsing the directory with a graphical tool, you may need to type in the name manually; most programs will try what you give it, and the drive will be mounted before it notices. Unfortunately not being able to choose from the available invisible mount points is probably the major drawback of autofs. If it really bugs you, edit the configuration files. (Hint, the ones that end in .c for "configuration") --> オートマウントが正常にセットアップされれば、あなたが必要としているマウントポイントがどのような物であっても、使おうとすれば見つける事ができます。使用していないときはみえませんけれども。もしもグラフィカルツールでディレクトリを見ている(browsing)場合、手動でディレクトリ名を入力する必要があるかもしれません。使用可能なのに見えないマウントポイントを選択できないというのは autofs の大きな欠点かもしれません。もしそれが本当に問題なら設定ファイルを編集してください(設定ファイルは .c で終わります)。 <!-- One workaround several people have tried is to create symbolic links to where automount will create something once it's mounted. This will likely prevent the program from complaining a directory doesn't exist (if the mount works, that is) but careless directory listings will cause filesystems to be mounted. --> この問題に対処するために何人かの方が行っている方法は、オートマウントがマウントする場所に対してシンボリックリンクを作成することです。これによりディレクトリが存在しないというエラーは無くすことができるでしょう(マウントが行われたらマウントされた場所を指すようになります)。無頓着なファイラーの場合リンクを参照すると、オートマウントを引き起こすことになります。 <sect1> <!-- How do I see what's mounted? --> マウントの状態を見るには? <p> <!-- The <tt>df</tt> command. <tt>mount</tt> with no options will do the same, plus show the options its mounted with. --> <tt>df</tt> コマンドを使用してください。オプション無しの <tt>mount</tt> コマンドでも構いません。mount 場合はさらにマウントされているオプションも表示します。 <sect1> <!-- I put in a win95 disk ("vfat") and it was autodetected as only a regular FAT disk. --> win95(vfat)フロッピーを入れましたが、単なる FAT のフロッピーとして自動認識されました <p> <!-- This is not a problem with automount. As of this writing, the "auto" fs type does not attempt a vfat mount before it successfully mounts an msdos filesystem. VFAT is the Win95 and WinNT long filenames crammed into a FAT/MSDOS filesystem. --> これはオートマウントの問題ではありません。この Howto を書いている時点でのファイルシステムの自動認識は、msdos のファイルシステムを正常にマウントできるまでは vfat でのマウントをしようとしません。VFAT とは(MSDOS で使用している)FAT に Win95 と WinNT で使用するロングファイル名を強引につめこんだ物の事です。 (訳注: VFAT とは、従来の FAT16 の FAT の使用されていない部分にロングファイル名(最長 255 文字まで)を格納し、そのファイル名の頭から 6 文字+~+通番を、8 + 拡張子 3 文字の従来使用していたファイル名として使用することによって、DOS との上位互換性を保持しながら無理矢理にファイル長 8.3 文字の制約を排したものです。これによって、VFAT 対応の OS からはロングファイル名部分(及び従来のファイル名)を、VFAT 未対応の OS (DOS など)からは 8.3 文字のファイル名を見せるようにしています。例えば "1234567890" というファイル名は、"123456~1" などというファイル名になります) <p> <!-- According to one of the authors of mount, since mount is only a wrapper around a system call which must specify the filesystem type, it's still the responsibility of the user to come up with the fs type. Having mount take a list of filesystems to try in order, rather than the current "heuristic" is under consideration. Some users have simply not compiled msdos into the kernel; this prevents it from being tested prior to vfat. This will work for most people; a few actually need msdos fs and it caused me quite some frustration to not have a module handy when I actually needed it. --> mount の著者の一人によると、mount はファイルシステムのタイプを指定する必要があるシステムコールの単なるラッパーなので、ファイルシステムのタイプの指定をユーザーが行う必要があります。現行の自分自身でファイルシステムを探す(heuristic)仕様の代わりに mount 自身にファイルシステムのリストを取得させることを現在考慮中です。単純に、msdos fs をカーネルに組み込まない人もいます。これにより vfat の前に msdos かどうかをテストされることを避けられます。多くの人の環境でこれはうまく動くでしょうが、本当に msdos fs が必要な場合にモジュールの組み込みが簡単にできないような時には非常にフラストレーションが溜まります。 <!-- I'm sure that if anyone wants to go to the effort of finding the owner(s) of the mount program, your comments would be welcome. So unless you don't compile msdos in, for now this means that you can't mount vfat unless you give up the ability to autodetect all other fs's. Hopefully it will be configurable someday. In the mean time, feel free to create multiple mount points with different fs types specified. --> mount プログラムの著者(達)を探しだしてコメントを送ると歓迎されるでしょう。結論としては msdos をコンパイル時に組み込まない場合を除いて、現在のところは他のファイルシステムの自動認識をあきらめない限り、vfat をマウントすることはできないということです。この問題が早く解決すればよいのですが。。。それまでの間はファイルシステムのタイプごとに別々のマウントポイントを作って指定するようにしましょう。 <sect1> <!-- My filesystem <tt>/auto/grumblesmurf</tt> is mounted and <tt>kill -SIGUSR1</tt> won't unmount it. --> 私の /grumblesmurf というファイルシステムがマウントされましたが kill -SIGUSR1 を送ってもアンマウントされません <p> <!-- It's being used by something. Root probably can't manually unmount it either. If you're the one who caused it to be mounted (i.e. it can't be someone else using it) look around for a shell that might be in that directory. If there are none, look for something else (particularly something that might have gone though that directory like a directory browser) that might have left an invisible foot in the door so to speak. If you've given up looking, try using the fuser program. --> それは現在使用されているからです。root であったとしても、おそらく手動でアンマウントすることはできないでしょう。マウントしたのがあなた(つまり、他のユーザーに使われているはずが無い)であるなら、そのディレクトリにあるシェルを探してみてください。もしも見あたらなければ、他の何か(すでに終了されたファイラーのような)が、いわゆる痕跡を残していないかどうかを調べてみてください。うまく探せなかったら、fuser プログラムを使ってみてください。 <sect1> <!-- What happens if I make / the directory for the automounter --> / ディレクトリをオートマウントするようにしたらどうなります? <p> <!-- Oooh. Well, out of a statistical sample of only one person, none of the results were positive. You have been warned. If you want /grumblesmurf, then I suggest a symbolic link. Much safer. --> え〜と。。。私だけの実験だけじゃぁ何が起きるか予想できませんねぇ。注意してくださいよ。たとえば /grumblesmurf なんてのが必要ならシンボリックリンクを作成することを勧めます。まだ安全ですから。 <sect1> <!-- Can I have two map files on the same directory? --> 同じディレクトリに2つのマップファイルを置いておけますか? <p> <!-- Not as far as I know. Try using one map file, with specific options for individual entries. --> 私の知る限り無理です。個々のエントリーを記述するオプションを利用して1つのマップファイルを使うようにしてください。 <sect1> <!-- I'm using SuSE 6.0 and needed <tt>---timeout</tt> instead of <tt>--timeout</tt> --> 私は SuSE 6.0 を使っています。<tt>--timeout</tt> の代わりに <tt>---timeout</tt> を使う必要があるんですが <p> <!-- Uh. Ok, I've made a note about it. Another solution to "timeout not working" problems would be to add a <tt>-t time</tt> option to the autofs script. --> え〜と、はい。メモを取りましたよ。"timeout が動作していない" 問題のもう一つの解決方法は、<tt>-t time</tt> オプションを autofs スクリプトに追加することです。 <sect1> <!-- How do I set the permissions and ownership for the filesystem (IE FAT) --> ファイルシステム(つまり FAT ですが)にパーミッションと所有権をセットする方法は <p> <!-- Check the man page for mount for some of the options, such as setting the uid=value or umask=value options. One option that appears to be missing for FAT filesystems is mode=value. Sorry. Check in with the people who do mounting. --> mount の man page を参照してください。uid=値 や umask=値 オプションが見つかるはずです。FAT ファイルシステム上で動作しないだろうと思われるオプションは mode=値 です。すいません、詳しくはご自分でチェックしてください。 <sect1> <!-- Who do I thank for autofs? --> autofs に感謝するには? <p> <!-- Not me. I didn't have anything to do with it. I just wanted to bring everyone's attention to what a great job had been done with autofs, and how easy it is to use. Compared to the original perpetrators of AMD (Hint, they sell an overpriced unice with prehistoric versions of free tools) the autofs is very well documented and the implementors have my sincere thanks. Everything is stamped copyright Transmeta so sorry I can't provide a credits list,but I would bet Peter Anvin is responsible for quite a bit of it. Peter also held a session on autofs at linuxworldexpo on March 3, 1999. --> 私にではありません。私は autofs に関しては何もしていません。私はただ、みんなに autofs の素晴らしい仕事と、なんて簡単に使えるかということに注目してもらいたかっただけです。強欲な AMD (例えば unice や有史以前のフリーなツールを非常に高値で販売しています)に比べ、autofs はドキュメントも豊富です。実装者には心から感謝しています。 すべての著作権は Transmeta 社が保持しておりますので、すいませんがクレジットリストを書き出すことはできませんが、Peter Anvin がかなり多くの部分を持ってると確信しています。また Peter は、1999 年 3 月 3 日の linuxworldexpo で autofs に関するセッションを行いました。 (訳注: unice とは、UNIX の複数形です。ただし、同じ種類の UNIX が複数あったとしても unice ではありません。AIX, Linux, BSD など複数の種類の UNIX を指して unice と言います) <sect1> <!-- Where can I learn more about automounting? --> オートマウンティングについてもっと知りたいのですが? <p> <!-- There's a autofs tutorial at <url url=" http://www.linuxhq.com/lg/issue24/nielsen.html">. See also am-utils at <url url="http://www.cs.columbia.edu/~ezk/am-utils"> --> autofs のチュートリアルが <url url="http://www.linuxhq.com/lg/issue24/nielsen.html"> にあります。<url url="http://www.cs.columbia.edu/~ezk/am-utils"> にある am-utils も参考になるでしょう。 <p> <!-- (Thanks for these URLs) --> (この URL を教えてくれてありがとう) </article>