So I'm following a tutorial to install OTRS which is Open source Ticket Request System. So in order to install, it requires: 4GB of Swap space. Here's the command I used:
[root@ip-10-0-7-41 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 50G 14G 37G 27% /
devtmpfs 478M 0 478M 0% /dev
tmpfs 496M 0 496M 0% /dev/shm
tmpfs 496M 13M 484M 3% /run
tmpfs 496M 0 496M 0% /sys/fs/cgroup
tmpfs 100M 0 100M 0% /run/user/1000
[root@ip-10-0-7-41 ~]# fallocate -l 4G /myswap
[root@ip-10-0-7-41 ~]# ls -lh /myswap
-rw-r--r--. 1 root root 4.0G Jul 8 08:44 /myswap
[root@ip-10-0-7-41 ~]# chmod 600 /myswap
[root@ip-10-0-7-41 ~]# mkswap /myswap
Setting up swapspace version 1, size = 4194300 KiB
no label, UUID=3656082a-148d-4604-96fb-5b4604fa5b2e
[root@ip-10-0-7-41 ~]# swapon /myswap
swapon: /myswap: swapon failed: Invalid argument
You can see : Invalid argument error here. I tried many time in vain to enable it.Someone please tell me how to fix this error.
(I'm running this CentOS 7 on AWS Instance EC2)
[root@ip-10-0-7-41 ~]# df -T | awk '{print $1,$2,$NF}' | grep "^/dev"
/dev/xvda1 xfs /
Best Answer
The problem with
fallocate(1)
is that it uses filesystemioctls
to make the allocation fast and effective, the disadvantage is that it does not physically allocate the space butswapon(2)
syscall requires a real space. Reference : https://bugzilla.redhat.com/show_bug.cgi?id=1129205I'd faced this issue earlier with my box too. So instead of using
fallocate
, I useddd
as the link suggestsand moving ahead with
chmod
,mkswap
&swapon
commands. Bingo ! It worked.