There are times when we become anxious about our RAM space. However, it is not easy to physically increase the RAM, especially if you have already used up all the memory slots! In such cases, the best alternative is to increase the swap space. There are several methods to modify the swap space, and here I am going to share a method I found on DBA Genesis1 that doesn’t require rebooting your machine. I have successfully increased the swap space on my Oracle Linux 9 machine, and this method should work well for most other distributions.
The process is straightforward. Just use the dd command to allocate a specified space for the increased swap space and then attach the newly allocated swap space to the swap partition.
For example, if I want to add 2GB of swap space to my machine, I start by switching to the root or Administrator user:
1su
then copy
and convert
the space
1dd if/dev/zero of=/swapfilenew bs=1024 count=2097152
Note the size here is in MB, so a conversion from GB to MB is required.
Then, change the permissions,
1chmod 600 /swapfilenew
2mkswap /swapfilenew
3swapon /swapfile1new
Then modify fstab
(file system table)
1vim /etc/fstab
append the description of the newly allocated swapfilenew
1/swapfilenew swap swap defaults 0 0
Now, the swap space is ready to use! You can check it in the system monitor
or by viewing the /proc/swaps
file.
However, I must note that the dd command can sometimes be dangerous. If a reboot is available, an alternative method is to use GParted. Create a live USB of GParted, boot from the live USB, enter the GUI, and perform the necessary modifications.
1 For more information, please see Arun Kumar’s post here.
Comments