Matt Jones Tech
  • Blog
  • Video Projects
  • Web Projects
  • How to Add Swap in Manjaro

    How to Add Swap in Manjaro

    Hey guys! If you’re hear, you probably already know what RAM is and you’re excited to learn how to add swap in Manjaro. If not, this is sort of a follow-up post to how to download more RAM. Anyway, let’s get started!

    Using a Swap File

    There’s a ton of different ways to add swap to your system, some more advantageous than others. In my experience, it’s always been easier to add swap to an existing install by using a swap file. First, just confirm that you don’t already have swap enabled. To do this, just run sudo swapon. If that command does not return any output, then you don’t have swap enabled. Also, if you have and/or use htop, it will actually display your swap status right below your RAM usage bar. if it reads empty and 0/0kb, then you don’t have swap enabled. Great! Now we can add a swap file.

    Creating and initializing a new swap file

    To create an initialize a new swap file, we’ll be using the fallocate command. To initialize a 16GB swap file just run the following in a terminal:

    sudo fallocate -l 16G /swapfile

    then run: sudo mkswap /swapfile

    Setting permissions for your new swap file

    Manjaro will likely give you a warning about changing the permissions of your swap file. You can change permissions using the chmod command. The swap file should only be readable and writable by the root.

    sudo chmod 0600 /swapfile

    Enabling your new swap file

    Enable your new swap file by running the following:

    sudo swapon /swapfile

    Make your changes permanent

    Make sure Manjaro knows to use your swap file every single time it boots up. Do this by running:

    sudo bash -c "echo /swapfile none swap defaults 0 0 >> /etc/fstab"

    And that’s it! The only thing left to do is reboot and just double check to see if your swap is up and running. Again, you can just run those commands from the beginning of the tutorial swapon or htop and you should be good to go! Happy blending!

    matt

    January 8, 2020
    Blender, General Computing, Linux
    Blender, general com, linux, manjaro, RAM, swap memory

Prove all things; hold fast that which is good. 1 Thess 5:21