Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Swap space

0 views
Skip to first unread message

Marmagya

unread,
Oct 6, 2003, 3:15:16 AM10/6/03
to
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

Davide Bianchi

unread,
Oct 6, 2003, 4:01:46 AM10/6/03
to
In comp.os.linux.misc Marmagya <marmagya@enopatra_spam.com> wrote:
> Can I simply go ahead and change the swap partition,

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

Paul Lutus

unread,
Oct 6, 2003, 4:25:13 AM10/6/03
to
Marmagya wrote:

> 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.

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?

> 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.

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

Floyd Davidson

unread,
Oct 6, 2003, 6:14:18 AM10/6/03
to
Paul Lutus <nos...@nosite.zzz> wrote:
>Marmagya wrote:
>
>> 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.
>
>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?

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.)

>> 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.
>
>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).

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) fl...@barrow.com

Dave Brown

unread,
Oct 6, 2003, 3:32:38 PM10/6/03
to
In article <877k3i4...@barrow.com>, Floyd Davidson wrote:
> Paul Lutus <nos...@nosite.zzz> wrote:
>>Marmagya wrote:
>>
>>> 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.
>>
>>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?
>
> 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.)
>
>>...

>>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).

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

0 new messages