Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
No Persistent SWAP with dmcrypt
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
paradigm-X
Apprentice
Apprentice


Joined: 19 Sep 2013
Posts: 168

PostPosted: Tue Jan 28, 2014 4:47 pm    Post subject: No Persistent SWAP with dmcrypt Reply with quote

I cannot figure out how to get a 100% persistent encrypted swap partition with dmcrypt/LUKS. I have a machine that often boots Gentoo OS from an externally enclosed hard disk attached to one of its USB ports. The data on the disk is encrypted with dmcrypt/LUKS, and it includes three partitions, one of which is for encrypted SWAP.

Normally, when this external disk is booted, it gets labeled as sda. There are other disks accessible to the OS after booting as well, such as sdb, sdc, etc. Right after booting I can use this command to get the following results, 'lsblk -f':

#NAME FSTYPE LABEL UUID MOUNTPOINT
#sda
#L sda1 ext2 Boot fb143bb59-...
#L sda2
#| L crypt-swap (dm-1) swap 6aff7ced-... [SWAP]
#L sda3 crypto_LUKS 942fcf207...
#| L root (dm-0) /


Corresponding to these partitions, I have the following in 'etc/fstab':

#LABEL=BOOT /boot ext2 noauto,noatime 1 2
#/dev/mapper/root / ext4 noatime,discard 0 1
#/dev/mapper/crypt-swap none swap sw 0 0


Additionally, I made the following settings in '/etc/conf.d/dmcrypt':

swap=crypt-swap
source='/dev/sda2'

However, this setup is inadequate because the label sda2 can move from one partition to another between boots. There is nothing in fstab that I can assign to the correct swap partition because it gets randomly encrypted on every boot, and this procedure causes LABEL and UUID to change. This sort of moving from one partition to another seldom happens, but it can and has happened on occassion, especially whenever I might have altered the number of disks available during boot. I now have to watch carefully to monitor this by using 'lsblk -f'. If it has moved, I have to reboot once in order to correct it. Consider if I had not noticed that it moved incorrectly and the swap got assigned to the 2nd partition of a different disk from the root partition, and if this other partition were, say, Windows OS partition?

If anyone sees a way around this without loosing any of my current functionality, I would like to hear about it.

Sorry for the messy appearance of this illustration, but I haven't yet figured out how to make the columns retain spacing formats used while creating the message.
Back to top
View user's profile Send private message
WorBlux
n00b
n00b


Joined: 07 May 2011
Posts: 39

PostPosted: Tue Jan 28, 2014 8:21 pm    Post subject: Reply with quote

If you are using a GPT partition table, each partition has a gpt-uuid that is seperate from the filesystem uuid and AFAIK is created when you make the partition.

http://www.linux.com/learn/tutorials/730440-using-the-new-guid-partition-table-in-linux-good-bye-ancient-mbr-
Back to top
View user's profile Send private message
paradigm-X
Apprentice
Apprentice


Joined: 19 Sep 2013
Posts: 168

PostPosted: Tue Jan 28, 2014 9:59 pm    Post subject: Reply with quote

> "If you are using a GPT partition table, each partition has a gpt-uuid that is seperate from the filesystem uuid..."

I do like the way you think, WorBlux! That sounds like the best idea I have come across so far, and man have I been looking around for one. I need to study it more now to see how it might impact KVM/Qemu. Thanks for the link too. :)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum