I'm trying to add a new
swapfile to increase Swap Space by following this tutorial.
swapfile creates successfully but, the
swapon command won't accept it: says "skipping - it appears to have holes.".
I'm running Xubuntu 19.10 with ZFS on root.
Here is what I've tried so far:
fallocate - failed
sudo fallocate -l 8G /swapfile fallocate: fallocate failed: Operation not supported
It seems fallocate currently does not support ZFS.
Alternative way - Using
dd - success
sudo dd if=/dev/zero of=/swapfile bs=1MiB count=$((8*1024)) 8192+0 records in 8192+0 records out 8589934592 bytes (8.6 GB, 8.0 GiB) copied, 2.68284 s, 3.2 GB/s
Prepare the Swap File - success
sudo chmod 600 /swapfile ls -lah /swapfile -rw------- 1 root root 8.0G Dec 27 14:15 /swapfile sudo mkswap /swapfile Setting up swapspace version 1, size = 8 GiB (8589930496 bytes) no label, UUID=db8aa64c-734c-4eba-a803-72db681ec1a1
Enable the Swap File - failed
sudo swapon /swapfile swapon: /swapfile: skipping - it appears to have holes.
From swapon manual:
Files with holes
The swap file implementation in the kernel expects to be able to write to the file directly, without the assistance of the filesystem. This is a problem on files with holes or on copy-on-write files on filesystems like Btrfs.
Commands like cp(1) or truncate(1) create files with holes. These files will be rejected by swapon.
Preallocated files created by fallocate(1) may be interpreted as files with holes too depending of the filesystem. Preallocated swap files are supported on XFS since Linux 4.18.
The most portable solution to create a swap file is to use dd(1) and /dev/zero.
How can I create a swapfile on ZFS which the
swapon command would accept?
sudo parted -l Model: WDC PC SN520 SDAPNUW-512G-1002 (nvme) Disk /dev/nvme0n1: 512GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 1049kB 538MB 537MB fat32 EFI System Partition boot, esp 2 538MB 590MB 52.4MB ext4 3 590MB 2738MB 2147MB linux-swap(v1) 4 2738MB 4885MB 2147MB zfs 5 4885MB 512GB 507GB zfs
sudo zpool list -v NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT bpool 1.88G 131M 1.75G - - 0% 6% 1.00x ONLINE - nvme0n1p4 1.88G 131M 1.75G - - 0% 6.82% - ONLINE rpool 472G 112G 360G - - 9% 23% 1.00x ONLINE - nvme0n1p5 472G 112G 360G - - 9% 23.8% - ONLINE
sudo zfs list # https://pastebin.ubuntu.com/p/6jDVwbhfCT/
sudo lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 19.10 Release: 19.10 Codename: eoan
sudo uname -a Linux iCyberRoze 5.3.0-24-generic #26-Ubuntu SMP Thu Nov 14 01:33:18 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux