When getting an invalid argument error when doing swapon /swapfile (for instance) it might be due to the underlying filesystem being btrfs. In this case you need to do the following steps:

# truncate -s 0 swapfile
# chattr +C swapfile
# fallocate -l 2G swapfile
# chmod 0600 swapfile
# mkswap swapfile
# swapon swapfile

Since version 6.1 of the btrfs tooling it’s possible to create the swapfile in a single command (except the activation):

# btrfs filesystem mkswapfile --size 2G swapfile
# swapon swapfile

All commands need root permissions (so either with root account or via sudo)

Generating swap file on btrfs filesystem

Johannes Rest


.NET Architekt und Entwickler


Beitragsnavigation


Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert