Professional Web Applications Themes

Swap space - Linux Setup, Configuration & Administration

Hello, I have around 2 GB of swap space and would like to reduce it to something around 1 GB or 500 MB as I have 500MB RAM and seems I do not need that huge a swap space. Can I simply go ahead and change the swap partition, or will doing so affect my system in any way? I do not want to reinstall anything and my aim is to keep my current system running with only the swap space removed. Regards Marmagya...

  1. #1

    Default Swap space

    Hello,
    I have around 2 GB of swap space and would like to reduce it to
    something around 1 GB or 500 MB as I have 500MB RAM and seems I do not
    need that huge a swap space. Can I simply go ahead and change the swap
    partition, or will doing so affect my system in any way? I do not want
    to reinstall anything and my aim is to keep my current system running
    with only the swap space removed.

    Regards
    Marmagya

    Marmagya Guest

  2. #2

    Default Re: Swap space

    In comp.os.linux.misc Marmagya <com> wrote: 

    For safety:
    boot in single-user-mode, disable the swap (swapoff), change your
    partition, prepare it as swap (mkswap), adjust /etc/fstab, turn
    your swap on (swapon), go back to multiuser.

    Davide
    Davide Guest

  3. #3

    Default Re: Swap space

    Marmagya wrote:
     

    The general rule is to have at least twice your RAM as swap space. So your
    present configuration is not that far from optimal. What is your reason for
    wanting to change this partition?
     

    Again, why? It is easy to change the swap partition size, but is not so easy
    to reclaim the freed space for some other use (in this case, 1 GB).

    --
    Paul Lutus
    http://www.arachnoid.com

    Paul Guest

  4. #4

    Default Re: Swap space

    Paul Lutus <zzz> wrote: 
    >
    >The general rule is to have at least twice your RAM as swap space. So your
    >present configuration is not that far from optimal. What is your reason for
    >wanting to change this partition?[/ref]

    That has *never* been a valid rule for Linux. (It was
    appropriate for certain versions of BSD at one time, and may or
    may not still be.)

    I would take the OP's word for it that the system does not need
    2500MB of virtual memory. If he has 500Mb of RAM and it never
    works out of swap, there is no need at all to have more than a
    couple hundred Mb of swap for non-active processes, and perhaps
    a couple hundred more just in case at some peak usage it does
    work from swap. It would appear that 500Mb would be fine, and
    anything more than maybe 750 is wasted. (In fact, probably
    anything greater than 150Mb is wasted, but disk space is cheap.)
     
    >
    >Again, why? It is easy to change the swap partition size, but is not so easy
    >to reclaim the freed space for some other use (in this case, 1 GB).[/ref]

    Actually it can all be done without rebooting. However, since
    it is always a good idea to verify changes, such as edits of
    /etc/fstab, are correct, there really is no reason not to reboot
    the system just to verify that it comes up correctly.

    It is also safest to do this in single user level, but that to
    is not required. To enter single level, do "init S", and
    proceed. At the end, either reboot or do "init n" where n is
    the normal run level (commonly 3, but it could be something
    different, so check with the runlevel command before starting).

    The steps are:

    1) use swapoff to disable swapping to the current swap partition.
    2) use fdisk to delete the swap partition,
    3) use fdisk to allocate the disk space to two new partitions,
    4) use mkswap on one partition to configure it as swap,
    5) use mkfs on the other partition to configure it as a filesystem,
    6) use swapon to enable the swap partition,
    7) use mount to access the new filesystem,
    8) edit /etc/fstab as needed to mount both swap and
    the filesystem at boot time.

    Then reboot if you like.

    --
    Floyd L. Davidson <http://web.newsguy.com/floyd_davidson>
    Ukpeagvik (Barrow, Alaska) com
    Floyd Guest

  5. #5

    Default Re: Swap space

    In article <com>, Floyd Davidson wrote: 
    >>
    >>The general rule is to have at least twice your RAM as swap space. So your
    >>present configuration is not that far from optimal. What is your reason for
    >>wanting to change this partition?[/ref]
    >
    > That has *never* been a valid rule for Linux. (It was
    > appropriate for certain versions of BSD at one time, and may or
    > may not still be.)
    > [/ref]

    I agree that other than a few early levels of the 2.4 kernel, no need for
    great amounts of swap space. For some reason, the RedHat installer has
    never changed from those dark days of defective swap code, and it tries to
    convince one of the need for unreasonable swap space.

    As far as "reusing" the 1 GB for some other purpose, once the swap
    partition is redefined, one might consider applying it as some other
    mounted partition, maybe /home, or even /tmp. For myself, I have LVM
    set up, which permits pooling of disk space, be it individual partitions
    or whole disks, into a "virtual disk" (called a Volume Group); so for me,
    I'd simply add that 1 GB to a VG.

    One word of warning: if you split an existing partition, you'll usually
    end up with device numbers of partitions being renumbered, so you have to
    deal with that.

    --
    Dave Brown Austin, TX
    Dave Guest

Similar Threads

  1. Swap Image ?
    By Peter Fettes in forum Macromedia Dynamic HTML
    Replies: 4
    Last Post: February 26th, 08:51 PM
  2. Swap image also swap link
    By Timothy Robertson in forum Dreamweaver AppDev
    Replies: 2
    Last Post: May 26th, 05:29 PM
  3. can swap space be resized ?
    By David Magda in forum Linux / Unix Administration
    Replies: 7
    Last Post: August 26th, 07:19 PM
  4. swap space
    By mike in forum Sun Solaris
    Replies: 1
    Last Post: August 1st, 05:04 PM
  5. Yikes swap space nearly used up!!!!
    By Dave Uhring in forum Sun Solaris
    Replies: 3
    Last Post: July 2nd, 04:15 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139