# Swap Partition

## cjohnsoia

Previosly posted in "Other things Gentoo"  realizing that it should probably go here.

Hi All,

I have a dive patitioned such:

Device Boot Start End Blocks Id System

/dev/hda1 * 1 13 104391 83 Linux

/dev/hda2 14 257 1959930 82 Linux swap / Solaris

/dev/hda3 258 3738 27961132+ 83 Linux

Where /dev/hda3 is only 19% utilized.

Question:

Can anyone suggest the best way (tool, etc) that could be used to increase the size of the swap patition and reduce hda3 without loss of data?

Any suggestions greatly appreciated.

Thanks

----------

## bLUEbYTE84

Whoa, 2 GB swap partition is more than enough I think, it is redundant unless the role of your PC is really exotic.

For the record, in my desktop PC (Gaming, music stuff) I don't even have a swap partition at all, without any problems (1 GB real ram).

With that said, there are tools to resize partitions, but I won't go into details since I have no experience with them. But know that they are filesystem-type specific. Therefore if you really will do this (which I see ridiculous), state your FS type so others may provide help  :Smile: 

----------

## no_hope

without using any tools you could tar your / copy it to /dev/hda2, delete hda3, make new swap, make new root, extract old root to new root...

Let me know if you are interested and I'll post more coherent instructions.

Also, bLUEbYTE84 is right. swap is for wussies. Real men just buy more RAM (unless your are using suspend2 or something)  :Smile: 

----------

## alkan

without resizing any partition, you can also increase your swap:

```

dd if=/dev/zero of=/var/.swap count=<the size you wish for extra swap>

mkswap /var/.swap

swapon /var/.swap (or add it to fstab)

```

----------

## cjohnsoia

Thanks for the info,

Have you heard of 'parted'?  Think this may work - giving it a try - I want the very large prioritized swap partitions...

----------

## no_hope

 *cjohnsoia wrote:*   

> I want the very large prioritized swap partitions...

 

may I ask what software requires this? I get the feeling we are not talking desktops.

----------

## cjohnsoia

I want to run three instances of WMware all running 2003 server's as DB, file and app servers

----------

## rmh3093

you could always make swap files... use dd to create a 0 filled file as big as you want your swap file to be... then run mkswap on it and then configure fstab to use it as a swap

----------

## Kaste

The most comfortable way I have found is this: http://gparted.sourceforge.net/livecd.php

Just pop in the cd and you get a nice gui that helps you use parted and thereby resizes your partitions. 

Out of curiosity, how much RAM have/will you put in that system to run three 2003 servers?

----------

## kienjakenobi

In the Gentoo Wiki on Software RAID the partitioning scheme shows that the size of the swap partition should be ">=2*RAM."  I read that to say greater than or equal to two times the amount of RAM.  Is that a recommendation specific to having a RAID setup?  8 GB of swap would be massive!  On my desktop with 2 GB of RAM and 2 GB of swap I have never seen the swap used more than 5%, though it has only one hard disk.

----------

## nixnut

merged above post here.

----------

## Lomion

 *kienjakenobi wrote:*   

> In the Gentoo Wiki on Software RAID the partitioning scheme shows that the size of the swap partition should be ">=2*RAM."  I read that to say greater than or equal to two times the amount of RAM.  Is that a recommendation specific to having a RAID setup?  8 GB of swap would be massive!  On my desktop with 2 GB of RAM and 2 GB of swap I have never seen the swap used more than 5%, though it has only one hard disk.

 

I have 4 Gigs of DDR2 and a 4 gigs swap partition for suspend, but in normal use (and a 3000MB tmpfs for /var/tmp/portage mounted on demand) a so large swap partition is useless.

I think that when you have more than 2 GB of ram, you could simply fix you swap to 2 GB unless you don't run specific programs, virtualize a lot or suspend your system to disk in swap.

----------

## kienjakenobi

I suppose the recommendation on the Software RAID Wiki is for systems with smaller amounts of RAM or very special cases.  On a laptop with 4GB of RAM I think I will have 4GB of swap so I can easily suspend to disk and virtualize Windows.

----------

## i92guboj

Just a note about swap on loopback files:

1.- they doesn't perform the same than real partition/disks

2.- they are subject to filesystem penalties, which real swap partitions are not, i.e. fragmentation

----------

## Lomion

 *Lomion wrote:*   

> 
> 
> I have 4 Gigs of DDR2 and a 4 gigs swap partition for suspend, but in normal use (and a 3000MB tmpfs for /var/tmp/portage mounted on demand) a so large swap partition is useless.
> 
> I think that when you have more than 2 GB of ram, you could simply fix you swap to 2 GB unless you don't run specific programs, virtualize a lot or suspend your system to disk in swap.

 

Forgot to say I've a pair of Hitachi Deskstar disks in RAID 0 (except for /boot in RAID1)  :Wink: 

----------

## kienjakenobi

Ah!  So RAID tends to use the swap partition?  It sounds like you have a software RAID setup, but would a hardware RAID setup use the swap?  I suppose RAID of any type is not different from any other type of file processing in this aspect: RAID probably use the swap whenever it needs to temporarily put information somewhere, just as any program does.

----------

## Lomion

 *kienjakenobi wrote:*   

> Ah!  So RAID tends to use the swap partition?  It sounds like you have a software RAID setup, but would a hardware RAID setup use the swap?  I suppose RAID of any type is not different from any other type of file processing in this aspect: RAID probably use the swap whenever it needs to temporarily put information somewhere, just as any program does.

 

There's no difference in swap usage between RAID and non-RAID systems.

Swap will be used only on-demand when your ram is full, according to the "swappiness" of your box.

The only difference is that having a RAID Swap partition makes the swapping a little faster, although the difference isn't noticeable.

The reason because I have such a large swap partition is suspend to disk the system.

Anyway, happy new year everyone!   :Very Happy: 

----------

## zeek

Don't bother with swap partitions these days.  Swap files have 0 performance penalty and can be resized easily without playing with low level tools.

 *Quote:*   

> The kernel generates a map of swap offset -> disk blocks at
> 
> swapon time and from then on uses that map to perform swap I/O directly
> 
> against the underlying disk queue, bypassing all caching, metadata and
> ...

 

http://lkml.org/lkml/2005/7/7/326

----------

