2

I need to run some application to convert large files (7GB). The converter application isn't nicely written. So it doesn't stream the coverted data. Therefore, it requires high amount of memory. I have 8GB memory and 8GB swap space. But the application reports a memory usage of around 9GB and stops at 60% of conversion. I assume with some more memory, I can finish the task. As this needs to be done once only, I can maybe allocate some space from my SSD to extend memory temporarily. Only for this operation. Is there any way to do that without messing with partitions?

Thanks!

1 Answers1

2

You can indeed use swapfile as temporary addition to your system memory. Personally, I have an SSD and use 1 GB swap file for protection instead of having a partition , since it's a compromise between using the limited disk space, but having extra memory if I ever run out of RAM

First create the file itself

sudo dd if=/dev/zero of=/swapfile bs=1M count=1024

The command will create a file named swapfile inside your root folder, its content being all zeroes and size of 1024 megabytes (1 GB). To make it 2 GB , change count value to 2048

Next, make it read-writable by root only

sudo chmod 600 /swapfile

And format it to swap

sudo mkswap /swapfile

Finally, enable the file

sudo swapon /swapfile

You can disable it at any point using sudo swapoff /swapfile command and remove at will; in addition, since here we don't add it to the /etc/fstab file, it won't be added at next boot, so on the next boot you can remove it

FYI, all this I've turned into a script so that there's an actual single command you can execute to add swap. See How can i increase size of swap file?