LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Can I install linux without a swap partition? (https://www.linuxquestions.org/questions/linux-general-1/can-i-install-linux-without-a-swap-partition-82969/)

w1k0 11-15-2010 07:38 AM

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.

catkin 11-15-2010 07:44 AM

Quote:

Originally Posted by w1k0 (Post 4159357)
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.

w1k0 11-15-2010 08:07 AM

Quote:

Originally Posted by catkin (Post 4159363)
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.

catkin 11-15-2010 08:59 AM

Quote:

Originally Posted by w1k0 (Post 4159392)
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.

w1k0 11-15-2010 10:22 AM

Quote:

Originally Posted by catkin (Post 4159456)
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.

teebones 11-15-2010 01:10 PM

indeed.. YES is the answer. (if it's good practise is complete another question....)

johnsfine 11-15-2010 01:19 PM

Quote:

Originally Posted by teebones (Post 4159691)
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.

salasi 11-15-2010 03:29 PM

Quote:

Originally Posted by catkin (Post 4159456)
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.

johnsfine 11-15-2010 03:44 PM

Quote:

Originally Posted by salasi (Post 4159858)
'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).

catkin 11-15-2010 09:17 PM

Quote:

Originally Posted by w1k0 (Post 4159544)
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.

catkin 11-15-2010 09:28 PM

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.

salasi 11-16-2010 02:58 AM

Quote:

Originally Posted by johnsfine (Post 4159881)
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 (Post 4159881)
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 (Post 4159881)
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.


All times are GMT -5. The time now is 07:05 PM.