Hi all,
Recently we got a feedback on our tutorial - https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-centos-7
It stated the following :
sudo swapon /swapfile swapon failed: invalid argument
Shout out to @Vault108 for pointing this out! I want to confirm we are in the process of updating the tutorial to avoid this error
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Accepted Answer
This error is created due to the usage of fallocate in the article.
The problem with fallocate is that it uses filesystem ioctls to make the allocation fast and effective, the disadvantage is that it does not physically allocate the space but swapon(2) syscall requires a real space.
To move forward with this, replace the command that uses fallocate the create the file with this:
sudo dd if=/dev/zero of=/myswap count=4096 bs=1MiB
Once you do, follow every step of the tutorial as it’s written.
Thanks again to @Vault108 for mentioning this!
Regards, KDSys
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.