Memory requirement to build Linux Server

Added by molator about 8 years ago

As i discovered on my poor PC, about 1280Mo of RAM is required to build the Linux Server.
It includes the RAM used by the kernel and the Linux Services.

What can you do if you lack of memory ?
Create a temporary swap file.

sudo dd if=/dev/zero of=/mnt/512Mb.swap bs=1M count=512

of=name_of_the_swap_file
bs=size_of_a_block
count=number_of_blocks

The swap size is equal to bs * count.
1M * 512 = 512M in that example.

Change count value as you need

sudo mkswap /mnt/512Mb.swap

sudo swapon /mnt/512Mb.swap

The swap file is added to the swap partition.


Replies (2)

RE: Memory requirement to build Linux Server - Added by kervala about 8 years ago

Hehe, personally I don't like swap partitions under Linux, so I create swap files instead :) That's working fine.

RE: Memory requirement to build Linux Server - Added by Minthos about 8 years ago

Alternative remedies:

Tell the build system to use temporary files instead of pipes, by having it omit "-pipe" from the build flags. I don't know how much memory this saves.
Tell make to not launch any parallel jobs by removing -j2 or setting it to -j1. If you only have one CPU core, this won't slow the compile down much (might actually speed it up due to less swapping). (Conversely, if you have many cores and lots of memory, you should set a higher -j number to speed up compilation).
Read this: http://hostingfu.com/article/compiling-with-gcc-on-low-memory-vps

(1-2/2)