1

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

David Taub
  • 133
  • 6

1 Answers1

2

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
David Taub
  • 133
  • 6