Click to See Complete Forum and Search --> : Need help to resize the SWAP partition
hdang0821
08-12-2003, 12:37 AM
Hello,
I've Redhat 9 on my machine and have just upgraded the
ram from 128m to384M. As I understand, the size of SWAP partition is always 2 * RAM. How do I resize the SWAP?
Thanks in advance.
hd
andysimmons
08-12-2003, 12:43 AM
You'll need to rewrite the partition table, which usually involves losing all your data. You may be able to resize it and keep your data, but someone else will have to tell you how :)
psi42
08-12-2003, 01:21 AM
In order to keep you existing data, you will need to shrink an existing partition to make room to expand the swap partition.
There are many programs out there to do this, redhat probably comes with one. I'm not sure, but I bet the Knoppix live cd has one also. :) You'll probably want to resize the partition with a bootable CD or floppy to reduce possible complications.
Although non-destructive partition resizing is possible, you should be prepared to lose ALL your data on ALL partitions, as that can happen. It is a very complex task and sometimes things don't work out. :) (Yes I am speaking from personal experience:D)
However, do you really need to go through all that work? If you were fine with 128MB RAM and 256MB swap, then you should be even better with 384MB ram and 256MB swap.
Issue the command
free -m
and see if you are even using any of your swap space at all.
It's a lot of work and probably won't make a significant change. :)
hope this helps...
~psi42
The size of swap isn't always 2 * RAM; it can be any size you want, and that's just a general rule. You don't really need a swap bigger than 512MB, and for most systems somewhere between 250-512MB will be absolutely fine, so do you need to resize?
If you really want to resize your swap partition, check out Parted (http://www.gnu.org/software/parted/)
mdwatts
08-12-2003, 08:18 AM
Originally posted by o0zi
The size of swap isn't always 2 * RAM; it can be any size you want, and that's just a general rule. You don't really need a swap bigger than 512MB, and for most systems somewhere between 250-512MB will be absolutely fine, so do you need to resize?
I would agree. If you don't need that space you would claim by resizing the swap partition for anything else, then just leave it alone as it certainly will not do any harm.
I have 1gb of memory and still have a 1gb swap partition (never used anyways) that is shared by all of my installed distros.
If you really want to resize the swap partition, it might be easier to just delete the swap, recreate the partition as a smaller size, format as swap etc. etc.
This JL Help File on 'Creating a Swap Partition' (http://justlinux.com/nhf/Filesystems/Building_a_Swap_Partition.html) will explain.
ph34r
08-12-2003, 09:07 AM
I've never had a swap partition larger than 128mb, with system ram from 128 up to 768mb...
The Whizzard
08-12-2003, 09:19 AM
If you need to increase your SWAP, you can create a swapfile instead of resizing the partitions. The following will create a 256M swapfile:
dd if=/dev/zero of=/swapfile bs=1024 count=256k
mkswap /swapfile
swapon /swapfile
You'd then edit your /etc/fstab to enable the swapfile on boot. Insert the following:
/swapfile swap swap defaults 0 0
mdwatts
08-12-2003, 04:57 PM
We even have a JL Help File on 'Creating a SWAPFILE' (http://justlinux.com/nhf/Filesystems/Fly_Swapping.html).