Re: swapon command error

Matus UHLAR - fantomas <[email protected]> Thu, 9 Sep 2021 19:03:16 +0200
Newsgroups gmane.linux.debian.user.laptop
Message-ID <[email protected]>
On 09.09.21 19:46, lin dimitri wrote:
>I am trying to increase my swap memory, below is the commands I used:-
>$ sudo swapon --show
>$ sudo swapoff -a
>$ sudo fallocate -l 4G /swapfile
>$ sudo chmod 600 /swapfile
>$ sudo mkswap /swapfile
>$ sudo swapon /swapfile
>swapon failed: Function not implemented
>
>i got above error.
>
>I have CONFIG_SWAP=y in /proc/config.gz.
>
>i don't know how this can be solved

from mkswap man page:

       Note  that a swap file must not contain any holes.  Using cp(1) to cre‐
       ate the file is not acceptable.  Neither is use of fallocate(1) on file
       systems  that  support  preallocated  files, such as XFS or ext4, or on
       copy-on-write filesystems like btrfs.  It is recommended to  use  dd(1)
       and  /dev/zero in these cases.  Please read notes from swapon(8) before
       adding a swap file to copy-on-write filesystems.