Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I need to increase my swap space (to satisfy an application) and as there are a couple of options I thought I'd ask people more experienced than me as to what the pitfalls / advantages of each strategy are. I guess that I have 2 options:
increase swap partition
add a swap file
1) I suspect that increasing swap will be the most troublesome, but I wonder if it might not be the best option. I guess that I'd need to backup my system (say to an external drive) and repartition. Is it possible to repartion without destroying existing file system?
2) adding a swap file seems simple enough, but I have a question about the commands for this. For example I could do:
Code:
dd if=/dev/zero of=/swappie bs=128M count=1
or
Code:
dd if=/dev/zero of=/swappie bs=1M count=128
would there be any differences in this? So (for instance) is it better to have one big block than heaps of tiny ones?
Lastly, my current configuration is something like this :
Personally I prefer partitions - note you can have more than one. Just create more partitions and add them to fstab. RH also have a modification in place to allow you to use swap partitions larger than 2 Gig - this is a RH (only) feature.
I do not like the idea of putting swap files on LVM - just another layer of software to (needlessly) get in the way and slow things down.
I also wouldn't like the idea of software purveyors telling me I need that much swap - must be java.
I also wouldn't like the idea of software purveyors telling me I need that much swap - must be java.
yep, it definitely makes use of java. Problem is that the installer seems to make the calculation on swap being 4x system memory, if you don't have that it conks out ... as to why it needs 16 gig of swap (when its not getting even 2 gig of memory to itself is beyond me
Is it possible to repartion without destroying existing file system?
Yes. It's easiest to boot a liveCD and use the partitioning tools on the liveCD. You can resize and/or move partitions (with existing file systems) and create and/or extend swap partitions.
Depending on what you do to the partition containing stage 1.5 of grub, you might need to reinstall stage 1 of grub after partitioning. That also is pretty easy to do while booted on the liveCD. Everything else in the partition is accessed in a way that won't be upset by the partition being in a different physical location.
BTW, do you have a 32-bit kernel or 64-bit? I'm not sure of the limits (max size per swap partition or file, etc.) in 32-bit, but I expect you need to worry about some of those to get to 16GB of swap.
Quote:
Code:
dd if=/dev/zero of=/swappie bs=128M count=1
or
Code:
dd if=/dev/zero of=/swappie bs=1M count=128
would there be any differences in this? So (for instance) is it better to have one big block than heaps of tiny ones?
That choice shouldn't affect the resulting file. It only affects the sequence of I/O operations used to create the file, which might significantly affect the time it takes to create the file, but no lasting effects.
BTW, why are those just 128M? Don't you need much more than that?
Quote:
Originally Posted by pellicle
Problem is that the installer seems to make the calculation on swap being 4x system memory, if you don't have that it conks out
Seems unbelievably lame. Your pretty sure it insists on 4x? Is it just the installer? In other words, once installed, does it still need the excess swap space?
Maybe you should create swap file(s) just for the install, then remove them once the program is installed.
Quote:
can I repartition on the fly?
You can't move nor resize a mounted partition. That restriction gets very tricky when booted on the same hard drive you are repartitioning. But it is pretty easy when booted from a liveCD.
You can resize and/or move partitions (with existing file systems) and create and/or extend swap partitions.
BTW, do you have a 32-bit kernel or 64-bit?
BTW, why are those just 128M? Don't you need much more than that?
Seems unbelievably lame. Your pretty sure it insists on 4x? Is it just the installer? In other words, once installed, does it still need the excess swap space?
live CD is very interesting option ... I'll look into that!
I believe that I have 64 bit kernel (not sure how to be sure though)
the examples I quoted were form other posts here ... naturally I'd alter them but just wanted to have some examples to 'discuss'
I've (since) got it installed (with errors) as it is. So I'll delay partitioning till I see some actual needs for that (why waste HDD??).
The minimum RAM required is 512MB, and the minimum required swap space is
1GB. Swap space should be twice the amount of RAM for systems with 2GB of
RAM or less and between one and two times the amount of RAM for systems with
more than 2GB.
Well, that 2nd sentence is the basic guideline for swap space on Linux generally.
There's no hard & fast rules though...
did you mean this one:
Swap space should be twice the amount of RAM for systems with 2GB of RAM or less and between one and two times the amount of RAM for systems with more than 2GB.
so probably I should make it 2Gig then ... not a big sacrifice.
Still, if the graphical tool that reports system loading is to be believed then there is nothing much even using the existing swap...
Last edited by pellicle; 07-30-2008 at 12:34 AM.
Reason: clicked too soon :-)
I thought I'd use top to monitor my system for a bit (to see what was happening with the demands on swap) and found the following:
Code:
top - 09:05:58 up 49 min, 3 users, load average: 0.08, 0.19, 0.09
Tasks: 125 total, 1 running, 123 sleeping, 0 stopped, 1 zombie
Cpu(s): 0.7% us, 0.3% sy, 0.0% ni, 98.8% id, 0.2% wa, 0.0% hi, 0.0% si
Mem: 3886992k total, 728300k used, 3158692k free, 21244k buffers
Swap: 2031608k total, 0k used, 2031608k free, 479516k cached
USER PR NI VIRT RES SHR S %CPU %MEM TIME+ SWAP COMMAND
cje 17 0 605m 22m 20m S 1.0 0.6 0:00.03 583moracle
cje 16 0 2216 972 752 R 0.3 0.0 0:00.67 1244 top
cje 16 0 574m 83m 24m S 0.3 2.2 0:16.84 491m java
root 16 0 3160 556 476 S 0.0 0.0 0:00.56 2604 init
root RT 0 0 0 0 S 0.0 0.0 0:00.00 0 migration/0
this actually raises some questions for me (doesn't good information always:-)
the process oracle seems to be consuming 583m of swap memory, yet nothing is being consumed (or so it seems) in swap. Is this because I have 3158692k free?
the process oracle seems to be consuming 583m of swap memory, yet nothing is being consumed (or so it seems) in swap. Is this because I have 3158692k free?
Yes (you actually have a bit more than that free BTW).
Having tried to make sense of that metric in the past, I now consider it meaningless. Probably the swapcache count, but I know of no way to verify my conjecture.
this actually raises some questions for me (doesn't good information always:-)
It raises a slightly different question for me, because I know the answer to the one that confused you:
Quote:
the process oracle seems to be consuming 583m of swap memory, yet nothing is being consumed (or so it seems) in swap. Is this because I have 3158692k free?
That "SWAP" column in top does not tell you how much swap memory the task is consuming. It tells you how much of the process's memory isn't resident in physical memory.
In a typical system, most non resident pages aren't in the swap space.
When pages are read in unmodified from a binary executable, Linux can keep track of the association between those pages and their source position in executable file. If Linux decides to push those pages out of memory, it can just discard the copy in memory (rather than write it to swap space). Then, if the page is needed in physical memory again, Linux can reread it from the executable file.
I'm pretty sure (especially seeing that 538MB) that memory mapped files are accounted the same way in top. A process can map part of a file into part of its virtual address space. Any pages brought in by that mapping are backed by the original file, not the swap space.
So what I wonder about your top output is did your system ever kick any pages out of physical memory. If it did, does that mean it was temporaraily doing so much file caching that free physical ram went nearly to zero?
The alternative is that everything listed in your SWAP column is mappings those processes created but never used. The process bound pages of its virtual address space to parts of a file, but then never read nor wrote those pages of its address space. A file mapping starts non resident (as if it had been paged out) and gets paged in as each page of the mapping is read or written.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.