this sequence on a machine with 4k page size: xfs_io -F -c "pwrite 0 4096" /dev/sdb2 pvcreate -u 92e4895d-a9c2-4a70-8f02-b8f67372e506 /dev/sdb2 mkswap -U 92e4895d-a9c2-4a70-8f02-b8f67372e506 /dev/sdb2 generates exactly the same first 4k on the block device as this sequence: xfs_io -F -c "pwrite 0 4096" /dev/sdb2 mkswap -U 92e4895d-a9c2-4a70-8f02-b8f67372e506 /dev/sdb2 pvcreate -u 92e4895d-a9c2-4a70-8f02-b8f67372e506 /dev/sdb2 making it awfully hard to know if the device is truly swap or not: 00000000 cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd |................| * 00000200 4c 41 42 45 4c 4f 4e 45 01 00 00 00 00 00 00 00 |LABELONE........| 00000210 19 e6 90 d1 20 00 00 00 4c 56 4d 32 20 30 30 31 |.... ...LVM2 001| 00000220 39 32 65 34 38 39 35 64 61 39 63 32 34 61 37 30 |92e4895da9c24a70| 00000230 38 66 30 32 62 38 66 36 37 33 37 32 65 35 30 36 |8f02b8f67372e506| 00000240 00 d0 2d e6 1b 00 00 00 00 00 03 00 00 00 00 00 |..-.............| 00000250 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 00000260 00 00 00 00 00 00 00 00 00 10 00 00 00 00 00 00 |................| 00000270 00 f0 02 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 00000280 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * 00000400 01 00 00 00 dc 62 be 01 00 00 00 00 92 e4 89 5d |.....b.........]| 00000410 a9 c2 4a 70 8f 02 b8 f6 73 72 e5 06 00 00 00 00 |..Jp....sr......| 00000420 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * 00000ff0 00 00 00 00 00 00 53 57 41 50 53 50 41 43 45 32 |......SWAPSPACE2| 00001000 (the xfs_io command simply patterns the first 4k to make it obvious what has been re-written) It seems like it would be wise for pvcreate to zero out at least the first page-sized chunk of the device, to eliminate old swap signatures or anything else that might be out there. Thanks, -Eric
LVM2 wipes the first 2k (see man page) as that's where LVM2 can write its label (depending on options). There is an option already to disable wiping that. I think it's probably safe to increase the amount it wipes - though it might be better to add a check for a swap signature and require confirmation first.
Ah, sorry, missed the part in the manpage about not doing the wiping if --uuid is specified. I'm on the fence about asking for confirmation if swap is found; should you check for every old signature of everything you might find? It gets cumbersome...
This is also partially related to https://bugzilla.redhat.com/show_bug.cgi?id=174700 (about the warning). Increasing wipe size is certainly an option as well (I don't think this will have any adverse effects, so I'm all for doing that in CVS).
Changing version to '9' as part of upcoming Fedora 9 GA. More information and reason for this action is here: http://fedoraproject.org/wiki/BugZappers/HouseKeeping
Unless it's particularly awkward to do, I'd prefer to recognise the signature in pvcreate.c and ask people whether or not to wipe it, like we do with md superblocks, so they are aware of what they are doing.
Created attachment 335395 [details] lvm-pvcreate-wipe-swap.diff Proposed patch to address this issue. Upstream review pending.
This has been checked in upstream.