LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Extend the Swap Memory ? (https://www.linuxquestions.org/questions/linux-software-2/extend-the-swap-memory-4175465461/)

Senthilv 06-10-2013 03:02 PM

Extend the Swap Memory ?
 
Hai All,

Assume that i have installed centos and its running as fine, when i installing os its having ram memory of 2GB, but while installing time i have given as ram size is wrongly as 1024(i.e swap memory is 1024)

Now i just want to update the ram size as 2GB, i.e. i want to extend the swap memory as 2048, this will happen without down the os or without delete the swap memory and again for recreating swap memory like that ...

Just i want to extend the swap memory as 2048 ...

Is it possible this ?

shane25119 06-10-2013 03:07 PM

Sure, use GParted to resize the partition.

Senthilv 06-10-2013 03:15 PM

Mr shane,

You said GParted, using this we have to shut down the system, i asked without shutdown the computer.

shane25119 06-10-2013 03:17 PM

No, since the partition cannot be in use if you're resizing it. Running GParted off a live cd gets around that.

The whole process should take less than 10 minutes.

Senthilv 06-10-2013 03:29 PM

No, this swap memory currently running, within this itself i want to extent the swap memory.

smallpond 06-10-2013 03:41 PM

Safest is to create a new 1GB swap space and add that to fstab. Then do swapon -a

shane25119 06-10-2013 03:41 PM

If your system is currently running the swap memory partition is in use. It cannot be extended without powering down the system.

Is there a reason you do not want to boot into a live cd?

shane25119 06-10-2013 03:42 PM

@Smallpond, that assumes there is unpartitioned space and it also creates the problem of unused space that is the old swapspace.

johnsfine 06-10-2013 03:44 PM

1) You probably don't need to increase swap. There is no meaning behind whatever rule you found relating ram size to swap size. Increasing swap to 2GB is probably a good idea at some point, but not urgent enough to worry about now.

2) If you really need more swap space right away with minimum disruption on a running system, add a swap file (1GB). Linux can use multiple independent swap allocations (as the total of their sizes). Swap files are a lot easier to add on the fly than adding or resizing partitions.

smallpond 06-10-2013 04:25 PM

Quote:

Originally Posted by shane25119 (Post 4969099)
@Smallpond, that assumes there is unpartitioned space and it also creates the problem of unused space that is the old swapspace.

What problem? Use both.

shane25119 06-10-2013 04:39 PM

^ True, that would work- but your partition table gets real ugly real fast that way (not that it matters terribly much, I just like an orderly partition table).

chrism01 06-10-2013 09:57 PM

1. forget talking about RAM: you've got what you've got and the system doesn't let you set that on install anyway. It'll use it all.
See the output from 'top'.

2. as above, what you're talking about is swap space on disk.
Its perfectly possible to add and and activate another swap partition without re-booting IF you already have some spare disk space to put it (NB: I don't think you can resize root '/' partition when its running; its risky in any case).
What you need to do is google for your Linux distro and 'add swap' to see how.
Note that a swap partition is different from a swap file, although they perform the same job. I'd go with adding a partition.

EDDY1 06-11-2013 12:45 AM

Quote:

Its perfectly possible to add and and activate another swap partition without re-booting IF you already have some spare disk space to put it (NB: I don't think you can resize root '/' partition when its running; its risky in any case).
It's possible to add swap partition(not sure about extending) on running system only if there is free space, if no free space then they will have to free up space from another partition & extend swap. The problem is which partition to free up space & how many partitions have to be moved to access it. Also can the partitions be unmounted to perform task. Most likely OP needs to shutdown to perform task.

Quote:

Assume that i have installed centos and its running as fine, when i installing os its having ram memory of 2GB, but while installing time i have given as ram size is wrongly as 1024(i.e swap memory is 1024)
I've never had a system ask about ram size nor swap.

chrism01 06-11-2013 05:34 AM

If you do custom partitions during install, you specify swap space.
RAM: no, I think that's a confusion about 'virtual mem' implications.

johnsfine 06-11-2013 08:37 AM

Quote:

Originally Posted by chrism01 (Post 4969271)
Note that a swap partition is different from a swap file, although they perform the same job. I'd go with adding a partition.

There is barely any advantage to a swap partition vs. a swap file. In normal operation, there is no advantage to partition vs. file.

If expanding the existing swap partition were easy, I would recommend it. If we saw output from
/sbin/fdisk -l
we would have a better idea whether expanding or adding a swap partition without booting alternate media is easy, difficult, or impossible.

Meanwhile, I'm assuming that is not easy, so adding a swap file is easy and solves the problem.


All times are GMT -5. The time now is 02:53 PM.