4 ms·
The kernel cheats: on start up it figures out which sectors the swap file uses (best if it is contiguous on the drive) and doesn't actually use the file system
by gvb 6y ago
The kernel cheats: on start up it figures out which sectors the swap file uses (best if it is contiguous on the drive) and doesn't actually use the file system to read/write swap. This allows it to achieve the same performance for a file as a partition.
The advantage is that files are much easier to change (extend) than a disk partition.
Ref:
https://askubuntu.com/questions/904372/swap-partition-vs-swap-file https://askubuntu.com/questions/904372/swap-partition-vs-swa...
https://askubuntu.com/questions/927854/how-do-i-increase-the-size-of-swapfile-without-removing-it-in-the-terminal https://askubuntu.com/questions/927854/how-do-i-increase-the...
- aidenn0 6y agoHow does that work with log-structured filesystems (or any filesystem that does online defragmentation)?
- m45t3r 6y agoAFAIK it doesn't, it expects a continuous file without fragmentation. On btrfs systems, for example, I have to set a bit to disable COW for the file to be used as a swapfile, otherwise it will not work.
- fomine3 6y agoZFS zvol works as swap even though CoW can't be disabled, how does it work? Edit: I found that zvol is virtual volume so anyway it should be handled by zfs. I also found mention about the bypass mechanism. http://lkml.iu.edu/hypermail/linux/kernel/0507.0/1690.html http://lkml.iu.edu/hypermail/linux/kernel/0507.0/1690.html