Note that sparse files cannot be used for swap files: dd if=/dev/zero of=swap.img bs=1 count=0 seek=1G mkswap swap.img sudo swapon swap.img swapon: Skipping file /swap.img - it appears to have holes.
Instead, make a full file dd if=/dev/zero of=swap.img bs=1 count=1G mkswap swap.img sudo swapon swap.img