An introduction to swap space on Linux systems - linux training
An introduction to swap space on Linux systems
Learn how to adjust the amount of swap space applicable on your Linux system, and how much you actually need.
Swap space is a simple aspect of computing today, regardless of operating system. Linux benefits swap space to boost the amount of virtual memory applicable to a host. It can use one or extra dedicated swap partitions or a swap file on a daily filesystem or logical volume.
More Linux resources
A typical computer has two basic types of memory. The first type of random access memory (RAM) it is used to store data and programs while they are actively used by the computer.Computer programs and data can not be used until they are stored in RAM. Ram is volatile memory; That is, if the computer is locked then the data stored in the RAM will be lost.
Hard drives are used for long-term storage of magnetic media data and programs. Magnetic media is non-volatile; data is stored on disk residues, even when powered off from the computer.The CPU (central processing unit) cannot straight access the programs and data on the hard drive; it must be copied into RAM first, and that is where the CPU can access its programming information and the data to be operated on by those guidance. During the boot process, a computer copies special operating system programs, such as the kernel and init or systems, and data from the hard drive into RAM, where it is accessed precisely by the computer’s processor, the CPU.
Swap space
Swap space is the second type of memory in stylish Linux systems. The primary function of swap space is to substitute disk space for RAM memory when actual RAM fills up and more space is required.
For example, consider you have a computer system with 8GB of RAM. If you start up programs that don’t fill that RAM, all is fine and no swapping is needed. But think the spreadsheet you are working on grows when you add more rows, and that, plus all else that's running, now fills all of RAM. Without swap space feasible, you would have to pause working on the spreadsheet until you could free up some of your RAM by closing down some other programs.
The kernel uses a memory authority program that detects blocks, aka pages, of memory in which the contents have not been used newly. The memory management program swaps sufficient of these relatively rarely used pages of memory out to a specific partition on the hard drive exactly designated for “paging,” or swapping. This frees up RAM and cause room for more data to be entered into your spreadsheet. Those pages of memory swapped out to the hard drive are tracked by the kernel memory management code and can be paged back into RAM if they are required.
The overall amount of memory in a Linux computer is the RAM plus swap space and is assign to as virtual memory.
Types of Linux swap
Linux produce two types of swap space by default, more Linux installations build a swap partition, but it is also possible to use a specifically configured file as a swap file. A swap partition is just what its name implies—a standard disk partition that is label as swap space by the mkswap command.
A swap file can be used if there is no free disk space in which to design a new swap partition or space in a volume group where a logical volume can be build for swap space. This is just a daily file that is created and preallocated to a specified size.Then run the mkswap command to configure it as a swap space. I do not recommend using files for swap space until absolutely necessary.
Thrashing
Thrashing can occur when overall virtual memory, both RAM and swap space, become virtually full. The system absorb so much time paging blocks of memory between swap space and RAM and back that little time is left for real work. The typical symptoms of this are available: The system becomes slow or fully unresponsive, and the hard drive activity light is on actually constantly.
If you can manage to matter a command like free that shows CPU load and memory usage, you will see that the CPU load is very high,At CPU cores in the system the number perhaps as much as 30 to 40 times.
Another symptom is that both RAM and swap space are virtually completely absolutely allocated.
After the fact, see at SAR (system activity report) data can also show these symptoms.I install SAR on various system I work on and use it for post-repair forensic analysis.
0 comments:
Post a Comment