Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230
Do you really need a 4-TB swap file ?
A swap file must not have holes because the kernel needs to map all its blocks to the underlying block device, but the dd command should create a file without holes.
What is the filesystem type for /var ?
The OP's dd command creates a 4-TB swap file, not 4-GB.
swapon and mkswap man pages warn against using fallocate on some filesystems (ext4, xfs) because it can create a file with holes.
To clear up the confusion. I didn't realize this until you guys said something, but I meant 4GB. Not 4TB. I'm not exactly sure what I was thinking when I wrote that part. The file system I'm using is zfs. I ran fallocate as Head_on_a_Stick suggested and I get
fallocate: fallocate failed: Operation not supported
Looks like zfs is another filesystem which does not support Linux swap files, like btrfs and nilfs2.
Linux swap files are broken by design. Do not use them.
Tip : if you really need to create a temporay swap file on an unsupporting filesystem, you can create a loop device with losetup.