• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

How to increase swap partition?

NBPTL

Member
New to linux but gained some knowlege from installing to running virtualbox.
But now I am wondering that I will be putting 2 more gigs of ram in my box for total of 4gig, should/how to inscrease swap partition to 8gig?
 
It really depends on how you have it setup, whether you used LVM, software RAID, etc. But it's the same way you resize any other partition, simplest is probably to just boot from a gparted LiveCD and go from there.
 
Doesn't linux use the swap for hibernation storage? I have 2 gb but almost never touch the swap. If you don't really touch it either then I don't really see much benefit (though, I could be really wrong with this one, but I have had swap sizes that don't match my ram size with pretty much no problems)
 
If I'm not compiling huge software (like I did with gentoo) I almost never hit the swap. In fact unless I'm using a notebook I use a swap file and not a swap partition (as far as I know you can not hybernate to swap if it's a file). If your not hitting max memory and swap usage, there is no reason to increase it.

However, you can have more then 1 swap partition or file. You can even have a swap partition and a swap file. The easiest way would be to make a swap file and add it as additional swap.
 
You can hibernate to an arbitrary file or swap file if you want with the TuxOnIce patches, but the in-kernel version and uswsusp can only do swap partitions right now AFIAK.
 
I wouldn't make the swap file any larger than 1.5gb if you really want to have a large swap file. All of my boxes have 800mb or less for swap and it's rarely used except when installing a lot of updates.
 
If you do decide to increase the size of the swap, you'll have to make some room on your disk with a disk repartitioning tool. fdisk will do the job -- but it'll corrupt data on whatever partition you shrink. I hope you have a partition you can trash...
 
fdisk will do the job -- but it'll corrupt data on whatever partition you shrink. I hope you have a partition you can trash...

That's why you first shrink the filesystem yourself or use something like gparted to do that for you...
 
i would monitor swap usage before adding swap. if you don't have any apps requiring more swap or aren't swapping in/out like mad or at all. There's no need. I'd just use top, free, or vmstat to monitor this.

If you must add and don't feel like messing with your partitions, just create a swap file with mkswap. Instructions are in the man page on how to dd a zero file and making a swap file out of it. use swapon to add it on the fly, swapoff to remove it. enter /etc/fstab entries to make it perm.
 
You can use just a swap file instead of a dedicated partition. I've done that on a couple of systems and it works fine in my testing. Basically you create a swap file, and use it as a loopback swap filesystem. A good process for this is at:

http://www.cyberciti.biz/faq/l...add-a-swap-file-howto/

This will keep you from having to hassle with partition changes. If you like what you experience, then maybe you could move on to the repartition later.
 
how to inscrease swap partition to 8gig?

Do you have unpartitioned space on a hard disk?

you can do all this without a reboot:

fdisk /dev/sda
- or whatever the device path is for your hard disk
- create a new partition of 8 GB, or however much you want to use
mkswap -L "newswap" /dev/sda1
- or whichever partition you use for swap
swapon LABEL=newswap
vi /etc/fstab
- update fstab to mount the new swap partition by label, so that it will be there on next reboot

If you are using LVM or don't have any unpartitioned space things will be a little different. You can use LVM tools to resize partitons, or as others noted, something like gparted. Hope this helps.




 
Back
Top