3 ms·
Out of curiosity, do you know the functional difference between a swap file and a swap partition? A swap file seems like quite a bit more added complexity with
by j-james 6y ago
Out of curiosity, do you know the functional difference between a swap file and a swap partition? A swap file seems like quite a bit more added complexity with very few benefits.
- gvb 6y agoThe 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