Red Hat Training

A Red Hat training course is available for RHEL 8

18.8. systemd.automount を使用して、マウントユニットを使用してファイルシステムをオンデマンドでマウントします

この手順は、マウントポイントがマウントユニットによって定義されている場合に、automount systemd ユニットを使用してオンデマンドでファイルシステムをマウントする方法を示しています。マウントごとに自動マウントユニットを追加して有効にする必要があります。

手順

  1. マウントユニットを作成します。以下に例を示します。

    mount-point.mount
    [Mount]
    What=/dev/disk/by-uuid/f5755511-a714-44c1-a123-cfde0e4ac688
    Where=/mount/point
    Type=xfs
  2. マウントユニットと同じ名前で、拡張子が .automount のユニットファイルを作成します。
  3. ファイルを開き、[Automount] セクションを作成します。Where= オプションをマウントパスに設定します。

    [Automount]
    Where=/mount/point
    [Install]
    WantedBy=multi-user.target
  4. システムが新しい設定を登録するように、新しく作成されたユニットをロードします。

    # systemctl daemon-reload
  5. 代わりに、自動マウントユニットを有効にして起動します。

    # systemctl enable --now mount-point.automount

検証

  1. mount-point.automount が実行されていることを確認します。

    # systemctl status mount-point.automount
  2. 自動マウントされたディレクトリーに目的のコンテンツが含まれていることを確認します。

    # ls /mount/point

関連情報

  • systemd.automount(5) man ページ
  • systemd.mount(5) man ページ
  • systemd の管理