Question

Keep Receiving Message: Invalid Option

Posted October 7, 2014 2.8k views

I am trying to use the command fallocate to create a swapfile for memory purposes. Every time I use the command: sudo fallocate -1 2G /swapfile, the message I get back is: fallocate: invalid option – ‘1’.

How do I resolve this problem?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
2 answers

Replace -1 with -l (a lowercase L):

       -l, --length length
              Specifies the length of the allocation, in bytes.

So the command should be:

sudo fallocate -l 2G /swapfile

Hello, all

You can follow the steps on how to do that here:

https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-20-04

Hope that this helps!
Regards,
Alex

by Brian Boucheron
One way to guard against out-of-memory errors in applications is to add some swap space to your server. In this guide, we will cover how to add a swap file to an Ubuntu 20.04 server.
Submit an Answer