Account Links: Cart | Your Account | Logout

Skip to content

Red Hat Knowledgebase

Red Hat Knowledgebase Search:

Updated Within the Last:

New Solutions within the last day New Solutions within the last week New Solutions within the last month

Browse by topics:


Click to View a Topic
Red Hat Enterprise Linux > AS/ES/WS Basics > Issue <<  88 of 908 >>

Solution Tools:


Email a Solution Postcard Printer version Submit a comment on this answer Update notifications Request an answer Back

Article Reference

Article ID: 385
Last update: 08-27-07
Issue:
How do I add a swap partition to my system in Red Hat Enterprise Linux?
Resolution:
  1. To add a swap partition (assuming /dev/hdb2 is the swap partition you want to add): The hard drive can not be in use (partitions can not be mounted, and swap space can not be enabled). The partition table should not be modified while in use because the kernel may not properly recognize the changes. Data could be overwitten by writing to the wrong partition because the partition table and partitions mounted do not match. The easiest way to achieve this is to boot your system in rescue mode. When prompted to mount the file system, select Skip. Alternately, if the drive does not contain any partitions in use, you can unmount them and turn off all the swap space on the hard drive with the swapoff command.

  2. Create the swap partition using parted:
  • At a shell prompt as root, type the command parted /dev/hdb, where /dev/hdb is the
    device name for the hard drive with free space.
  • At the (parted) prompt, type print to view the existing partitions and the amount of free space. The start and end values are in megabytes. Determine how much free space is on the hard drive and how much you want to allocate for a new swap partition.
  • At the (parted) prompt, type mkpartfs part-type linux-swap start end, where part-type is one of primary, extended, or logical, start is the starting point of
    the partition, and end is the end point of the partition.
  • Exit parted by typing quit.
  1. Now that you have created the swap partition, use the command mkswap to setup the swap partition. At a shell prompt as root, type the following:

    mkswap /dev/hdb2

  2. To enable the swap partition immediately, type the following command:

    swapon /dev/hdb2

  3. To enable it at boot time, edit /etc/fstab to include:

    /dev/hdb2    swap    swap defaults   0 0

    The next time the system boots, it enables the new swap partition.

  4. After adding the new swap partition and enabling it, verify it is enabled by viewing the output of the command cat /proc/swaps or free.


How well did this entry answer your question?


good wrong incomplete out of date
Red Hat Enterprise Linux > AS/ES/WS Basics > Issue <<   88  of  908  >>