4 ms·
Is there a reason why it is required to fill the swapfile with zeroes here? Normally you'd see something like "dd of=/swapfile bs=1G seek=3 count=0", creating a
by jstimpfle 4y ago
Is there a reason why it is required to fill the swapfile with zeroes here? Normally you'd see something like "dd of=/swapfile bs=1G seek=3 count=0", creating a file of size 3G but with no space allocated (yet). It's much quicker to complete the setup this way.
- wongarsu 4y agoI assume if you force the file system to allocate inodes you are likely to have a less fragmented file than if you create a sparse file that gets inodes assigned over time when each part is used.
- theblazehen 4y agoWhich won't matter on SSDs
- wongarsu 4y agoOn all the benchmarks of SSDs I've seen they perform 1.5 to 4 times better on sequential reads than on random reads. That's a much better ratio than HDDs, but still enough to care about it. You're also likely to get less write amplification if your swap file is continuous. Of course with all the layers of indirection it's a numbers game, you don't know if your file system allocates adjacent inodes, and you don't know how your SSD will remap the blocks. But all else being equal, trying to make the file as sequential as possible seems preferable.
- olddustytrail 4y agoInteresting guess but wrong I'm afraid :) It's simply because it's an easy way to create a file of a certain size that most Linux users would be familiar with. The quicker way (and possibly more "proper" way) is to use fallocate, but who has even heard of that vs dd ?