Score:1

How to fix swapfile problem having holes - Ubuntu 22.04?

vi flag

I have created a swapfile successfully, but when I am trying to:

"sudo swapon /swapfile" 

this is what I see:

"swapon: /swapfile1: skipping"

It appears to have holes.

How can I create a swapfile that doesn't have a hole?

hr flag
So how exactly did you create the swapfile?
C.S.Cameron avatar
cn flag
@steeldriver: Some people have had a problem with holes when using fallocate to create swapfiles. https://askubuntu.com/a/1285218/43926 `sudo fallocate -l XG /swapfile`
hr flag
@C.S.Cameron hence my question ;)
C.S.Cameron avatar
cn flag
@steeldriver: I only know of two methods to create a swapfile, one is `fallocate` the other is `dd`. `Fallocate` is known to occasionally create holes, `dd` is not. The method using fallocate is given above in my comment, and the method using dd is given in my answer below. Do you have a preferred method to create swapfiles not mentioned? The OP has not confirmed their method.
hr flag
@C.S.Cameron I know far less about it than you - I've upvoted your answer, but unless the OP engages we're spinning our wheels
Score:2
cn flag

Swapfile Holes

There is a slight possibility of getting holes in a swapfile when creating it with fallocate.

/var/log/syslog can be searched for the phrase swapon: swapfile has holes to ensure there will be no data loss.

A swap file can alternatively be created using dd:

sudo dd if=/dev/zero of=/swapfile bs=1G count=8

An error when using dd may overwrite your HDD.

Nathan Nyawaya avatar
vi flag
I am still having the same problem, i tried using both fallocate and dd ...... still getting the error saying there is holes
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.