Return-Path: Received: from mout.web.de (mout.web.de [212.227.17.11]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.server123.net (Postfix) with ESMTPS for ; Sun, 23 Oct 2016 12:52:35 +0200 (CEST) Received: from [192.168.123.201] ([77.10.252.20]) by smtp.web.de (mrweb101) with ESMTPSA (Nemesis) id 0Lkh7Q-1cWDhO2wqK-00aVsw for ; Sun, 23 Oct 2016 12:52:34 +0200 References: <20161022095519.00911f8c@ulgy_thing> <3cc57d54-970e-968d-106c-19b767219177@whgl.uni-frankfurt.de> From: Heiko Rosemann Message-ID: <7d77c541-8bed-0c97-0e97-13ddb90adfba@web.de> Date: Sun, 23 Oct 2016 12:52:29 +0200 MIME-Version: 1.0 In-Reply-To: <3cc57d54-970e-968d-106c-19b767219177@whgl.uni-frankfurt.de> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="S4o7v9i2Eqbawwh6MTU4eQuKG2k0ooeI5" Subject: Re: [dm-crypt] How to suspend to disk with random encrypted swap List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: dm-crypt@saout.de This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --S4o7v9i2Eqbawwh6MTU4eQuKG2k0ooeI5 Content-Type: multipart/mixed; boundary="sVPkSuF4msiq2m5DoN7nQ6d17p7cTLxAa"; protected-headers="v1" From: Heiko Rosemann To: dm-crypt@saout.de Message-ID: <7d77c541-8bed-0c97-0e97-13ddb90adfba@web.de> Subject: Re: [dm-crypt] How to suspend to disk with random encrypted swap References: <20161022095519.00911f8c@ulgy_thing> <3cc57d54-970e-968d-106c-19b767219177@whgl.uni-frankfurt.de> In-Reply-To: <3cc57d54-970e-968d-106c-19b767219177@whgl.uni-frankfurt.de> --sVPkSuF4msiq2m5DoN7nQ6d17p7cTLxAa Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Hi David, Sven is right, this is not really a cryptsetup question... However, let me add a few more pointers to his answers: Basically, you'll have the same problem as someone booting with an encrypted root fs, so you can start there: https://wiki.gentoo.org/wiki/Dm-crypt_full_disk_encryption#Generating_an_= initramfs - you'll need to add to your initramfs some code to luksOpen the swap partition (one way or another) and then start the resuming process. The swap partition obviously can't be encrypted with a random passphrase, but probably setting it up just like a "normal" data partition in gentoo will give you the correct result. For starting the resuming process, you'll need to write "MAJOR:MINOR" of your resuming device (probably something like /dev/mapper/swap) into /sys/power/resume - the way my Slackware does that is the following in the init script of the initramfs: # Resume state from swap if [ "$RESUMEDEV" !=3D "" ]; then # Find resume device if a label or UUID was given: if echo $RESUMEDEV | grep -q "LABEL=3D" || \ echo $RESUMEDEV | grep -q "UUID=3D" ; then RESUMEDEV=3D$(findfs $RESUMEDEV) elif ls -l $RESUMEDEV | grep -q "^l" ; then RESUMEDEV=3D$(readlink -f $RESUMEDEV) fi echo "Trying to resume from $RESUMEDEV" RESMAJMIN=3D$(ls -l $RESUMEDEV | tr , : | awk '{ print $5$6 }') echo $RESMAJMIN > /sys/power/resume fi I don't know if gentoo has a similar setup ready out of the box. Good luck, and remember to backup early and often ;) Heiko On 10/23/2016 12:27 AM, Sven Eschenberg wrote: > Not really a cryptsetup question. >=20 > You should be aware of the fact, that suspend to disk on a randomly=20 > encrypted swap cannot work (for obvious reasons). In any way, you'll=20 > need to start the kernel and give it a way to read the disk image. The = > diskimage however should be encrypted for obvious reasons. >=20 > How can you resolve the hen and egg problem? >=20 > You can't with complete randomness. >=20 > You'll have to either: > 1.) have a fixed passphrase for your swap, unlock swap during boot and = > then resume > 2.) store your in memory image at some other place than swap, again,=20 > that place should be encrypted - you could possibly store the image on = > /, then you'll have to unlock / during boot to resume. > 3.) forget about suspend alltogether. >=20 > To answer your questions to some extent: > The kernel will first try to find a suspend image signature on the=20 > default swap partition, the location can however be overridden with=20 > resume=3D, the gory details are in the kernel's documentation on boot=20 > parameters. The kernel will resume, if there's an image accessible, thi= s=20 > can however be overridden with hibernate=3D . >=20 > Regards >=20 > -Sven >=20 >=20 > Am 22.10.2016 um 15:55 schrieb David Niklas: >> Hello, >> I use a random encrypted swap partition, and I want to suspend my syst= em >> to disk. I'm having two problems. >> 1. How does the kernel know where to resume from/at all? >> 2. How do I get the random passphrase for decrypting the swap (and >> remember it)? >> >> Gentoo linux >> cryptsetup 1.7.2 >> >> ###### /etc/conf.d/dmcrypt ######### >> >> swap=3Dswap >> options=3D' -c aes -h sha256 -d /dev/urandom ' >> source=3D'/dev/sda2' >> >> #################################### >> >> Thanks, >> David >> _______________________________________________ >> dm-crypt mailing list >> dm-crypt@saout.de >> http://www.saout.de/mailman/listinfo/dm-crypt >> > _______________________________________________ > dm-crypt mailing list > dm-crypt@saout.de > http://www.saout.de/mailman/listinfo/dm-crypt >=20 --=20 eMails verschl=FCsseln mit PGP - privacy is your right! Mein PGP-Key zur Verifizierung: http://pgp.mit.edu --sVPkSuF4msiq2m5DoN7nQ6d17p7cTLxAa-- --S4o7v9i2Eqbawwh6MTU4eQuKG2k0ooeI5 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iEYEARECAAYFAlgMlnAACgkQ/Vb5NagElAUpLwCeLm4rP4Ob8zWcL4BCT1Hf7KT4 u+AAnR26adb+VaVcvzo20CiuKmGQ1NbN =sM+F -----END PGP SIGNATURE----- --S4o7v9i2Eqbawwh6MTU4eQuKG2k0ooeI5--