LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Laptop and Netbook
User Name
Password
Linux - Laptop and Netbook Having a problem installing or configuring Linux on your laptop? Need help running Linux on your netbook? This forum is for you. This forum is for any topics relating to Linux and either traditional laptops or netbooks (such as the Asus EEE PC, Everex CloudBook or MSI Wind).

Notices


Reply
  Search this Thread
Old 05-14-2018, 05:59 AM   #1
Herve5
Member
 
Registered: Oct 2016
Location: Europe
Distribution: Debian & Ubuntu Mate
Posts: 107

Rep: Reputation: Disabled
Hibernating Ubuntu Mate : swap size?


Hello,
We are using two laptops here that came with U. Mate preinstalled (16.04, supplied by the German Tuxedo), and are very happy with these configurations, with only an issue : hibernation doesn't work.

I am definitely not a geek, but I sort of understand this may be due to the fact that when preparing an hibernation, the system tries to record the RAM contents onto the swap partition (and only there?), which in our case does not succeed as the swaps are smaller than the RAM on our machines.

I considered increasing the swap partitions, but
- I want to be sure my analysis above is correct
- I don't have external disks or CD to boot from (which I understand may be needed to touch the swap?), nor do I really master the 'Grub' commanding
- I don't know the terminal swap-related commands, but I saw they were numerous and visibly powerful (capable to add a second swap for instance...)
- I am tempted to solve the issue by switching to a swap file : is it as simple as in the extremely seducing post here ? (indeed is hibernation actually compatible with swapfiles?)

So, in short, is there a safe way to proceed without creating a complete alternate boot, maybe by adding a second, larger swap then unmounting the small one, or switching to a swapfile?

(please consider I didn't even install Ubuntu myself, and am quite a newcomer!)

Thank you!
Hervé

Last edited by Herve5; 05-14-2018 at 06:04 AM.
 
Old 05-14-2018, 06:32 AM   #2
pierre2
Member
 
Registered: May 2009
Location: Perth, AU
Distribution: LinuxMint
Posts: 388
Blog Entries: 9

Rep: Reputation: 88
the hibernate option will require the /swap size to be At Least Equal to the RAM size,
- or even bigger, preferably.

you can increase the size if the existing /swap partition,
and then modify the Fstab to record that adjustment.

but, for any N00B it may be just plain easier to redo the installation, again . .
 
1 members found this post helpful.
Old 05-14-2018, 06:52 AM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Nah - of all the disk/partition operations on Linux, adjusting swap is the least likely to cause problems. Swap can be easily added or removed and a reboot usually fixes any screw-ups. Last I looked you couldn't use a swapfile for hibernation - that may have changed or I may be wrong.
Go to a terminal and run these commands and post the output.
Code:
df -hT
free -m
lsblk
 
1 members found this post helpful.
Old 05-14-2018, 12:03 PM   #4
Herve5
Member
 
Registered: Oct 2016
Location: Europe
Distribution: Debian & Ubuntu Mate
Posts: 107

Original Poster
Rep: Reputation: Disabled
Thank you for these very fast reactions!
Indeed, I don't want to delete everything and restart : over more than one year of use, I painfully imported really many features and data, recreated ranges of email filters etc.
What I'd like is an upgrade...


Here is what I get with the three commands, in a french but quite explicit terminal :
Code:
herve5@TuxHerve:~$ df -hT
Sys. de fichiers      Type     Taille Utilisé Dispo Uti% Monté sur
udev                  devtmpfs    16G       0   16G   0% /dev
tmpfs                 tmpfs      3,2G     18M  3,2G   1% /run
/dev/nvme0n1p3        ext4        50G     17G   31G  35% /
tmpfs                 tmpfs       16G     97M   16G   1% /dev/shm
tmpfs                 tmpfs      5,0M    8,0K  5,0M   1% /run/lock
tmpfs                 tmpfs       16G       0   16G   0% /sys/fs/cgroup
/dev/nvme0n1p1        vfat       512M    136K  512M   1% /boot/efi
/dev/nvme0n1p4        ext4       882G    208G  674G  24% /home
/dev/sda1             ext4       1,8T    838G  996G  46% /datadisk
tmpfs                 tmpfs      3,2G     68K  3,2G   1% /run/user/1000
/home/herve5/.Private ecryptfs   882G    208G  674G  24% /home/herve5
herve5@TuxHerve:~$ free -m
              total       utilisé      libre     partagé tamp/cache   disponible
Mem:          31962        2558         915         462       28489       28143
Partition d'échange:        8191           0        8191
herve5@TuxHerve:~$ lsblk
NAME           MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda              8:0    0   1,8T  0 disk  
└─sda1           8:1    0   1,8T  0 part  /datadisk
nvme0n1        259:0    0 953,9G  0 disk  
├─nvme0n1p3    259:3    0    50G  0 part  /
├─nvme0n1p1    259:1    0   512M  0 part  /boot/efi
├─nvme0n1p4    259:4    0 895,4G  0 part  /home
└─nvme0n1p2    259:2    0     8G  0 part  
  └─cryptswap1 253:0    0     8G  0 crypt [SWAP]
Both disks are SSDs, the small one is faster; I use the second one for backups of the home folder (using the 'Back in Time' app which basically seems to be an rsync wrapper, à la 'Time Machine' on OSX).

Last edited by Herve5; 05-14-2018 at 12:10 PM.
 
Old 05-14-2018, 03:39 PM   #5
ChuangTzu
Senior Member
 
Registered: May 2015
Location: Where ever needed
Distribution: Slackware/Salix while testing others
Posts: 1,718

Rep: Reputation: 1857Reputation: 1857Reputation: 1857Reputation: 1857Reputation: 1857Reputation: 1857Reputation: 1857Reputation: 1857Reputation: 1857Reputation: 1857Reputation: 1857
Hibernate is disabled on Ubuntu, this should help, as mentioned by pierre2m Swap should ideally be equal (or double) to the amount or RAM on system :
http://ubuntuhandbook.org/index.php/...-ubuntu-17-10/
 
1 members found this post helpful.
Old 05-14-2018, 07:31 PM   #6
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Let me re-phrase:
Quote:
of all the disk/partition operations on Linux, adjusting swap is should be the least likely to cause problems.
Now I remember why I gave up on Ubuntu all those years ago.

So you have 32G of RAM, and only 8G of encrypted swap. Which I doubt you've ever used. As mentioned, your swap needs to be at least as big as your RAM (for safety), although hibernate only saves what is used. Whether it needs to be encrypted is probably debatable, but is likely the default these days on Ubuntu.
In a "normal" setup you'd just set up a swap partition of the appropriate size and ensure fstab and grub looked at the correct volume. Even the encryption isn't that big a deal of itself, but I don't know what Ubuntu do in the initrd. That could make the system unbootable (but shouldn't). The last post here suggests things work as expected, but I haven't tried on a Ubuntu system. Hence I'm not prepared to suggest a course of action.

It should be noted that your /home is also encrypted when you are not logged on - but your backup will be there for the all world to see.
 
1 members found this post helpful.
Old 05-14-2018, 08:35 PM   #7
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,982

Rep: Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625
I think there is a bit of overhead on the swap partition size to ram so you'd need a bit more.

Not sure about using encrypted swap too. It is supposed to use a random key. If you can make it one of your selection you could unlock it.
 
1 members found this post helpful.
Old 05-14-2018, 08:52 PM   #8
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,324
Blog Entries: 28

Rep: Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142
The old rule of thumb that swap size should be double RAM dates back to the days when RAM was measured in kb. In those days, such a relationship materially affected the performance of the machine.

In these days of 4 and 8 and 16 (and more) GB RAM, not so much. I just checked the swap usage of this desktop machine, which has 16GB RAM, 4GB swap, and an uptime of four days. No swap is being used. Nada. Zilch. None.

On a contemporary machine with 4 or more GB RAM, my experience has been that the only reason for swap to exceed RAM is if "hibernate" will be used. On such a machine, I generally set swap to 1/2 RAM and have found performance to be quite acceptable.

Just for myself, I never use "hibernate," but I do sometimes use "suspend," mainly so the cats don't mess up my laptop by walking over the keyboard when I'm not there to defend it. I have found that cats do not recognize anyone else's territorial rights . . . .
 
Old 05-15-2018, 12:48 AM   #9
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
https://askubuntu.com/questions/7681...n-ubuntu-16-04
second and third answers seem to be much better than the first.
 
1 members found this post helpful.
Old 05-15-2018, 12:15 PM   #10
Herve5
Member
 
Registered: Oct 2016
Location: Europe
Distribution: Debian & Ubuntu Mate
Posts: 107

Original Poster
Rep: Reputation: Disabled
Thank you all, thank you ondoho!
Quote:
Originally Posted by ondoho View Post
https://askubuntu.com/questions/7681...n-ubuntu-16-04
second and third answers seem to be much better than the first.
Indeed the second answer seems very convincing, but I have a newbie issue I think : when I edit /etc/default/grub, even with the sudoedit command, I just cannot overwrite it (permission refused)...
 
Old 05-15-2018, 05:34 PM   #11
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524

Rep: Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015
Post

Quote:
Originally Posted by pierre2 View Post
the hibernate option will require the /swap size to be At Least Equal to the RAM size,
- or even bigger, preferably.

you can increase the size if the existing /swap partition,
and then modify the Fstab to record that adjustment.

but, for any N00B it may be just plain easier to redo the installation, again . .
fstab doesn't care about size unless it's dynamic.
 
Old 05-24-2018, 12:48 AM   #12
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by Herve5 View Post
Thank you all, thank you ondoho!

Indeed the second answer seems very convincing, but I have a newbie issue I think : when I edit /etc/default/grub, even with the sudoedit command, I just cannot overwrite it (permission refused)...
show us the terminal output.

you can also use
Code:
sudo nano /etc/default/grub
if that works better for you.

also remember that afetr every (succesful) edit of that file, you should run
Code:
sudo update-grub
 
Old 05-27-2018, 04:21 PM   #13
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524

Rep: Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015
I guess it is possible to use a swap file for swsusp: https://github.com/spotify/linux/blo...swap-files.txt
 
1 members found this post helpful.
Old 05-27-2018, 08:15 PM   #14
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
Quote:
Originally Posted by AwesomeMachine View Post
I guess it is possible to use a swap file for swsusp: https://github.com/spotify/linux/blo...swap-files.txt
I have used similar to create a swap file on my system and it, kind-of, allowed me to hibernate -- in other words I could hibernate and resume but drivers and the like were as messed up as I'd expected from using hibernate on laptops.
But, yes, swap files work just as well as swap partitions and have the benefit of being easily deleatable when, for example, you have 32GB of RAM and only want to mess around with swap.
 
1 members found this post helpful.
  


Reply

Tags
hibernate, hibernation, mate, swap, swapfile



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
High CPU by Xorg on Linux Mint Mate and Ubuntu + Mate ronaldv Linux - Desktop 7 04-11-2017 07:27 AM
LXer: Ubuntu MATE 15.04 Arrives With MATE Desktop 1.8.2 and MATE Tweak LXer Syndicated Linux News 0 05-15-2015 09:30 AM
8.10 partition size requirements for / /home/ /swap /var /usr going from 8.04 Ubuntu Thane Ubuntu 10 11-30-2008 07:27 PM
ubuntu - increase swap size dna9 Linux - Distributions 11 01-24-2005 11:45 AM
Why should you give the size of the swap disk as twice the size of RAM vmniza Linux - Newbie 3 09-17-2004 02:13 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Laptop and Netbook

All times are GMT -5. The time now is 02:01 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