7

Possible Duplicate:
Adding swap partition after system installation

I got 8GB RAM on my laptop but only partitioned 1GB for swap, now the hibernation cannot be achieved even if I use sudo pm-hibernate.

Is there any solution?

Yang Xia
  • 171
  • For creating a swap file (no need to re-partition) see: http://askubuntu.com/questions/126018/adding-a-new-swap-file-how-to-edit-fstab-to-enable-swap-after-reboot – Takkat Nov 07 '12 at 08:32
  • Run this command: echo 1 | sudo tee /proc/sys/kernel/sysrq ; echo f | sudo tee /proc/sysrq-trigger, and then hibernate. – neverMind9 Feb 03 '19 at 14:38

2 Answers2

4

Hibernation basically writes the contents of RAM to disk, using the swap partition. So, for hibernation to work, you need a swap partition not smaller than your RAM - I'd try something like 10Gb.

From SwapFAQ:

Hibernation (suspend-to-disk) 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.

You'll need to boot from a LiveCD and use gparted to resize partitions.

Sergey
  • 43,665
2

I'd suggest increasing the size of the swap partition if you can. Traditionally swap was twice the size of the RAM but you could probably get away with 4Gb.

You should also look at how much of the swap space is getting used with something like activity monitor.

  • 4Gb won't help... – Sergey Nov 06 '12 at 23:59
  • I guess it depends how big his RAM usage is. If its more than 4Gb your right 4Gb probably won't help. – niallhaslam Nov 07 '12 at 00:06
  • That's an interesting point you're raising here - does hibernation write ALL memory in one continuous 8Gb blob, regardless of how much is used by applications, or just the areas which are in use by the system/applications? I'm not sure although I suspect the former may be the case. Do you have any info on this? – Sergey Nov 07 '12 at 00:11
  • 1
    Assume the worst-case scenario. I have 16GB of RAM and hibernate works well (there's a 5-10 second period during the boot where I can see it reading the hibernate data back into memory). If I had to guess I would say it writes out the full capacity of the RAM, i.e. 16GB RAM = 16GB hibernate storage. I base this on the observation that a restart from hibernate seems to take the same amount of time from a heavy or light session. I have 20GB of swap space because... why not. Consider the cost of storage vs. the cost of RAM (even on an SSD) and over-allocate for swap. – Aaron Newton Nov 07 '12 at 04:13
  • I doubt the entire ram is written to swap all the time, only the effective content, otherwise the disk write operation should be a lot slower than what I observed on my system with 4G – prusswan Apr 24 '13 at 01:39