LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 05-13-2017, 03:38 PM   #1
hyperhead
Member
 
Registered: Mar 2011
Location: UK
Distribution: Slackware-14.2
Posts: 117

Rep: Reputation: 19
Ecrypted swap with hibernate, resume not working


Hi

I'm running Slackware-current and had hibernate working fine with a standard swap file.

I decided to encrypted my swap partition and try that with hibernate. It doesn't seem to work (or it does seem to hibernate, but ignores resume when powered on)

I have followed the guide here: http://slackware.osuosl.org/slackwar...ADME_CRYPT.TXT and looking at crypsetup and swap everything is fine for hibernate, but when I power on the resume in elilo and mkinitrd seem to be ignored. (butare present in elilo.con / dmesg for Kernel command line in dmesg)

Has anybody got an encrypted swap partition that they hibernate resume from regularly, I can't see what I'm doing wrong here

Shown are the pertinent configurations and statuses that show it looking ok, I don't see any errors that might indicate that it has not saved to swap and I get prompted for my password or /dev/mapper/swap on boot to unencrypt the partition.

There isn't much written about resume only to add it to the lilo.conf and re-run mkinitrd with -h option pointing at swap partiton. ( I use elilo, and have added the resume entry)

/Thanks

Code:
Cryptsetup status: 
================== 
/dev/mapper/swap is active and is in use.
  type:    LUKS1
  cipher:  aes-xts-plain64
  keysize: 256 bits
  device:  /dev/sda3
  offset:  4096 sectors
  size:    15560704 sectors
  mode:    read/write

Swap status: 
================== 
Filename                                Type            Size    Used    Priority
/dev/dm-0                               partition       7780348 0       -1

Crypttab status: 
================== 
#swap /dev/sda3 /dev/random swap,cipher=aes-xts-essiv:sha256
swap /dev/sda3 none swap

Fstab status
================== 
/dev/mapper/swap swap swap defaults 0 0

Elilo status
================== 
chooser=simple
delay=1
timeout=1
#
image=vmlinuz
        label=vmlinuz
        initrd=initrd.gz
        read-only
        append="root=/dev/sda5 vga=normal resume=/dev/mapper/swap ro"

Mkinitrd confirmation in dmesg
==============================
[    0.000000] Command line: BOOT_IMAGE=dev000:\EFI\Slackware\vmlinuz  root=/dev/sda5 vga=normal resume=/dev/mapper/swap ro ro
[    0.000000] Kernel command line: BOOT_IMAGE=dev000:\EFI\Slackware\vmlinuz  root=/dev/sda5 vga=normal resume=/dev/mapper/swap ro ro
[   19.603374] Adding 7780348k swap on /dev/mapper/swap.  Priority:-1 extents:1 across:7780348k SS

Upower for hibernate shown in /var/log/messages
===============================================
May 14 22:15:45 darkstar dbus[1065]: [system] Activating service name='org.freedesktop.UPower' (using servicehelper)
May 14 22:15:45 darkstar dbus[1065]: [system] Successfully activated service 'org.freedesktop.UPower'
 
Old 05-13-2017, 07:54 PM   #2
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,776

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
It can't work with a random key. The only record of that key is in the kernel memory saved in that encrypted space. See the problem?

There are various alternatives to using that random key. A search for "hibernate+encrypted+swap" will yield several good links.
 
Old 05-13-2017, 10:20 PM   #3
v3g4n
LQ Newbie
 
Registered: Mar 2017
Distribution: Slackware
Posts: 18

Rep: Reputation: 3
I am not use elilo, lilo instead, but can only say that hibernation is working fine for me once I added "resume=/dev/cryptvg/swap" to /etc/lilo.conf and -h when I ran mkinitrd.sh.
Not sure if it will help, but here is where I added the -h for mkinird.sh
Code:
mkinitrd -c -h -k 4.4.38 -f ext4 -r /dev/cryptvg/root -m jbd2:mbcache:ext4 -C /dev/sda2 -L -u -o /boot/initrd.gz
Hope it helps.
 
Old 05-14-2017, 03:51 AM   #4
hyperhead
Member
 
Registered: Mar 2011
Location: UK
Distribution: Slackware-14.2
Posts: 117

Original Poster
Rep: Reputation: 19
Quote:
Originally Posted by rknichols View Post
It can't work with a random key. The only record of that key is in the kernel memory saved in that encrypted space. See the problem?

There are various alternatives to using that random key. A search for "hibernate+encrypted+swap" will yield several good links.
Hi, I removed the random key and used a password and it decrypts fine on first boot.

However I will regoogle with your search terms as I never yielded much results.
 
Old 05-14-2017, 03:52 AM   #5
hyperhead
Member
 
Registered: Mar 2011
Location: UK
Distribution: Slackware-14.2
Posts: 117

Original Poster
Rep: Reputation: 19
Quote:
Originally Posted by v3g4n View Post
I am not use elilo, lilo instead, but can only say that hibernation is working fine for me once I added "resume=/dev/cryptvg/swap" to /etc/lilo.conf and -h when I ran mkinitrd.sh.
Not sure if it will help, but here is where I added the -h for mkinird.sh
Code:
mkinitrd -c -h -k 4.4.38 -f ext4 -r /dev/cryptvg/root -m jbd2:mbcache:ext4 -C /dev/sda2 -L -u -o /boot/initrd.gz
Hope it helps.
Hi I can try re-run mkinitrd.sh as mine was a bit different to that. I am only using encrypted swap no LVM volumes or anything, so I didnt follow the full guide for that.

Thanks
 
Old 05-14-2017, 04:03 AM   #6
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 8,559

Rep: Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106
Quote:
Originally Posted by hyperhead View Post
Hi

I'm running Slackware-current and had hibernate working fine with a standard swap file.

I decided to encrypted my swap partition and try that with hibernate. It doesn't seem to work (or it does seem to hibernate, but ignores resume when powered on)

I have followed the guide here: http://slackware.osuosl.org/slackwar...ADME_CRYPT.TXT and looking at crypsetup and swap everything is fine for hibernate, but when I power on the resume in elilo and mkinitrd seem to be ignored.
I guess you did not read that README in full, or did not realize the importance of some parts of the text.

In the section about encrypting your swap, there's two notes:

Code:
NOTE: the swap partition is encrypted with a new randomly generated key every
      time your computer boots.
      There is no need to ever enter a passphrase!

NOTE: having an encrypted swap like this causes a re-format of the swap
      partition on avery boot-up and shutdown.  This is perfectly OK as long
      as you do not change the order of your hard disks.  If you add a disk,
      or move this disk to another computer, the device name may change (for
      instance from sda to sdb) and if you forget to modify '/etc/crypttab'
      your system may end up formatting the wrong partition!
      For this reason alone, it is recommended that you implement disk
      encryption including swap using the "Combining LUKS and LVM" method
      described in the chapter with the same name!
 
Old 05-14-2017, 04:24 AM   #7
hyperhead
Member
 
Registered: Mar 2011
Location: UK
Distribution: Slackware-14.2
Posts: 117

Original Poster
Rep: Reputation: 19
Quote:
Originally Posted by Alien Bob View Post
I guess you did not read that README in full, or did not realize the importance of some parts of the text.

In the section about encrypting your swap, there's two notes:

Code:
NOTE: the swap partition is encrypted with a new randomly generated key every
      time your computer boots.
      There is no need to ever enter a passphrase!

NOTE: having an encrypted swap like this causes a re-format of the swap
      partition on avery boot-up and shutdown.  This is perfectly OK as long
      as you do not change the order of your hard disks.  If you add a disk,
      or move this disk to another computer, the device name may change (for
      instance from sda to sdb) and if you forget to modify '/etc/crypttab'
      your system may end up formatting the wrong partition!
      For this reason alone, it is recommended that you implement disk
      encryption including swap using the "Combining LUKS and LVM" method
      described in the chapter with the same name!
Hi, I am not using a randomly generated key for the swap partition, but used the method for encrypting the home partition

Code:
cryptsetup -s 256 -y luksFormat /dev/sdx2
I also tried with the random key in an earlier attempt and got the same results. I deviated as the previous method of the random key as that did not work either, so I didn't see an issue with using a passphrase for decrypting the partition used for resume

I did take note of the fact if I got the partition wrong in crypttab I could end up hosing my OS, this was a risk I was willing to take and it was only for that reason that LVM was recommended.

I am not installing up my Slackware from scratch and just had the whim to encrypt my swap space that I use for hibernate.

I will re-read and implement again and maybe not be so cavalier with my alteration of the documented method!

Thanks for the input.
 
Old 05-17-2017, 02:03 PM   #8
brobr
Member
 
Registered: Oct 2003
Location: uk
Distribution: Slackware
Posts: 973

Rep: Reputation: 238Reputation: 238Reputation: 238
Did you try to include the encrypted swap-partition for the -h flag to point at in your mkinitrd? Such as:
Code:
mkinitrd -c -k <kernel> -m ext4 -f ext4 -r /dev/sdXx -h /dev/cryptvg/swap -C /dev/sda5 -L -l gb -o initrd-<kernel>.gz
 
Old 05-18-2017, 01:41 PM   #9
hyperhead
Member
 
Registered: Mar 2011
Location: UK
Distribution: Slackware-14.2
Posts: 117

Original Poster
Rep: Reputation: 19
Quote:
Originally Posted by brobr View Post
Did you try to include the encrypted swap-partition for the -h flag to point at in your mkinitrd? Such as:
Code:
mkinitrd -c -k <kernel> -m ext4 -f ext4 -r /dev/sdXx -h /dev/cryptvg/swap -C /dev/sda5 -L -l gb -o initrd-<kernel>.gz

Yes I did. It didnt work for me. I will revisit this task another day....

Thanks for input
 
Old 05-29-2017, 08:35 AM   #10
brobr
Member
 
Registered: Oct 2003
Location: uk
Distribution: Slackware
Posts: 973

Rep: Reputation: 238Reputation: 238Reputation: 238
Hi, are you still looking for a solution?

During a kernel-upgrade I noticed that in my elilo.conf I have this line for each image:
Quote:
append="root=proc vga=normal ro resume=/dev/cryptvg/swap"
Does the append line in your (e)lilo.conf contains something like " resume=/dev/cryptvg/swap", to help to resume your encrypted swap?

HTH

Rob
 
  


Reply



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
Can't resume after hibernate tux360 Linux - Software 3 10-14-2013 12:59 PM
Hibernate does not Resume - Slackware 13.37 xp19375 Linux - Newbie 2 01-25-2012 11:07 AM
[SOLVED] Why do nVida drivers hose suspend/resume or hibernate/resume? taylorkh Linux - Hardware 3 06-23-2011 01:09 PM
Hibernate stopped working properly after accidental swap formatting shadogamon Linux - Laptop and Netbook 3 06-05-2011 08:59 PM
Mini HOW-TO: Hibernate and resume cwwilson721 Slackware 12 03-13-2006 03:54 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

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

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