No Title[an error occurred while processing this directive]
Reference: Cisco: Internetworking Basics
Similar to all Unix-like operating systems, Linux uses a virtual memory system which is an addressing schema that uses non-volatile disk storage (swap space) as an extension of physical RAM. This is used so that the effective size of usable memory can grow as demand for memory increases. A process known as swapping copies inactive pages of RAM to a reserved swap file or swap partition in order to free up physical memory for other user processes. The swap space can contain one or more swap files or swap partitions. The amount of virtual memory available is the sum of the physical RAM and the swap space. If no swap space is available, user processes would be limited to the amount of physical memory available on the machine.
In the past, swap space needed to be configured as a separate swap partition either during installation or later by the system administrator. With Linux kernel 2.6, swap files can be used for swap space and are known to be just as fast as swap partitions. Although many system administrators still recommend using a swap partition, creating swap files is an efficient and quick method to increase the amount of virtual memory on a machine without the need to use a raw device or even worse, reformat a hard disk. For example, swap space may need to be added to increase system performance or to successfully install the Oracle Database software. Provided there is adequate space on an existing file system, the swap space can be increased without the need for an outage by creating a swap file.
This guide provides instructions on how to add additional swap space to a Linux system by adding a swap file using command-line options.
The Linux system used in this example is currently not configured with any swap space.
Use the dd command to create a new file that will be configured later as a swap file. The following example creates a 4GB file named /mnt/swap/swapfile1.
Create a Linux swap area within the swap file.
For security purposes, set the appropriate permissions on the swap file. Only root should be able to read and write to the swap file.
Finally, activate the swap file which immediately adds it to the swap space.
Verify the new swap space.
The procedure document above will only enable the new swap file until the next reboot of the system. To activate the swap file after each system reboot, add the following entry to the /etc/fstab file.
Jeffrey Hunter is an Oracle Certified Professional, Java Development Certified Professional, Author, and an Oracle ACE. Jeff currently works as a Senior Database Administrator for The DBA Zone, Inc. located in Pittsburgh, Pennsylvania. His work includes advanced performance tuning, Java and PL/SQL programming, developing high availability solutions, capacity planning, database security, and physical / logical database design in a UNIX / Linux server environment. Jeff's other interests include mathematical encryption theory, tutoring advanced mathematics, programming language processors (compilers and interpreters) in Java and C, LDAP, writing web-based database administration tools, and of course Linux. He has been a Sr. Database Administrator and Software Engineer for over 20 years and maintains his own website site at: http://www.iDevelopment.info. Jeff graduated from Stanislaus State University in Turlock, California, with a Bachelor's degree in Computer Science and Mathematics.
Copyright (c) 1998-2018 Jeffrey M. Hunter. All rights reserved.
All articles, scripts and material located at the Internet address of http://www.idevelopment.info is the copyright of Jeffrey M. Hunter and is protected under copyright laws of the United States. This document may not be hosted on any other site without my express, prior, written permission. Application to host any of the material elsewhere can be made by contacting me at email@example.com.
I have made every effort and taken great care in making sure that the material included on my web site is technically accurate, but I disclaim any and all responsibility for any loss, damage or destruction of data or any other property which may arise from relying on it. I will in no case be liable for any monetary damages arising from such loss, damage or destruction.
Last modified on
Wednesday, 03-Oct-2012 18:13:46 EDT
Page Count: 6478