fstabは自動的にマウントポイントを作成します

Jan 02 2021

ここで述べたように、「パーティションをマウントする前にマウントポイントを作成する必要があります」。しかし、fstabに次の行を追加してシステムを再起動した後

/dev/sdxy /media/user/hdd_mount_point ext4 defaults 0 0
tmpfs /mnt/tmpfs_mount_point tmpfs rw,nosuid,noatime,nodev,size=4G,mode=1777 0 0

マウントポイント(ターゲットディレクトリ)でhdd_mount_pointあり、tmpfs_mount_point存在しない場合は自動的に作成されます。マニュアルページに記載されているように、コマンドにX-mount.mkdirオプションを追加することで、マウントポイントが存在しない場合でもマウントポイントを作成できることは知っていますが、fstabを介してファイルシステムをマウントするときにこのオプションが暗黙的に使用されるかどうかを知りたいです。mount

そしてNO、それはの複製ではないの/ etc / fstabファイルにファイルシステムを追加する自動

回答

3 mook765 Jan 03 2021 at 00:43

そしてここにドキュメントからの重要な部分があります:

Mount units may either be configured via unit files, or via /etc/fstab
(see fstab(5) for details). Mounts listed in /etc/fstab will be converted
into native units dynamically at boot and when the configuration of the
system manager is reloaded. In general, configuring mount points through
/etc/fstab is the preferred approach. See systemd-fstab-generator(8) for
details about the conversion.

さらに下にこれがあります:

Where=

    Takes an absolute path of a file or directory for the mount point;
    in particular,the destination cannot be a symbolic link. If the
    mount point does not exist at the time of mounting, it is created
    as directory.
6 MartinThornton Jan 03 2021 at 00:07

これは以前は真実mountでしたが、今でも古典的なコマンドを使用したい場合はそうです。

近年、のエントリは、オプションの存在に関係なく、必要に応じて欠落しているマウントポイントを自動的に作成/etc/fstabするsystemdによって起動時にマウントされX-mount.mkdirます。

また、マウントするディレクトリを最初に手動で作成せずに、自分でパーティションをマウントしたい場合に備えsystemd-mountて、の代わりにコマンドを提供mountします。