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?
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?
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.
sudo fallocate -l XG /swapfile
– C.S.Cameron Feb 03 '23 at 09:28fallocate
the other isdd
.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. – C.S.Cameron Feb 03 '23 at 13:55