スワップを設定するにはmkswapと/etc/fstabが必要なのはなぜですか?

スワップを設定するにはmkswapと/etc/fstabが必要なのはなぜですか?

与えられた

$ cat /etc/fstab
...
/dev/mapper/lubuntu--vg-swap none            swap    sw              0       0

なぜ我々はまだ必要ですか?

$ sudo swapoff /dev/mapper/lubuntu--vg-swap
$ sudo mkswap /dev/mapper/lubuntu--vg-swap
$ sudo swapon /dev/mapper/lubuntu--vg-swap

つまり、なぜ両方を設定し、mkswap交換/etc/fstabを設定する必要がありますか?これらのすべきこととすべきことmkswap/etc/fstab違いは何ですか?

私の質問は以下から来ています。https://unix.stackexchange.com/a/502591/674

ありがとうございます。

ベストアンサー1

jordanmが言ったように、fstabはマウントするファイルシステムと起動時にアクティブになるスワップデバイスに関する情報を含むファイルです。これを手動で実行したくありません。

mountとのマニュアルページを見てくださいswapon

設置(8)

 -a, --all
              Mount all filesystems (of the given types) mentioned in fstab (except for those whose line contains the
              noauto keyword). The filesystems are mounted following their order in fstab.

交換(8)

 -a, --all
              All devices marked as ``swap'' in /etc/fstab are made available, except for those with the ``noauto''
              option. Devices that are already being used as swap are silently skipped.

このコマンドは、デバイスにext4ファイルシステムなどのmkswapスワップデバイスを作成します。mkfs.ext4

おすすめ記事