Currently rcscripts/addons/dm-crypt-start.sh checks whether partition is LUKS. However, it is possible to accidentaly point to a partition with data and have the data destroyed. Attached patch uses blkid, to test for recognizable file systems and refuse to initialize swap on the partition.
Created attachment 173104 [details, diff] Add stricter checks for swap partition initialization
I like the idea, but I don't like the dependency on e2fsprogs, although we already have a dependency on e2fsprogs-libs, and if blkid ever recognizes luks partitions, this will break.
Partly ignore that comment. blkid actually recognizes luks devices, but I was thinking about having the blkid check being applied to every source device, not only swap.
I believe that since this situation can lead to data loss, as partition numbers or ids can easily change due to repartitioning, remove or add drives, etc, this should be mentioned in the configuration file (/etc/init.d/dmcrypt) and maybe suggest users to create a standard encrypted partition for their swap and use the target= instead of swap= for it. Although a case of data loss will probably be fault of the end user's poor memory (as he'll probably have forgotten to adjust dmcrypt) it would be better to point out this danger.
*** Bug 289055 has been marked as a duplicate of this bug. ***
Created attachment 387676 [details, diff] add PARTUUID handling Perhaps the "right" solution is to discourage use of explicit (unportable) partitions and to use UUID/PARTUUID instead. It already does the prior but not the latter, and I had interest in PARTUUID since I'm using a real partition (/dev/sdX3). I've modified /etc/init.d/dmcrypt to handle PARTUUID (see attached patch). It doesn't follow the precise mode that it uses to handle UUID, but I couldn't seem to get the % suffix handling working right, so punted and used awk.
i've updated the docs to encourage people to use UUID/PARTUUID: http://sources.gentoo.org/sys-fs/cryptsetup/files/1.0.6-dmcrypt.confd?r1=1.6&r2=1.7 http://sources.gentoo.org/sys-fs/cryptsetup/files/1.5.1-dmcrypt.rc?r1=1.7&r2=1.8