「Autofs」の版間の差分
(en:Autofsへの転送ページ) |
|||
1行目: | 1行目: | ||
+ | [[Category:ファイルシステム]] |
||
− | #redirect[[en:Autofs]] |
||
+ | [[en:Autofs]] |
||
+ | [[es:Autofs]] |
||
+ | [[it:Autofs]] |
||
+ | [[ru:Autofs]] |
||
+ | [[uk:Autofs]] |
||
+ | [[zh-CN:Autofs]] |
||
+ | このドキュメントは AutoFS を設定する手順を解説しています。AutoFS はリムーバルメディアやネットワーク共有などが接続されたりアクセスされたときに自動でマウントするパッケージです。 |
||
+ | |||
+ | == インストール == |
||
+ | |||
+ | {{Pkg|autofs}} を[[インストール]]してください。 |
||
+ | |||
+ | {{Note|{{ic|autofs4}} モジュールをロードする必要はなくなりました。}} |
||
+ | |||
+ | == 設定 == |
||
+ | |||
+ | AutoFS ではテンプレートファイルを使って設定します。ファイルは {{ic|/etc/autofs}} にあります。メインのテンプレートは {{ic|auto.master}} で、メディアタイプに合わせて他のテンプレートを読み込むことができます。 |
||
+ | |||
+ | * お好きなエディタで {{ic|/etc/autofs/auto.master}} ファイルを開いて下さい。以下のようになっているはずです: |
||
+ | |||
+ | {{hc|/etc/autofs/auto.master|2= |
||
+ | #/media /etc/autofs/auto.media |
||
+ | |||
+ | }} |
||
+ | |||
+ | The first value on each line determines the base directory under which all the media in a template are mounted, the second value is which template to use. The default base path is {{ic|/media}}, but you can change this to any other location you prefer. For instance: |
||
+ | |||
+ | {{hc|/etc/autofs/auto.master|2= |
||
+ | /media/misc /etc/autofs/auto.misc --timeout=5 |
||
+ | /media/net /etc/autofs/auto.net --timeout=60 |
||
+ | |||
+ | }} |
||
+ | {{Note|Make sure there is an empty line on the end of template files (press {{ic|ENTER}} after last word). If there is no correct EOF (end of file) line, the AutoFS daemon will not properly load.}} |
||
+ | |||
+ | The optional parameter {{ic|timeout}} sets the amount of seconds after which to unmount directories. |
||
+ | |||
+ | The base directory will be created if it does not exist on your system. The base directory will be mounted on to load the dynamically loaded media, which means any content in the base directory will not be accessible while autofs is on. This procedure is however non-destructive, so if you accidentally automount into a live directory you can just change the location in {{ic|auto.master}} and restart AutoFS to regain the original contents. |
||
+ | |||
+ | If you still want to automount to a target non-empty directory and want to have the original files available even after the dynamically loaded directories are mounted, you can use autofs to mount them to another directory (e.g. /var/autofs/net) and create soft links. |
||
+ | |||
+ | # ln -s /var/autofs/net/share_name /media/share_name |
||
+ | |||
+ | Alternatively, you can have autofs mount your media to a specific folder, rather than inside a common folder. |
||
+ | |||
+ | {{hc|/etc/autofs/auto.master|2= |
||
+ | /- /etc/autofs/auto.template |
||
+ | }} |
||
+ | {{hc|/etc/autofs/auto.template|2= |
||
+ | /path/to/folder -options :/device/path |
||
+ | /home/user/usbstick -fstype=auto,async,nodev,nosuid,umask=000 :/dev/sdb1 |
||
+ | }} |
||
+ | {{Note|This can cause problems with resources getting locked if the connection to the share is lost. When trying to access the folder, programs will get locked into waiting for a response, and either the connection has to be restored or the process has to be forcibly killed before unmounting is possible. To mitigate this, only use if you will always be connected to the share, and do not use your home folder or other commonly used folders lest your file browser reads ahead into the disconnected folder}} |
||
+ | |||
+ | * Open the file {{ic|/etc/nsswitch.conf}} and add an entry for automount: |
||
+ | automount: files |
||
+ | |||
+ | * テンプレートの設定が完了したら (下を参照)、root で {{ic|autofs.service}} を[[有効化]]・起動して AutoFS デーモンを起動してください。 |
||
+ | |||
+ | Devices are now automatically mounted when they are accessed, they will remain mounted as long as you access them. |
||
+ | |||
+ | === リムーバルメディア === |
||
+ | |||
+ | * Open {{ic|/etc/autofs/auto.misc}} to add, remove or edit miscellaneous devices. For instance: |
||
+ | |||
+ | {{hc|/etc/autofs/auto.misc|<nowiki> |
||
+ | #kernel -ro ftp.kernel.org:/pub/linux |
||
+ | #boot -fstype=ext2 :/dev/hda1 |
||
+ | usbstick -fstype=auto,async,nodev,nosuid,umask=000 :/dev/sdb1 |
||
+ | cdrom -fstype=iso9660,ro :/dev/cdrom |
||
+ | #floppy -fstype=auto :/dev/fd0 |
||
+ | </nowiki>}} |
||
+ | |||
+ | If you have a CD/DVD combo-drive you can change the {{ic|cdrom}} line with {{ic|-fstype<nowiki>=</nowiki>auto}} to have the media type autodetected. |
||
+ | |||
+ | === NFS ネットワークマウント === |
||
+ | |||
+ | AutoFS provides a new way of automatically discovering and mounting [[NFS]]-shares on remote servers (the AutoFS network template in {{ic|/etc/autofs/auto.net}} has been removed in autofs5). To enable automatic discovery and mounting of network shares from all accessible servers without any further configuration, you will need to add the following to the {{ic|/etc/autofs/auto.master}} file: |
||
+ | |||
+ | /net -hosts --timeout=60 |
||
+ | |||
+ | Each host name needs to be resolveable, e.g. the name an IP address in {{ic|/etc/hosts}} or via [[Wikipedia:Domain_Name_System|DNS]] and please make sure you have {{Pkg|nfs-utils}} installed and working. You also have to enable RPC (systemctl start|enable rpcbind) to browse shared Folders. |
||
+ | |||
+ | For instance, if you have a remote server ''fileserver'' (the name of the directory is the hostname of the server) with an NFS share named ''/home/share'', you can just access the share by typing: |
||
+ | |||
+ | # cd /net/fileserver/home/share |
||
+ | |||
+ | {{Note|Please note that ''ghosting'', i.e. automatically creating directory placeholders before mounting shares is enabled by default, although AutoFS installation notes claim to remove that option from {{ic|/etc/conf.d/autofs}} in order to start the AutoFS daemon.}} |
||
+ | |||
+ | The {{ic|-hosts}} option uses a similar mechanism as the {{ic|showmount}} command to detect remote shares. You can see the exported shares by typing: |
||
+ | |||
+ | # showmount <servername> -e |
||
+ | |||
+ | Replacing ''<servername>'' with the name of your own server. |
||
+ | |||
+ | An alternative Way is to use the automount-service from Systemd, see [[NFS#systemd で /etc/fstab を使う|NFS with systemd-automount]] |
||
+ | |||
+ | ==== NFS の手動設定 ==== |
||
+ | To mount a NFS share on server_name called /srv/shared_dir to another computer named client_pc at location /mnt/foo, edit auto.master and create a config file for the share (auto.server_name): |
||
+ | {{hc|<nowiki>/etc/autofs/auto.master</nowiki>|<nowiki>/mnt /etc/autofs/auto.server_name --timeout 60</nowiki>}} |
||
+ | {{hc|<nowiki>/etc/autofs/auto.server_name</nowiki>|<nowiki>foo -rw,soft,intr,rsize=8192,wsize=8192 server_name:/srv/shared_dir</nowiki>}} |
||
+ | |||
+ | === Samba === |
||
+ | |||
+ | The Arch package does not provide any [[Samba]] or CIFS templates/scripts (23.07.2009), but the following should work for single shares: |
||
+ | |||
+ | Add the following to {{ic|/etc/autofs/auto.master}}: |
||
+ | /media/[my_server] /etc/autofs/auto.[my_server] --timeout=60 --ghost |
||
+ | where {{ic|--timeout}} defines how many seconds to wait before the file system is unmounted. The {{ic|--ghost}} option creates empty folders for each mount-point in the file in order to prevent timeouts, if a network share cannot be contacted. |
||
+ | |||
+ | Next create a file {{ic|/etc/autofs/auto.[my_server]}} |
||
+ | [any_name] -fstype=cifs,[other_options] ://[remote_server]/[remote_share_name] |
||
+ | |||
+ | You can specify a user name and password to use with the share in the {{ic|other_options}} section: |
||
+ | [any_name] -fstype=cifs,username=[username],password=[password],[other_options] ://[remote_server]/[remote_share_name] |
||
+ | |||
+ | {{Note|Escape $, and other characters, with a backslash when neccessary.}} |
||
+ | |||
+ | === FTP と SSH (FUSE を使用) === |
||
+ | |||
+ | リモートの FTP や [[SSH]] サーバーには [[Wikipedia:Filesystem in Userspace|FUSE]] (仮想ファイルシステムレイヤー) と AutoFS でシームレスにアクセスすることができます。 |
||
+ | |||
+ | ==== リモート FTP ==== |
||
+ | |||
+ | まず、{{Pkg|curlftpfs}} パッケージをインストールしてください。 |
||
+ | |||
+ | {{ic|fuse}} モジュールをロード: |
||
+ | |||
+ | # modprobe fuse |
||
+ | |||
+ | システムが起動するたびにモジュールがロードされるように {{ic|/etc/modules-load.d/fuse.conf}} ファイルを作成して {{ic|fuse}} と記述してください。 |
||
+ | |||
+ | そして、{{ic|/etc/autofs/auto.master}} に FTP サーバーのエントリを追加します: |
||
+ | |||
+ | /media/ftp /etc/autofs/auto.ftp --timeout=60 |
||
+ | |||
+ | {{ic|/etc/autofs/auto.ftp}} ファイルを作成して {{ic|ftp://myuser:mypassword@host:port/path}} の形式でサーバーを追加してください: |
||
+ | |||
+ | servername -fstype=curl,rw,allow_other,nodev,nonempty,noatime :ftp\://myuser\:mypassword\@remoteserver |
||
+ | |||
+ | {{Note| Your passwords are plainly visible for anyone that can run {{ic|df}} (only for mounted servers) or view the file {{ic|/etc/autofs/auto.ftp}}.}} |
||
+ | If you want slightly more security you can create the file {{ic|~root/.netrc}} and add the passwords there. |
||
+ | Passwords are still plain text, but you can have mode 600, and {{ic|df}} command will not show them (mounted or not). |
||
+ | This method is also less sensitive to special characters (that else must be escaped) in the passwords. The format is: |
||
+ | |||
+ | machine remoteserver |
||
+ | login myuser |
||
+ | password mypassword |
||
+ | |||
+ | The line in {{ic|/etc/autofs/auto.ftp}} looks like this without user and password: |
||
+ | |||
+ | servername -fstype=curl,allow_other :ftp\://remoteserver |
||
+ | |||
+ | Create the file {{ic|/sbin/mount.curl}} with this code: |
||
+ | |||
+ | {{hc|/sbin/mount.curl|<nowiki> |
||
+ | #! /bin/sh |
||
+ | curlftpfs $1 $2 -o $5,disable_eprt |
||
+ | </nowiki>}} |
||
+ | |||
+ | Create the file {{ic|/sbin/umount.curl}} with this code: |
||
+ | |||
+ | {{hc|/sbin/umount.curl|<nowiki> |
||
+ | #! /bin/sh |
||
+ | fusermount -u $1 |
||
+ | </nowiki>}} |
||
+ | |||
+ | Set the permissions for both files: |
||
+ | |||
+ | # chmod 755 /sbin/mount.curl |
||
+ | # chmod 755 /sbin/umount.curl |
||
+ | |||
+ | After a restart your new FTP server should be accessible through {{ic|/media/ftp/servername}}. |
||
+ | |||
+ | ==== リモート SSH ==== |
||
+ | |||
+ | These are basic instructions to access a remote filesystem over [[SSH]] with AutoFS. |
||
+ | |||
+ | {{Note|パスワードを使わない認証は便利なだけでなくセキュリティ的に安全でもあります。詳しくは [[SSH 鍵]]を参照。}} |
||
+ | |||
+ | {{Pkg|sshfs}} パッケージをインストールしてください。 |
||
+ | |||
+ | {{ic|fuse}} モジュールをロード: |
||
+ | |||
+ | # modprobe fuse |
||
+ | |||
+ | システムが起動するたびにモジュールがロードされるように {{ic|/etc/modules-load.d/fuse.conf}} ファイルを作成して {{ic|fuse}} と記述してください。 |
||
+ | |||
+ | {{Pkg|openssh}} をインストールしてください。 |
||
+ | |||
+ | [[SSH 鍵]]を生成: |
||
+ | $ ssh-keygen |
||
+ | |||
+ | When the generator ask for a passphrase, just press {{ic|ENTER}}. Using SSH keys without a passphrase is less secure, yet running AutoFS together with passphrases poses some additional difficulties which are not (yet) covered in this article. |
||
+ | |||
+ | Next, copy the public key to the remote SSH server: |
||
+ | $ ssh-copy-id username@remotehost |
||
+ | |||
+ | '''As root''', see that you can login to the remote server without entering a password: |
||
+ | # ssh username@remotehost |
||
+ | |||
+ | {{Note|This will add the remote server to root's list of {{ic|known_hosts}}. Hosts can be also be manually added to {{ic|/etc/ssh/ssh_known_hosts}}.}} |
||
+ | |||
+ | Create a new entry for SSH servers in {{ic|/etc/autofs/auto.master}}: |
||
+ | /media/ssh /etc/autofs/auto.ssh --timeout=60 |
||
+ | |||
+ | Create the file {{ic|/etc/autofs/auto.ssh}} and add an SSH server: |
||
+ | {{hc|/etc/autofs/auto.ssh|2= |
||
+ | servername -fstype=fuse,rw,allow_other,IdentityFile=/home/username/.ssh/id_rsa :sshfs\#username@host\:/ |
||
+ | }} |
||
+ | |||
+ | After a restart your SSH server should be accessible through {{ic|/media/ssh/servername}}. |
||
+ | |||
+ | == MTP == |
||
+ | |||
+ | Android デバイスでは Media Transfer Protocol ([[MTP]]) が使われます。 |
||
+ | |||
+ | {{Pkg|mtpfs}} パッケージをインストールしてください。 |
||
+ | |||
+ | {{ic|/etc/autofs/auto.misc}} に MTP デバイスのエントリを追加: |
||
+ | android -fstype=fuse,allow_other,umask=000 :mtpfs |
||
+ | |||
+ | == トラブルシューティング == |
||
+ | |||
+ | このセクションでは AutoFS に関するよくある問題の解決方法を載せています。 |
||
+ | |||
+ | === NIS を使用 === |
||
+ | |||
+ | AutoFS のバージョン 5.0.5 には [[NIS]] の高度なサポートが含まれています。AutoFS で NIS を使うには、{{ic|/etc/autofs/auto.master}} でテンプレートの名前の前に {{ic|yp:}} を追加してください: |
||
+ | |||
+ | /home yp:auto_home --timeout=60 |
||
+ | /sbtn yp:auto_sbtn --timeout=60 |
||
+ | +auto.master |
||
+ | |||
+ | バージョン 5.0.5 以前の NIS を使っている場合、{{ic|/etc/nsswitch.conf}} に {{ic|nis}} を追加してください: |
||
+ | automount: files nis |
||
+ | |||
+ | === 任意のパラメータ === |
||
+ | |||
+ | You can set parameters like {{ic|timeout}} systemwide for all AutoFS media in {{ic|/etc/default/autofs}}: |
||
+ | |||
+ | * Open the {{ic|/etc/default/autofs}} file and edit the {{ic|OPTIONS}} line: |
||
+ | OPTIONS='--timeout=5' |
||
+ | |||
+ | * To enable logging (default is no logging at all), uncomment and add {{ic|--verbose}} to the {{ic|OPTIONS}} line in {{ic|/etc/default/autofs}} e.g.: |
||
+ | OPTIONS='--verbose --timeout=5' |
||
+ | |||
+ | After restarting the {{ic|autofs}} daemon, verbose output is visible in {{ic|systemctl status}} or in {{ic|journalctl}}. |
||
+ | |||
+ | === 複数のデバイスを認識 === |
||
+ | |||
+ | USB ドライブ/スティックを複数使用する場合、AutoFS を使ってマウントポイントを設定して [[Udev]] で USB ドライブごとに名前を付けることができます。Udev ルールの設定方法については [[udev#固定デバイス名の設定]] を見て下さい。 |
||
+ | |||
+ | === AutoFS のパーミッション === |
||
+ | |||
+ | If AutoFS is not working for you, make sure that the permissions of the templates files are correct, otherwise AutoFS will not start. This may happen if you backed up your configuration files in a manner which did not preserve file modes. Here are what the modes should be on the configuration files: |
||
+ | |||
+ | *0644 - /etc/autofs/auto.master |
||
+ | *0644 - /etc/autofs/auto.media |
||
+ | *0644 - /etc/autofs/auto.misc |
||
+ | *0644 - /etc/conf.d/autofs |
||
+ | |||
+ | In general, scripts (like previous {{ic|auto.net}}) should have executable ({{ic|chmod a+x filename}}) bits set and lists of mounts should not. |
||
+ | |||
+ | If you are getting errors in {{ic|/var/log/daemon.log}} similar to this, you have a permissions problem: |
||
+ | |||
+ | May 7 19:44:16 peterix automount[15218]: lookup(program): lookup for petr failed |
||
+ | May 7 19:44:16 peterix automount[15218]: failed to mount /media/cifs/petr |
||
+ | |||
+ | === fusermount の問題 === |
||
+ | With certain versions of util-linux, you may not be able to unmount a fuse file system drive mounted by autofs, even if you use the "user=" option. See the discussion here: |
||
+ | http://fuse.996288.n3.nabble.com/Cannot-umount-as-non-root-user-anymore-tp689p697.html |
||
+ | |||
+ | == AutoFS の代替 == |
||
+ | |||
+ | * [[Systemd]] は必要に応じてファイルシステムを自動マウントすることができます。説明は [[Fstab#systemd で自動マウント]] を、例は [[Sshfs#必要に応じてマウント]] を見て下さい。 |
||
+ | * [[Thunar#Thunar Volume Manager|Thunar Volume Manager]] は [[Thunar]] ファイルマネージャの自動マウントシステムです。 |
||
+ | * [[PCManFM]] はリモート共有にアクセスすることができる軽量なファイルマネージャです。 |
||
+ | * [[Udisks]] は最小主義の自動ディスクマウントサービスです。 |
||
+ | |||
+ | == 参照 == |
||
+ | |||
+ | * AutoFS で FTP と SFTP を使用する方法は Gentoo Wiki の記事を元にしています: https://web.archive.org/web/20130414074212/http://en.gentoo-wiki.com/wiki/Mounting_SFTP_and_FTP_shares |
||
+ | * SSH に関する詳細は [[SSH]] や [[SSH 鍵]]のページを見て下さい。 |
2015年8月9日 (日) 01:06時点における版
このドキュメントは AutoFS を設定する手順を解説しています。AutoFS はリムーバルメディアやネットワーク共有などが接続されたりアクセスされたときに自動でマウントするパッケージです。
目次
インストール
設定
AutoFS ではテンプレートファイルを使って設定します。ファイルは /etc/autofs
にあります。メインのテンプレートは auto.master
で、メディアタイプに合わせて他のテンプレートを読み込むことができます。
- お好きなエディタで
/etc/autofs/auto.master
ファイルを開いて下さい。以下のようになっているはずです:
/etc/autofs/auto.master
#/media /etc/autofs/auto.media
The first value on each line determines the base directory under which all the media in a template are mounted, the second value is which template to use. The default base path is /media
, but you can change this to any other location you prefer. For instance:
/etc/autofs/auto.master
/media/misc /etc/autofs/auto.misc --timeout=5 /media/net /etc/autofs/auto.net --timeout=60
The optional parameter timeout
sets the amount of seconds after which to unmount directories.
The base directory will be created if it does not exist on your system. The base directory will be mounted on to load the dynamically loaded media, which means any content in the base directory will not be accessible while autofs is on. This procedure is however non-destructive, so if you accidentally automount into a live directory you can just change the location in auto.master
and restart AutoFS to regain the original contents.
If you still want to automount to a target non-empty directory and want to have the original files available even after the dynamically loaded directories are mounted, you can use autofs to mount them to another directory (e.g. /var/autofs/net) and create soft links.
# ln -s /var/autofs/net/share_name /media/share_name
Alternatively, you can have autofs mount your media to a specific folder, rather than inside a common folder.
/etc/autofs/auto.master
/- /etc/autofs/auto.template
/etc/autofs/auto.template
/path/to/folder -options :/device/path /home/user/usbstick -fstype=auto,async,nodev,nosuid,umask=000 :/dev/sdb1
- Open the file
/etc/nsswitch.conf
and add an entry for automount:
automount: files
- テンプレートの設定が完了したら (下を参照)、root で
autofs.service
を有効化・起動して AutoFS デーモンを起動してください。
Devices are now automatically mounted when they are accessed, they will remain mounted as long as you access them.
リムーバルメディア
- Open
/etc/autofs/auto.misc
to add, remove or edit miscellaneous devices. For instance:
/etc/autofs/auto.misc
#kernel -ro ftp.kernel.org:/pub/linux #boot -fstype=ext2 :/dev/hda1 usbstick -fstype=auto,async,nodev,nosuid,umask=000 :/dev/sdb1 cdrom -fstype=iso9660,ro :/dev/cdrom #floppy -fstype=auto :/dev/fd0
If you have a CD/DVD combo-drive you can change the cdrom
line with -fstype=auto
to have the media type autodetected.
NFS ネットワークマウント
AutoFS provides a new way of automatically discovering and mounting NFS-shares on remote servers (the AutoFS network template in /etc/autofs/auto.net
has been removed in autofs5). To enable automatic discovery and mounting of network shares from all accessible servers without any further configuration, you will need to add the following to the /etc/autofs/auto.master
file:
/net -hosts --timeout=60
Each host name needs to be resolveable, e.g. the name an IP address in /etc/hosts
or via DNS and please make sure you have nfs-utils installed and working. You also have to enable RPC (systemctl start|enable rpcbind) to browse shared Folders.
For instance, if you have a remote server fileserver (the name of the directory is the hostname of the server) with an NFS share named /home/share, you can just access the share by typing:
# cd /net/fileserver/home/share
The -hosts
option uses a similar mechanism as the showmount
command to detect remote shares. You can see the exported shares by typing:
# showmount <servername> -e
Replacing <servername> with the name of your own server.
An alternative Way is to use the automount-service from Systemd, see NFS with systemd-automount
NFS の手動設定
To mount a NFS share on server_name called /srv/shared_dir to another computer named client_pc at location /mnt/foo, edit auto.master and create a config file for the share (auto.server_name):
/etc/autofs/auto.master
/mnt /etc/autofs/auto.server_name --timeout 60
/etc/autofs/auto.server_name
foo -rw,soft,intr,rsize=8192,wsize=8192 server_name:/srv/shared_dir
Samba
The Arch package does not provide any Samba or CIFS templates/scripts (23.07.2009), but the following should work for single shares:
Add the following to /etc/autofs/auto.master
:
/media/[my_server] /etc/autofs/auto.[my_server] --timeout=60 --ghost
where --timeout
defines how many seconds to wait before the file system is unmounted. The --ghost
option creates empty folders for each mount-point in the file in order to prevent timeouts, if a network share cannot be contacted.
Next create a file /etc/autofs/auto.[my_server]
[any_name] -fstype=cifs,[other_options] ://[remote_server]/[remote_share_name]
You can specify a user name and password to use with the share in the other_options
section:
[any_name] -fstype=cifs,username=[username],password=[password],[other_options] ://[remote_server]/[remote_share_name]
FTP と SSH (FUSE を使用)
リモートの FTP や SSH サーバーには FUSE (仮想ファイルシステムレイヤー) と AutoFS でシームレスにアクセスすることができます。
リモート FTP
まず、curlftpfs パッケージをインストールしてください。
fuse
モジュールをロード:
# modprobe fuse
システムが起動するたびにモジュールがロードされるように /etc/modules-load.d/fuse.conf
ファイルを作成して fuse
と記述してください。
そして、/etc/autofs/auto.master
に FTP サーバーのエントリを追加します:
/media/ftp /etc/autofs/auto.ftp --timeout=60
/etc/autofs/auto.ftp
ファイルを作成して ftp://myuser:mypassword@host:port/path
の形式でサーバーを追加してください:
servername -fstype=curl,rw,allow_other,nodev,nonempty,noatime :ftp\://myuser\:mypassword\@remoteserver
If you want slightly more security you can create the file ~root/.netrc
and add the passwords there.
Passwords are still plain text, but you can have mode 600, and df
command will not show them (mounted or not).
This method is also less sensitive to special characters (that else must be escaped) in the passwords. The format is:
machine remoteserver login myuser password mypassword
The line in /etc/autofs/auto.ftp
looks like this without user and password:
servername -fstype=curl,allow_other :ftp\://remoteserver
Create the file /sbin/mount.curl
with this code:
/sbin/mount.curl
#! /bin/sh curlftpfs $1 $2 -o $5,disable_eprt
Create the file /sbin/umount.curl
with this code:
/sbin/umount.curl
#! /bin/sh fusermount -u $1
Set the permissions for both files:
# chmod 755 /sbin/mount.curl # chmod 755 /sbin/umount.curl
After a restart your new FTP server should be accessible through /media/ftp/servername
.
リモート SSH
These are basic instructions to access a remote filesystem over SSH with AutoFS.
sshfs パッケージをインストールしてください。
fuse
モジュールをロード:
# modprobe fuse
システムが起動するたびにモジュールがロードされるように /etc/modules-load.d/fuse.conf
ファイルを作成して fuse
と記述してください。
openssh をインストールしてください。
SSH 鍵を生成:
$ ssh-keygen
When the generator ask for a passphrase, just press ENTER
. Using SSH keys without a passphrase is less secure, yet running AutoFS together with passphrases poses some additional difficulties which are not (yet) covered in this article.
Next, copy the public key to the remote SSH server:
$ ssh-copy-id username@remotehost
As root, see that you can login to the remote server without entering a password:
# ssh username@remotehost
Create a new entry for SSH servers in /etc/autofs/auto.master
:
/media/ssh /etc/autofs/auto.ssh --timeout=60
Create the file /etc/autofs/auto.ssh
and add an SSH server:
/etc/autofs/auto.ssh
servername -fstype=fuse,rw,allow_other,IdentityFile=/home/username/.ssh/id_rsa :sshfs\#username@host\:/
After a restart your SSH server should be accessible through /media/ssh/servername
.
MTP
Android デバイスでは Media Transfer Protocol (MTP) が使われます。
mtpfs パッケージをインストールしてください。
/etc/autofs/auto.misc
に MTP デバイスのエントリを追加:
android -fstype=fuse,allow_other,umask=000 :mtpfs
トラブルシューティング
このセクションでは AutoFS に関するよくある問題の解決方法を載せています。
NIS を使用
AutoFS のバージョン 5.0.5 には NIS の高度なサポートが含まれています。AutoFS で NIS を使うには、/etc/autofs/auto.master
でテンプレートの名前の前に yp:
を追加してください:
/home yp:auto_home --timeout=60 /sbtn yp:auto_sbtn --timeout=60 +auto.master
バージョン 5.0.5 以前の NIS を使っている場合、/etc/nsswitch.conf
に nis
を追加してください:
automount: files nis
任意のパラメータ
You can set parameters like timeout
systemwide for all AutoFS media in /etc/default/autofs
:
- Open the
/etc/default/autofs
file and edit theOPTIONS
line:
OPTIONS='--timeout=5'
- To enable logging (default is no logging at all), uncomment and add
--verbose
to theOPTIONS
line in/etc/default/autofs
e.g.:
OPTIONS='--verbose --timeout=5'
After restarting the autofs
daemon, verbose output is visible in systemctl status
or in journalctl
.
複数のデバイスを認識
USB ドライブ/スティックを複数使用する場合、AutoFS を使ってマウントポイントを設定して Udev で USB ドライブごとに名前を付けることができます。Udev ルールの設定方法については udev#固定デバイス名の設定 を見て下さい。
AutoFS のパーミッション
If AutoFS is not working for you, make sure that the permissions of the templates files are correct, otherwise AutoFS will not start. This may happen if you backed up your configuration files in a manner which did not preserve file modes. Here are what the modes should be on the configuration files:
- 0644 - /etc/autofs/auto.master
- 0644 - /etc/autofs/auto.media
- 0644 - /etc/autofs/auto.misc
- 0644 - /etc/conf.d/autofs
In general, scripts (like previous auto.net
) should have executable (chmod a+x filename
) bits set and lists of mounts should not.
If you are getting errors in /var/log/daemon.log
similar to this, you have a permissions problem:
May 7 19:44:16 peterix automount[15218]: lookup(program): lookup for petr failed May 7 19:44:16 peterix automount[15218]: failed to mount /media/cifs/petr
fusermount の問題
With certain versions of util-linux, you may not be able to unmount a fuse file system drive mounted by autofs, even if you use the "user=" option. See the discussion here: http://fuse.996288.n3.nabble.com/Cannot-umount-as-non-root-user-anymore-tp689p697.html
AutoFS の代替
- Systemd は必要に応じてファイルシステムを自動マウントすることができます。説明は Fstab#systemd で自動マウント を、例は Sshfs#必要に応じてマウント を見て下さい。
- Thunar Volume Manager は Thunar ファイルマネージャの自動マウントシステムです。
- PCManFM はリモート共有にアクセスすることができる軽量なファイルマネージャです。
- Udisks は最小主義の自動ディスクマウントサービスです。
参照
- AutoFS で FTP と SFTP を使用する方法は Gentoo Wiki の記事を元にしています: https://web.archive.org/web/20130414074212/http://en.gentoo-wiki.com/wiki/Mounting_SFTP_and_FTP_shares
- SSH に関する詳細は SSH や SSH 鍵のページを見て下さい。