Score:1

How to solve error on swap creation: "skipping - it appears to have holes." (Ubuntu 22.04)

my flag

I am trying to create 1GB swap file without success on my Ubuntu 22.04.

I use the following commands:

sudo rm /swapfile1
sudo dd if=/dev/zero of=/swapfile1 bs=1KB count=1MB status=progress
sudo chmod 0600 /swapfile1
sudo mkswap /swapfile1
sudo swapon /swapfile1

The output I get:

905663000 bytes (906 MB, 864 MiB) copied, 5 s, 181 MB/s
1000000+0 records in
1000000+0 records out
1000000000 bytes (1.0 GB, 954 MiB) copied, 5.46825 s, 183 MB/s

Setting up swapspace version 1, size = 953.7 MiB (999993344 bytes)
no label, UUID=4c4c204b-57ff-484d-848b-d719e0260156

swapon: /swapfile1: skipping - it appears to have holes.

Context

When looking at my free space, I see:

$ df /
Filesystem               1K-blocks      Used Available Use% Mounted on
rpool/ROOT/ubuntu_emx73f 879401216 225886848 653514368  26% /

Note that I use the Full Disk Encryption of Ubuntu (not sure if this is relevant)

Also, replacing dd with fallocate does not solve the problem

FedKad avatar
cn flag
Are you using ZFS file system? Does this help? https://askubuntu.com/a/1203843/855322
waltinator avatar
it flag
swap files MUST be contiguous (block N on the physical disk must be followed by block N+1). Did you `rm /swapfile` before you tried `fallocate`? It would help us help you if you showed the `fallocate` command, and its result. Please [edit] your question to add whatever information you get. Don't use Add Comment, or you'll classify yourself as "Does Not Follow Instructions (DNFI)", and I'll ignore you. I view DNFIs as unhelpable.
David Taub avatar
my flag
Waltinator, your comment is unnecessarily aggressive
Score:1
my flag

Credit to FedKad that pointed me to Stratus's answer.

What solved the issue:

sudo zfs create -V 1G -b 8192 -o logbias=throughput -o sync=always -o primarycache=metadata -o com.sun:auto-snapshot=false rpool/swap
sudo mkswap -f /dev/zvol/rpool/swap
sudo swapon /dev/zvol/rpool/swap
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.