LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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


Reply
  Search this Thread
Old 11-15-2010, 07:38 AM   #16
w1k0
Senior Member
 
Registered: May 2008
Location: Poland
Distribution: Slackware (personalized Window Maker), Mint (customized MATE)
Posts: 1,309

Rep: Reputation: 234Reputation: 234Reputation: 234

The other benefit of swap partition not mentioned above is the possibility of hibernate the system on that partition. I such case the swap should be at least of the same size as the memory.
 
Old 11-15-2010, 07:44 AM   #17
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by w1k0 View Post
The other benefit of swap partition not mentioned above is the possibility of hibernate the system on that partition. I such case the swap should be at least of the same size as the memory.
AFAIK it needs to be larger than the memory because hibernating saves more than just the memory -- it also saves CPU etc state (which is relatively small) and the contents of swap. For this reason the swap space intended for hibernating should be a little bigger than the memory plus the swap space and should be dedicated for hibernating, not used for regular swapping.
 
Old 11-15-2010, 08:07 AM   #18
w1k0
Senior Member
 
Registered: May 2008
Location: Poland
Distribution: Slackware (personalized Window Maker), Mint (customized MATE)
Posts: 1,309

Rep: Reputation: 234Reputation: 234Reputation: 234
Quote:
Originally Posted by catkin View Post
AFAIK it needs to be larger than the memory because hibernating saves more than just the memory -- it also saves CPU etc state (which is relatively small) and the contents of swap. For this reason the swap space intended for hibernating should be a little bigger than the memory plus the swap space and should be dedicated for hibernating, not used for regular swapping.
I disagree in both cases.

1. Here you'll find such information: ``The hibernation feature (suspend-to-disk) writes out the contents of RAM to the swap partition before turning off the machine. Therefore, your swap partition should be at least as big as your RAM size. The hibernation implementation currently used in Ubuntu, swsusp, needs a swap or suspend partition. It cannot use a swap file on an active file system''.

2. Assuming your swap partition is /dev/sda4 to use it to hibernate the system you have to put in /etc/lilo.conf the line:

Code:
append="resume=/dev/sda4"
Of course it should be also the method allowing to use the swap partition to hibernate the system with GRUB.
 
Old 11-15-2010, 08:59 AM   #19
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by w1k0 View Post
I disagree in both cases.
I couldn't find any authoritative reference about it but all the processes' memory must be restored on resume and if some of that data was in swap, restoring only the RAM contents would not restore all the processes' memory -- the swap must also be restored. In practice flushing file system caches and compressing the data reduces the space required so it may be that in the majority of cases (when swap is not being heavily used at hibernate time) a swap space equal to the RAM is "good enough" but cannot be guaranteed to work in all cases.
 
Old 11-15-2010, 10:22 AM   #20
w1k0
Senior Member
 
Registered: May 2008
Location: Poland
Distribution: Slackware (personalized Window Maker), Mint (customized MATE)
Posts: 1,309

Rep: Reputation: 234Reputation: 234Reputation: 234
Quote:
Originally Posted by catkin View Post
I couldn’t find any authoritative reference
In fact you could to find such information on the same page I recommended above: “If Hibernation is important to you, have more swap space then ram + swap overflow”.

On the other hand I did simple experiment. According to top command my machine uses 1023192k memory and 1028152k swap. I logged two users in the system running two X Window sessions and started a lot of programs to fulfill memory and start to use swap space. Then I hibernated the system and successfully revived it from hibernation. It seems a resume manages somehow with the lacking swap space.
 
1 members found this post helpful.
Old 11-15-2010, 01:10 PM   #21
teebones
Member
 
Registered: Aug 2005
Location: /home/teebones
Distribution: sometimes this, sometimes that..
Posts: 502

Rep: Reputation: 56
indeed.. YES is the answer. (if it's good practise is complete another question....)
 
Old 11-15-2010, 01:19 PM   #22
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by teebones View Post
indeed.. YES is the answer.
Before giving a simple answer such as "Yes", notice the age of the thread as well as the topic drift.

After old wrong answers to the original question:
Quote:
Short answer, No.
The thread is reopened with significant topic drift
Quote:
Ubuntu installed on a 4 Gb USB drive.
And then reopened again followed by more topic drift into how much extra swap you need for hibernation.

If you have a useful answer to something asked here recently, you probably need to quote whatever you are answering so it isn't lost in the confusion.

If you want to correct an old wrong answer, I don't personally think that serves a purpose, but if you do it anyway, that also needs clarification of which segment of the thread you are answering.

Last edited by johnsfine; 11-15-2010 at 01:23 PM.
 
1 members found this post helpful.
Old 11-15-2010, 03:29 PM   #23
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 4,070

Rep: Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897
Quote:
Originally Posted by catkin View Post
I couldn't find any authoritative reference...
Nor could I, but there was the assertion scattered all around the net that 'for hibernation you need swap as big as ram'. This seemed to me to be likely to be an untrue statement, so I did an experiment. 1G ram and 1.6G swap space. that would be swap space at least as big as ram. It worked for a while for me, but eventually I started getting unexplained failures to come back from hibernation.

At this point I changed to enabling two swap partitions of 1.6 G each. The problems went away, but it does mean I have the rather generous 3.2 G of swap for 1G of ram...but then, the real problem is that 1G of ram isn't enough for my rather expansive working style. Must go to the ram shop sometime soon...

@catkin
Quote:
...and compressing the data reduces the space required...
And I saw a quote from, IIRC, some of the SUSE developers who said something like '...until recently we didn't even compress the data on suspend..ha, ha..how unsophisticated was that...' (this being a slightly old quote, he must have been referring to a situation that applied some time ago): so, I don't know whether you can take it as a universal rule that that all distros and all vintages will compress on suspend.
 
1 members found this post helpful.
Old 11-15-2010, 03:44 PM   #24
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by salasi View Post
'for hibernation you need swap as big as ram'. This seemed to me to be likely to be an untrue statement
I have interpreted that common assertion as "for hibernation swap at least as big as ram is required". I expect that is untrue. At first glance, I thought that is what you meant. But I think the interpretation you are saying is untrue is "for hibernation swap as big as ram is sufficient" (sorry about the implied double negative).

It seems completely obvious that the second interpretation couldn't be true. It should be easy to use up all your swap (even if it were ten times the size of ram) and then it should be obvious that hibernation would require at least some amount more than you used without hibernation.

Quote:
so I did an experiment. 1G ram and 1.6G swap space. that would be swap space at least as big as ram. It worked for a while for me, but eventually I started getting unexplained failures to come back from hibernation.
But how much swap was in use before trying a hiberation that failed?

I haven't even figured out how to try hibernation, so I haven't done the opposite test (but I ought to): With 8GB of ram, cut my swap size down to 1 or 2 GB, then set up a workload using no swap space and less than 1GB of anonymous memory but more than 2GB on non anonymous memory. Then would hibernation work? I strongly expect that it would work (that swap as big as ram is not necessary for hibernation).

Last edited by johnsfine; 11-15-2010 at 03:46 PM.
 
1 members found this post helpful.
Old 11-15-2010, 09:17 PM   #25
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by w1k0 View Post
In fact you could to find such information on the same page I recommended above: “If Hibernation is important to you, have more swap space then ram + swap overflow”.

On the other hand I did simple experiment. According to top command my machine uses 1023192k memory and 1028152k swap. I logged two users in the system running two X Window sessions and started a lot of programs to fulfill memory and start to use swap space. Then I hibernated the system and successfully revived it from hibernation. It seems a resume manages somehow with the lacking swap space.
Sorry for missing that. I did read the page but only as far as the quote you gave which I took as a heuristic -- as is implied by the presence of the later sentence you quote which is more swap than required for hibernate according to my understanding but an indeterminate amount because "swap overflow" cannot be known ahead of time.

Regards your experiment a) although the system had started swapping some of the memory contents can be discarded including file system cache space and unchanged pages read in from swap and b) the hibernate system may have compressed memory data.
 
Old 11-15-2010, 09:28 PM   #26
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Perhaps there are two questions here:
  1. How much swap space do I need for hibernate to work most of the time (keep it simple)?
  2. How much swap space do I need for hibernate to work dependably?
With corresponding answers:
  1. Same as the RAM, that works for most people.
  2. In addition to any swap space you already have (which on a multi-boot system must be dedicated to this OS) you also need a swap space dedicated to hibernating this OS (that is without auto in fstab) that is the size of the RAM. Actually it could be smaller, but the reduction is non-trivial to calculate.
 
Old 11-16-2010, 02:58 AM   #27
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 4,070

Rep: Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897
Quote:
Originally Posted by johnsfine View Post
I have interpreted that common assertion as "for hibernation swap at least as big as ram is required". I expect that is untrue. At first glance, I thought that is what you meant. But I think the interpretation you are saying is untrue is "for hibernation swap as big as ram is sufficient" (sorry about the implied double negative).
You are exactly correct right in your interpretation; what seems to be often implied (implied rather than stated exactly, but that's what you'd expect from this kind of thinking, too) is that a swap space any larger than ram will be sufficient.

Quote:
Originally Posted by johnsfine View Post
It seems completely obvious that the second interpretation couldn't be true. It should be easy to use up all your swap (even if it were ten times the size of ram) and then it should be obvious that hibernation would require at least some amount more than you used without hibernation.
Except that compression (if used in hibernation and not used in normal operation) could get you out of trouble, but probably doesn't... OTOH, the people who come up with the 'nonsense view' of hibernation seem to just ignore the possibility that swap may well be in use at the time of hibernation.

Quote:
But how much swap was in use before trying a hiberation that failed?
I can't give you an exact figure; after a crash, there was nothing that I know of that gives you that information. I can give you an estimate of how much memory was habitually in use at that time.

Out of 1g of ram, 850 - 950 M was habitually in use
Out of 1.6g of swap, 1.2 - 1.4 G was habitually in use

While that is a bit inexact, its the best that I have, and at the time, hibernation was failing maybe 10 - 15 times out of a hundred.

Quote:
Originally Posted by johnsfine View Post
I haven't even figured out how to try hibernation, so I haven't done the opposite test (but I ought to): With 8GB of ram, cut my swap size down to 1 or 2 GB, then set up a workload using no swap space and less than 1GB of anonymous memory but more than 2GB on non anonymous memory. Then would hibernation work?
You would expect it to, if the non-anon gets dropped, which it should be (but i don't actually know as a fact that it is). If you do do the test, I would be very pleased to see the result.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to pick the SWAP partition after install of FC4 Peanutman Fedora 9 10-27-2005 07:25 AM
Is it okay to alter swap partition with fdisk after FC4 install? Dimension User Fedora 6 09-19-2005 06:21 PM
install Linux without swap partition? leduytien Linux - Software 19 02-02-2005 01:21 PM
Activating swap partition early in install Septus Linux - Newbie 3 09-10-2003 10:54 PM
RH 7.2 install and swap partition hedstrom Linux - Software 2 12-31-2001 10:20 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration