While creating a swap on your Linux machine, executing sudo fallocate -l 1G /swap-file-name
may throw fallocate failed: Operation not supported
. Here I’m going to show you a quick fix for it.
Prerequisites
- Linux bash environment
- sudo privileges
Solution
Step 1. One of the reasons for the error is that fallocate
is not installed on your Linux machine. But anyway we can bypass it using another command:
sudo dd if=/dev/zero of=/swap-file-name bs=1024 count=1048576
Step 2. Add the correct permissions.
sudo chmod 600 /swap-file-name
Step 3. Make the file as Linux swap area.
sudo mkswap /swap-file-name
Step 4. Enable it.
sudo swapon /swap-file-name
Step 5. To make the swap permanent open the /etc/fstab
and add the following line:
/swap-file-name swap swap defaults 0 0
Step 6. To check if the swap is active, run:
sudo swapon --show
or:
sudo free -h
source : https://devcoops.com/swap-fallocate-failed-operation-not-supported/