Originally Posted by syg00
Why do you think the recommendation for allocation of a swapfile is to use dd ?.
guarantee a contiguous file. It uses normal write(2) calls to fill the file, and the filesystem code in the kernel allocates the blocks wherever it sees fit. Prior to ext4 there was no mechanism for requesting pre-allocation of blocks for a large file, so the allocation was always done in small chunks as the file was written. There is no way
to ensure that a file in an ext2/3/4 filesystem is contiguous, and for files larger than 128MiB it is impossible
for them to be contiguous. There is a maximum of 32768 4K blocks in a block group, and then the allocater has to skip over the next group descriptor and set of inode blocks.
Furthermore, for a non-empty filesystem, it is unlikely that there is any 128MiB block group that is completely empty, and therefore the maximum available contiguous space would be less than
128MiB. (The allocation strategy tries to equalize the usage of the block groups, thus increasing the likelihood that a file's data blocks can be located near the inode that references them.)