• No se han encontrado resultados

Adding and Managing RHEL 6 Swap Space

N/A
N/A
Protected

Academic year: 2018

Share "Adding and Managing RHEL 6 Swap Space"

Copied!
6
0
0

Texto completo

(1)

Adding and Managing RHEL 6 Swap Space

From Techotopia

An important part of maintaining the performance of a Red Hat Enterprise Linux 6 system involves ensuring that adequate swap space is available comparable to memory demands placed on the system. The goal of this chapter, therefore, is to provide an overview of swap management on RHEL 6.

Ads by Google Swap Linux Boot Disk Linux Systems RedHat Linux

0

Previous Table of Contents

Adding a New Disk to an RHEL 6 Volume Group and Logical Volume

Purchase and download the full PDF and ePub versions of this RHEL 6 eBook for only $9.99

PDF/ePub edition contains 40 chapters and over 250 pages.

Contents

1 What is Swap Space?

(2)

What is Swap Space?

Computer systems have a finite amount of physical memory that is made available to the operating system. When the operating system begins to approach the limit of the available memory it frees up space by writing memory pages to disk. When any of those pages are required by the operating system they are subsequently read back into memory. The area of the disk allocated for this task is referred to as swap space.

Recommended Swap Space for RHEL 6

The amount of swap recommended for RHEL 6 depends on a number of factors including the amount of memory in the system and the workload imposed on that memory. The current guidelines for Red Hat Enterprise Linux 6 swap space are as follows:

4GB of RAM requires a minimum of 2GB of swap space 4GB to 16GB RAM requires a minimum of 4GB of swap space 16GB to 64GB of RAM requires a minimum of 8GB of swap space 64GB to 256GB of RAM requires a minimum of 16GB of swap space

Identifying Current Swap Space Usage

The current amount of swap used by an RHEL 6 system may be identified in a number of ways. One option is to cat the /proc/swaps file:

Alternatively, use the swapon command:

Finally, the free command may also be used:

Adding a Swap File to an RHEL 6 System

Additional swap may be added to the system by creating a file and assigning it as swap. Begin by creating the swap file using the dd command (the size can be changed by adjusting the count= variable; the following creates a 131MB file):

Redhat Linux Training Winner 5 RedHat GLS Awards 4000+ Red Hat Certified Students www.networknuts.net

Compare Unix & Linux Provided By Dell India! Minimize distruption In Enterprise www.Dell.com/unixtolinux

Qt Professional Services Qt Consulting, Training and Addons. Development - Migration - Mentoring www.kdab.com

# cat /proc/swaps

Filename Type Size Used Priority /dev/dm-1 partition 2064376 0 -1

Filename Type Size Used Priority /dev/dm-1 partition 2064376 0 -1

# free

total used free shared buffers cached Mem: 1021488 615348 406140 0 199596 160312 -/+ buffers/cache: 255440 766048

(3)

Configure the file as swap:

Add the swap file to the system in real-time:

Finally, modify the /etc/fstab file to automatically add the new swap at system boot time by adding the following line:

Adding Swap to an RHEL 6 LVM Swap Volume

By default, RHEL 6 configures swap space using Logical Volume Management (LVM). An alternative to adding swap via file, therefore, is to extend the logical volume used for the swap.

The first step is to identify the current amount of swap available and the volume group and logical volume used for the swap space (for more information on LVM, refer to the chapter entitled Adding a New Disk to an RHEL 6 Volume Group and Logical Volume):

Clearly the swap resides on logical volume lv_swap which in part of volume group vg_rhel6. The next step is to verify if # dd if=/dev/zero of=/newswap bs=1024 count=128000

128000+0 records in 128000+0 records out

131072000 bytes (131 MB) copied, 1.7639 seconds, 74.3 MB/s

# mkswap /newswap

mkswap: /newswap: warning: don't erase bootbits sectors on whole disk. Use -f to force.

Setting up swapspace version 1, size = 127996 KiB no label, UUID=91588fb6-ac01-47f6-bb42-064c1c7c4599

# swapon /newswap

/newswap swap swap defaults 0 0

# lvdisplay

--- Logical volume ---

LV Name /dev/vg_rhel6/lv_root VG Name vg_rhel6

LV UUID nU70n0-scyi-xp2S-1CNq-GUa1-4Vad-gQKIOO LV Write Access read/write

LV Status available # open 1

LV Size 23.54 GiB Current LE 6026 Segments 2 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0

--- Logical volume ---

LV Name /dev/vg_rhel6/lv_swap VG Name vg_rhel6

LV UUID 5uVonb-SCk2-bedt-4Oj3-LGpq-TpsA-qyCGEl LV Write Access read/write

LV Status available # open 1

(4)

there is any space available on the volume group that can be allocated to swap volume:

If the amount of space available is sufficient to meet additional swap requirements, turn off the swap and extend the swap logical volume to use the additional space:

Next, reformat the swap volume and turn the swap back on:

Having made the changes, check that the swap space as increased:

Adding Swap Space to the Volume Group

In the above section we extended the swap logical volume to use space that was already available in the volume group. If no space is available in the volume group then it will need to be added before the swap can be extended. Begin by checking the status of the volume group:

The above output indicates that no space is available within the volume group. Suppose, however, that we have a requirement to add 2GB to the swap on the system. Clearly, this will require the addition of more space to the volume group. For the purposes of this example it will be assumed that a disk partition that is 2GB is size and represented by /dev/sdb is available for addition to the volume group. The first step is to turn this partition into a physical volume:

Next, the volume group needs to be extended to use this additional physical volume:

At this point the vgs command should report the addition of the 2GB of space to the volume group: # vgs

VG #PV #LV #SN Attr VSize VFree vg_rhel6 2 2 0 wz--n- 47.50g 22.00g

# swapoff /dev/vg_rhel6/lv_swap

# lvextend -L +3GB /dev/vg_rhel6/lv_swap Extending logical volume lv_swap to 4.97 GiB Logical volume lv_swap successfully resized

# mkswap /dev/vg_rhel6/lv_swap

mkswap: /dev/vg_rhel6/lv_swap: warning: don't erase bootbits sectors on whole disk. Use -f to force.

Setting up swapspace version 1, size = 5210108 KiB no label, UUID=acd810b6-6522-43c8-b16d-a3f365288b15 # swapon /dev/vg_rhel6/lv_swap

# swapon -s

Filename Type Size Used Priority /dev/dm-1 partition 5210104 0 -1

# vgs

VG #PV #LV #SN Attr VSize VFree vg_rhel6 1 2 0 wz--n- 8.79g 0

# pvcreate /dev/sdb

Physical volume "/dev/sdb" successfully created

# vgextend vg_rhel6 /dev/sdb

(5)

Now that the additional space is available in the volume group, the swap logical volume may be extended to utilize the space. First, turn off the swap:

Next, extend the logical volume to use the new space:

Re-create the swap on the logical volume:

Next, turn swap back on:

Finally, use the swapon –s command to verify the addition of the swap space to the system:

Retrieved from "http://www.techotopia.com/index.php/Adding_and_Managing_RHEL_6_Swap_Space" # vgs

VG #PV #LV #SN Attr VSize VFree vg_rhel6 2 2 0 wz--n- 10.78g 2.00g

# swapoff /dev/vg_rhel6/lv_swap

# lvextend -L+2GB /dev/vg_rhel6/lv_swap Extending logical volume lv_swap to 3.97 GiB

# mkswap /dev/vg_rhel6/lv_swap

mkswap: /dev/vg_rhel6/lv_swap: warning: don't erase bootbits sectors on whole disk. Use -f to force.

Setting up swapspace version 1, size = 2064380 KiB no label, UUID=1bb0e260-7940-4070-929c-91518a7be384

# swapon /dev/vg_rhel6/lv_swap

# swapon -s

Filename Type Size Used Priority /dev/dm-1 partition 2064376 0 -1

eBookFrenzy.com

Purchase and download the full PDF and ePub versions of this RHEL 6 eBook for only $9.99

PDF/ePub edition contains 40 chapters and over 250 pages.

Previous Table of Contents

(6)

Referencias

Documento similar

In the previous sections we have shown how astronomical alignments and solar hierophanies – with a common interest in the solstices − were substantiated in the

While Russian nostalgia for the late-socialism of the Brezhnev era began only after the clear-cut rupture of 1991, nostalgia for the 1970s seems to have emerged in Algeria

In working on a group, the problem of first and second canonical quantization on a (symmetric) curved space (which, relies heavily on both the structure of space-time itself and

K) is the Banach space of continuous functions from Vq to K , equipped with the supremum norm.. be a finite or infinite sequence of elements

MD simulations in this and previous work has allowed us to propose a relation between the nature of the interactions at the interface and the observed properties of nanofluids:

Government policy varies between nations and this guidance sets out the need for balanced decision-making about ways of working, and the ongoing safety considerations

No obstante, como esta enfermedad afecta a cada persona de manera diferente, no todas las opciones de cuidado y tratamiento pueden ser apropiadas para cada individuo.. La forma

 The expansionary monetary policy measures have had a negative impact on net interest margins both via the reduction in interest rates and –less powerfully- the flattening of the