mur*_*uru 12
看起来 Linux 不支持动态交换文件大小调整(无论如何,我无法检测到交换文件在没有swapoff/ 的情况下更改了大小swapon)。
据推测,在编写支持它的代码时,更容易假设交换文件不会动态更改文件大小。我也看不出它有什么大用处。由于您可以使用多个交换文件,因此没有什么可以阻止您根据需要创建更多交换文件。
还要注意从本段的swapon手册页:
The swap file implementation in the kernel expects to be able to write
to the file directly, without the assistance of the filesystem. This
is a problem on preallocated files (e.g. fallocate(1)) on filesystems
like XFS or ext4, and on copy-on-write filesystems like btrfs.
Run Code Online (Sandbox Code Playgroud)
我认为同样的问题适用于动态大小的交换文件。