Server Guide and Blog

Rock Your Linux


Server Memory Setup – To Swap or Not to Swap

For a while I turned off the swap file on my virtual machine. It worked, but then I began to use more php pages and the server began acting funny, especially with database queries. After a day or two of the system crashing I turned on a swap file and the system stability came back real quick. The virtual machine has 1024 megs of ram and 2048 megs of swap and the system appears to be managing memory much better. Review your system performance and status with the top binary.

As for the host, I turned the swap partition back on, but I dont think it is needed. I will try server configurations on my days off this week.


Create a Swap File – Separate Partition is not Needed

Debian, and Ubuntu have an incredibly convenient package that creates a swap file in any directory. Install with:

sudo apt-get install dphys-swapfile

The installation process with automatically create the swap file. Then just enable it with:

sudo swapon -a

Viola, a fully function swap file that is not on a separate partition.


I Love Virtualization

Virtualization is simply the coolest. I currently have 4 linux servers running. I consolidate my mail server in my web server, which takes one virtual machine. Another virtual machine is running a file server. The third is running a VPN for my iPhone. And the last server is running Nagios to monitor the uptime of all my servers. In addition I am concurrently running Windows XP for a program that graphically monitors the visitors to my websites. In the end I am only consuming about 1.5 Gigabytes of ram after all the virtual machines have fully loaded. I can have many many many more virtual machines, given that I have 5 Gigabytes of ram on my PC. This is power. Virtualization is power. The potential is incredible. Not to mention I have 3 hard drives in raid1 to ensure system stability in the case of hardware failure. I am going to set up the following: I want a 4′th hard drive, which I am going to connect via an external SATA port. They call these ports ESATA, which could have been seen a mile away. I am still debating weather to sync the drive via raid, or via rsync. A raid sync will be seamless, whereas rsync will probably consume some computing power. Also if something happens to the software on my PC the raid will copy the corruptions to the backup drive. Using rsync manually would most likely avoid copying corrupted data.