1833016 Members
2421 Online
110048 Solutions
New Discussion

Increase Swap

 
SOLVED
Go to solution
Harstad
Advisor

Increase Swap

Hi

How can I increase Swap area in a Linux?

I don´t know the commands to do it and the steps.

free -k
total used free
Swap: 4194192 317388 3876804


sfdisk -s
total: 35561280 blocks
10 REPLIES 10
Huc_1
Honored Contributor

Re: Increase Swap

do a
#fdisk -l
this will show you your partition on of the is a swap parttion.
If you want to increase this it means re partioning your disk ... that is if there is some space left to partition/use.

If you need more swap for some reason you can always use swap to a file read man swapon

swapon -s

will tell you what swap you are using

J-P
Smile I will feel the difference
Mark Grant
Honored Contributor
Solution

Re: Increase Swap

You can do either file or device swap. Device swap is the easiest but you need a free partition to do it.


DEVICE SWAP

using fdisk, make a partition and give it an id of Linux Swap (82).

run mkswap /dev/hdaX where X is your partition number

run "swapon -p X" where X is a priority between 0 and 32767 (low number are higher priorirty) though you can leave this step off if you want it to have the same priority as your existing swap

run "swapon -a"

edit /etc/fstab and pretty much copy the exisiting entry for swap but changing the device.

FILE SWAP

Choose a place to put your file swap

run "dd if=/dev/zero of=/swapfile bs=1024 count=XXXX" where XXXX is the size of the swapfil in Kilobytes

"mkswap /swapfile"

"swapon -p X" if you want ot set priority X

Edit /etc/fstab as above.

I think that's everything.

Never preceed any demonstration with anything more predictive than "watch this"
Harstad
Advisor

Re: Increase Swap

Hi All

Thanks for your help.

Ok,,the swap space has been increased, but doing a:

fdisk -l /dev/cciss/c0d0

I can´t see the new swap partition.

Thanks

Harstad
Huc_1
Honored Contributor

Re: Increase Swap

swapon -s
should show that

J-P
Smile I will feel the difference
Harstad
Advisor

Re: Increase Swap

Hi

It´s Ok,,

swapon -s
Filename Type Size Used Priority
/dev/cciss/c0d0p7 partition 2097096 0 -1
/dev/cciss/c0d0p10 partition 2097096 0 -2
/dev/cciss/c0d0p11 partition 2097136 0 -3

but executing:

#fdisk -l /dev/cciss/c0d0

/dev/cciss/c0d0p11 550 1320 3145664 83 Linux

is strange..

Thank
Huc_1
Honored Contributor

Re: Increase Swap


Yes that is strange !

I dont know the why ??

what does the sfdisk -l see
there should be an entry for swap file in there
or else something is wrong !

what does the command fdisk -l /dev/cciss not /dev/cciss/c0d0p11 show ?

Sorry I do not have cciss devices so can not check myself

J-P ( 0 points for this answer pls, more questions then answers really)

Smile I will feel the difference
Mark Grant
Honored Contributor

Re: Increase Swap

You need to change the partition type from 83 to 82. Run fdisk, type "t", select partition and put in "82"
Never preceed any demonstration with anything more predictive than "watch this"
Harstad
Advisor

Re: Increase Swap

Hi Huc

Answering your questions:

fdisk -l /dev/cciss not /dev/cciss/c0d0p11

Disk /dev/cciss/c0d0p11: 255 heads, 32 sectors, 770 cylinders
Units = cylinders of 8160 * 512 bytes

Disk /dev/cciss/c0d0p11 doesn't contain a valid partition table

sfdisk -l

nting from 0

Device Boot Start End #cyls #blocks Id System
/dev/cciss/c0d0p1 * 9 33 25 102000 83 Linux
/dev/cciss/c0d0p2 34 162 129 526320 83 Linux
/dev/cciss/c0d0p3 0+ 8 9- 36704 12 Compaq diagnostics
/dev/cciss/c0d0p4 163 8715 8553 34896240 5 Extended
/dev/cciss/c0d0p5 163+ 291 129- 526304 83 Linux
/dev/cciss/c0d0p6 292+ 548 257- 1048544 83 Linux
/dev/cciss/c0d0p7 1320+ 1833 514- 2097104 82 Linux swap
/dev/cciss/c0d0p8 1834+ 2347 514- 2097104 83 Linux
/dev/cciss/c0d0p9 2348+ 2861 514- 2097104 83 Linux
/dev/cciss/c0d0p10 2862+ 3375 514- 2097104 82 Linux swap
/dev/cciss/c0d0p11 549+ 1319 771- 3145664 83 Linux
/dev/cciss/c0d0p12 3376+ 8715 5340- 21787184 83 Linux
# ^H
ksh:: not found
# fdisk -l /dev/cciss not /dev/cciss/c0d0p11

Disk /dev/cciss/c0d0p11: 255 heads, 32 sectors, 770 cylinders
Units = cylinders of 8160 * 512 bytes

Thanks

Huc_1
Honored Contributor

Re: Increase Swap

dev/cciss/c0d0p11 should be of type 82 that is linux swap not 83 Linux

for ex: your patition 07 is a valid swap partition

dev/cciss/c0d0p7 1320+ 1833 514- 2097104 82 Linux swap

If c0d0p11 is the "new" swap partition you wanted to use and is not used/mounted on your file system as a linux valid mount point then
do

#swapoff dev/cciss/c0d0p11

After that follow Mark Grant advised and change file type using fdisk t option on partition, when this is written to disk do as you did previously so to use it.

Then check agains fdisk -l

Keep us informed of progress.

J-P
Smile I will feel the difference
Harstad
Advisor

Re: Increase Swap

Hi Huc

I will keep you informed.

Thanks for your hekp.