3 ms·
> I realised an extra benefit: you can make it a sparse file, so it never even uses disk space at all until you actually need it, which could be never. AFAIK,
by cesarb 6y ago
> I realised an extra benefit: you can make it a sparse file, so it never even uses disk space at all until you actually need it, which could be never.
AFAIK, this cannot work. The swap code does not go through the filesystem, it bypasses the filesystem (it only asks the filesystem code for the swap file extents during the "swapon" call), and it's the filesystem that would be responsible for allocating disk space when writing to a sparse file.
- asymptosis 6y agoI don't think I follow. Check it out: $ du /swapfile 329696 /swapfile $ du --apparent-size /swapfile 33554432 /swapfile Looks to me like it's behaving as expected?