swapon: swapfile has holes

Josh Sherman
1 min read
Linux Arch Linux

While I do absolutely adore Arch Linux, it wouldn’t be Arch without running an upgrade and having a problem crop up out of no where.

This time around, the issue showed up after a reboot when I saw the following error scroll past before I was presented with the GNOME login screen:

swapon: swapfile has holes

Holes? Like the critically acclaimed kids drama starring America’s sweetheart Shia LaBeouf?

Not quite.

Turns out whatever had recently been updated had decided that a swapfile that was created with fallocate was deemed unsuitable for use and thus, has “holes”.

So what’s the fix? Easy enough, you just need to re-create your swapfile using dd instead of fallocate:

# Turn off and remove your existing swapfile:
swapoff /swapfile
rm /swapfile

# Make a new swapfile with dd (adjust the count to fit your needs):
dd if=/dev/zero of=/swapfile bs=1M count=32768 status=progress

# Set the right permissions and make it so:
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile

Note: Those commands aren’t Arch specific, they should work on other Linux distributions as well.

Assuming everything is already setup in your fstab from your hole-filled swapfile and you used the same name and location, you should be off to the races.

To double check things, you can run swapon --show which should show your swapfile listed.

If you happen to use your swapfile for hibernation the way I do, you will need to tweak a few additional things to get the new offset value for your swapfile. Fortunately, I’ve already outlined these steps in another post.

Join the Conversation

Good stuff? Want more?

Weekly emails about technology, development, and sometimes sauerkraut.

100% Fresh, Grade A Content, Never Spam.

About Josh

Husband. Father. Pug dad. Musician. Founder of Holiday API, Head of Engineering and Emoji Specialist at Mailshake, and author of the best damn Lorem Ipsum Library for PHP.

Currently Reading

Parasie Eve

Previous Reads

Buy Me a Coffee Become a Sponsor

Related Articles