How much linux swap size




















File systems and LVM2 volumes assigned as swap space cannot be in use when being modified. For example, no system processes can be assigned the swap space, as well as no amount of swap should be allocated and used by the kernel. The best way to achieve swap space modifications is to boot your system in rescue mode, and then follow the instructions for each scenario in the remainder of this chapter. When prompted to mount the file system, select Skip.

What is Swap Space? Adding Swap Space 5. Adding Swap Space. Sometimes it is necessary to add more swap space after installation. It might be advantageous to increase the amount of swap space to 4 GB if you perform memory-intense operations or run applications that require a large amount of memory.

You have three options: create a new swap partition, create a new swap file, or extend swap on an existing LVM2 logical volume. It is recommended that you extend an existing logical volume. By default, Red Hat Enterprise Linux 7 uses all available space during installation. If this is the case with your system, then you must first add a new physical volume to the volume group used by the swap space.

After adding additional storage to the swap space's volume group, it is now possible to extend it. Procedure To test if the swap logical volume was successfully extended and activated, inspect active swap space:. To test if the swap logical volume was successfully created and activated, inspect active swap space:. Creating a Swap File. I install SAR on every system I work on and use it for post-repair forensic analysis.

Many years ago, the rule of thumb for the amount of swap space that should be allocated on the hard drive was 2X the amount of RAM installed in the computer of course, that was when most computers' RAM was measured in KB or MB. This rule took into account the facts that RAM sizes were typically quite small at that time and that allocating more than 2X RAM for swap space did not improve performance. With more than twice RAM for swap, most systems spent more time thrashing than actually performing useful work.

RAM has become an inexpensive commodity and most computers these days have amounts of RAM that extend into tens of gigabytes. When dealing with computers having huge amounts of RAM, the limiting performance factor for swap space is far lower than the 2X multiplier. The Fedora 28 online Installation Guide, which can be found online at Fedora Installation Guide , defines current thinking about swap space allocation.

I have included below some discussion and the table of recommendations from that document. The following table provides the recommended size of a swap partition depending on the amount of RAM in your system and whether you want sufficient memory for your system to hibernate.

The recommended swap partition size is established automatically during installation. To allow for hibernation, however, you will need to edit the swap space in the custom partitioning stage. At the border between each range listed above for example, a system with 2 GB, 8 GB, or 64 GB of system RAM , use discretion with regard to chosen swap space and hibernation support.

If your system resources allow for it, increasing the swap space may lead to better performance. Of course, most Linux administrators have their own ideas about the appropriate amount of swap space—as well as pretty much everything else.

Table 2, below, contains my recommendations based on my personal experiences in multiple environments. These may not work for you, but as with Table 1, they may help you get started. One consideration in both tables is that as the amount of RAM increases, beyond a certain point adding more swap space simply leads to thrashing well before the swap space even comes close to being filled.

If you have too little virtual memory while following these recommendations, you should add more RAM, if possible, rather than more swap space. As with all recommendations that affect system performance, use what works best for your specific environment.

This will take time and effort to experiment and make changes based on the conditions in your Linux environment. Due to changing requirements for swap space on hosts with Linux already installed, it may become necessary to modify the amount of swap space defined for the system. This procedure can be used for any general case where the amount of swap space needs to be increased.

It assumes sufficient available disk space is available. For safety's sake, before turning off swap, at the very least you should ensure that no applications are running and that no swap space is in use. The free or top commands can tell you whether swap space is in use.

To be even safer, you could revert to run level 1 or single-user mode. This displays the current partition tables on each drive. Identify the current swap partition by number. Use the fdisk p sub-command to verify that there is enough free space on the disk to create the new swap partition. The space on the hard drive is shown in terms of byte blocks and starting and ending cylinder numbers, so you may have to do some math to determine the available space between and at the end of allocated partitions.

Use the n sub-command to create a new swap partition. By default, it chooses the lowest-numbered available cylinder. If you wish to change that, type in the number of the starting cylinder. The fdisk command now allows you to enter the size of the partitions in a number of formats, including the last cylinder number or the size in bytes, KB or MB. Type in M, which will give about 4GB of space on the new partition for example , and press Enter.

Use the p sub-command to verify that the partition was created as you specified it. Note that the partition will probably not be exactly what you specified unless you used the ending cylinder number. The fdisk command can only allocate disk space in increments on whole cylinders, so your partition may be a little smaller or larger than you specified.

If the partition is not what you want, you can delete it and create it again. Now it is necessary to specify that the new partition is to be a swap partition. The sub-command t allows you to specify the type of partition. So enter t , specify the partition number, and when it asks for the hex code partition type, type 82, which is the Linux swap partition type, and press Enter.

When you are satisfied with the partition you have created, use the w sub-command to write the new partition table to the disk. The fdisk program will exit and return you to the command prompt after it completes writing the revised partition table. You will probably receive the following message as fdisk completes writing the new partition table:. At this point, you use the partprobe command to force the kernel to re-read the partition table so that it is not necessary to perform a reboot.

Now use the command fdisk -l to list the partitions and the new swap partition should be among those listed. The existing line may look like this:. Add a new line that looks similar this, depending upon the location of your new swap partition:.



0コメント

  • 1000 / 1000