* blkid doesn't find lvm pv when boot loader installed
@ 2013-10-11 16:05 Phillip Susi
2013-10-14 13:59 ` Karel Zak
0 siblings, 1 reply; 5+ messages in thread
From: Phillip Susi @ 2013-10-11 16:05 UTC (permalink / raw)
To: util-linux
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
When installing a boot loader into an LVM PV, blkid detects it as a
dos partition table and does not probe the lvm superblock.
Easy way to reproduce is to pvcreate a volume, then xxd -r the
following grub boot sector into it:
0000000: eb63 9000 0000 0000 0000 0000 0000 0000 .c..............
0000010: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0000020: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0000030: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0000040: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0000050: 0000 0000 0000 0000 0000 0080 7eb0 0300 ............~...
0000060: 0000 0000 fffa 9090 f6c2 8074 05f6 c270 ...........t...p
0000070: 7402 b280 ea79 7c00 0031 c08e d88e d0bc t....y|..1......
0000080: 0020 fba0 647c 3cff 7402 88c2 52be 807d . ..d|<.t...R..}
0000090: e817 01be 057c b441 bbaa 55cd 135a 5272 .....|.A..U..ZRr
00000a0: 3d81 fb55 aa75 3783 e101 7432 31c0 8944 =..U.u7...t21..D
00000b0: 0440 8844 ff89 4402 c704 1000 668b 1e5c .@.D..D.....f..\
00000c0: 7c66 895c 0866 8b1e 607c 6689 5c0c c744 |f.\.f..`|f.\..D
00000d0: 0600 70b4 42cd 1372 05bb 0070 eb76 b408 ..p.B..r...p.v..
00000e0: cd13 730d f6c2 800f 84d8 00be 8b7d e982 ..s..........}..
00000f0: 0066 0fb6 c688 64ff 4066 8944 040f b6d1 .f....d.@f.D....
0000100: c1e2 0288 e888 f440 8944 080f b6c2 c0e8 .......@.D......
0000110: 0266 8904 66a1 607c 6609 c075 4e66 a15c .f..f.`|f..uNf.\
0000120: 7c66 31d2 66f7 3488 d131 d266 f774 043b |f1.f.4..1.f.t.;
0000130: 4408 7d37 fec1 88c5 30c0 c1e8 0208 c188 D.}7....0.......
0000140: d05a 88c6 bb00 708e c331 dbb8 0102 cd13 .Z....p..1......
0000150: 721e 8cc3 601e b900 018e db31 f6bf 0080 r...`......1....
0000160: 8ec6 fcf3 a51f 61ff 265a 7cbe 867d eb03 ......a.&Z|..}..
0000170: be95 7de8 3400 be9a 7de8 2e00 cd18 ebfe ..}.4...}.......
0000180: 4752 5542 2000 4765 6f6d 0048 6172 6420 GRUB .Geom.Hard
0000190: 4469 736b 0052 6561 6400 2045 7272 6f72 Disk.Read. Error
00001a0: 0d0a 00bb 0100 b40e cd10 ac3c 0075 f4c3 ...........<.u..
00001b0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00001c0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00001d0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00001e0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00001f0: 0000 0000 0000 0000 0000 0000 0000 55aa ..............U.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (MingW32)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iQEcBAEBAgAGBQJSWCG2AAoJEJrBOlT6nu759noIAK7V5ZjDb1skpoIsQKLBGEty
5wU9Cm4yBJ9/uRhsE/w6kahZDQvjcj7jUZoYNpau94NySRLZ10QNBvMBZiflMaZF
9lZ2dtATh57eo0PvDPZ25ZgKO9rYzeAlrGx86/FffxmCpKzPAzRk7g4ggVtItEtl
irUtru4rDMdaKdfJQ9rSlYA7JcI/OcPiORUQQ+Zm1Ff2eRUSFr/8AWZrMD/oHMKb
qzln7tzKCktnKY1Iyyhr2mrNBxXxFV0QB7ObihQZxHrOmMTJTWIREVTPmDSp+jOX
7RHzV6DHLxR80HN2I2Y5iM4rEipQGxJ5Img/K6QPHWgo1BobfZNoeqe7o4lJwRg=
=rwTa
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: blkid doesn't find lvm pv when boot loader installed
2013-10-11 16:05 blkid doesn't find lvm pv when boot loader installed Phillip Susi
@ 2013-10-14 13:59 ` Karel Zak
2013-10-14 15:01 ` Phillip Susi
0 siblings, 1 reply; 5+ messages in thread
From: Karel Zak @ 2013-10-14 13:59 UTC (permalink / raw)
To: Phillip Susi; +Cc: util-linux
On Fri, Oct 11, 2013 at 12:05:10PM -0400, Phillip Susi wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> When installing a boot loader into an LVM PV, blkid detects it as a
> dos partition table and does not probe the lvm superblock.
Yes, unfortunately this is currently unsupported scenario.
The libblkid checks for collision between LVM and filesystems/partition
tables to avoid very common situations when users use whole-disks
previously used by LVM in new setups with partition tables.
Unfortunately, partitioning tools usually does not wipe LVM header
from the device and it easy to create situation when there is
valid PT as well as valid LVM header.
So.. libblkid assumes that there is only LVM header within first 8K
of the device, because pvcreate wipes this area (try pvcreate again
and it will silently erase your grub!). If there is anything else
then the previously detected LVM is ignored.
Yes, it's really not perfect solution, but do we have any better
solution? Maybe it would be enough to improve the blkid partition
table parser to not interpret the boot loader with empty PT as a
valid PT. Not sure.
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: blkid doesn't find lvm pv when boot loader installed
2013-10-14 13:59 ` Karel Zak
@ 2013-10-14 15:01 ` Phillip Susi
2013-10-18 9:36 ` Karel Zak
0 siblings, 1 reply; 5+ messages in thread
From: Phillip Susi @ 2013-10-14 15:01 UTC (permalink / raw)
To: Karel Zak; +Cc: util-linux
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 10/14/2013 9:59 AM, Karel Zak wrote:
> Yes, unfortunately this is currently unsupported scenario.
>
> The libblkid checks for collision between LVM and
> filesystems/partition tables to avoid very common situations when
> users use whole-disks previously used by LVM in new setups with
> partition tables.
Isn't mdadm in the same boat? i.e. you have a partitioned single
disk, and decided to turn it into a raid1. Now the partition table is
still there and valid, but should be ignored in favor of the raid
superblock.
> Unfortunately, partitioning tools usually does not wipe LVM header
> from the device and it easy to create situation when there is
> valid PT as well as valid LVM header.
>
> So.. libblkid assumes that there is only LVM header within first
> 8K of the device, because pvcreate wipes this area (try pvcreate
> again and it will silently erase your grub!). If there is anything
> else then the previously detected LVM is ignored.
>
> Yes, it's really not perfect solution, but do we have any better
> solution? Maybe it would be enough to improve the blkid partition
> table parser to not interpret the boot loader with empty PT as a
> valid PT. Not sure.
I started thinking along those lines, but it doesn't cover the above
mentioned raid1 case.
I'm now leaning towards thinking that any partition tool that doesn't
wipe the existing signatures is broken, and that's what needs fixed
rather than trying to work around it in blkid.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (MingW32)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iQEcBAEBAgAGBQJSXAdDAAoJEJrBOlT6nu75SngH/28P2VeL2Mki64ZJc3t1Mejy
ceRaOu3bEgmoskPD6esaRsOOUODFaN+KzdacB3fAoql0gQJwHMvNWmnOdgK5Cn+r
0BCGAB+5WdReOBQE4T5ey2pmkmD5G+rRuwx+e8tCfQ6yKkjU1kw80tecCXq9WgIQ
SYPgclR4BILGxaIutCOXAuzk52Q5Dteq/3BaWP7o8qWmKXG6P31SWG9Frm4GtAd9
OWXHZSsf6W9S9lCrSlgY85ptq9x6GE2llFhRZoZpxR18F4zQHW0RId49tr7PLxVS
wU9dUbAoT6KFDErUbXNBAgYn0He8nYT3X1jZs4SOEyICM3hSmSc2+2sDicn51+g=
=3j23
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: blkid doesn't find lvm pv when boot loader installed
2013-10-14 15:01 ` Phillip Susi
@ 2013-10-18 9:36 ` Karel Zak
2013-10-18 11:57 ` Karel Zak
0 siblings, 1 reply; 5+ messages in thread
From: Karel Zak @ 2013-10-18 9:36 UTC (permalink / raw)
To: Phillip Susi; +Cc: util-linux
On Mon, Oct 14, 2013 at 11:01:23AM -0400, Phillip Susi wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 10/14/2013 9:59 AM, Karel Zak wrote:
> > Yes, unfortunately this is currently unsupported scenario.
> >
> > The libblkid checks for collision between LVM and
> > filesystems/partition tables to avoid very common situations when
> > users use whole-disks previously used by LVM in new setups with
> > partition tables.
>
> Isn't mdadm in the same boat? i.e. you have a partitioned single
> disk, and decided to turn it into a raid1. Now the partition table is
> still there and valid, but should be ignored in favor of the raid
> superblock.
Yes, and with raids it's more complicated because if the raid1
superblock is at the end of the device and the raid device is partitioned
then there is a partition table at the begin as well as raid
superblock at the end and all is valid and wanted :-)
(So in these cases we have to parse PT and raid superblock to check
if the PT is within raid or vice versa.. nasty.. fortunately the
current Linux raid default is superblock at the begin of the device.)
> > So.. libblkid assumes that there is only LVM header within first
> > 8K of the device, because pvcreate wipes this area (try pvcreate
> > again and it will silently erase your grub!). If there is anything
> > else then the previously detected LVM is ignored.
> >
> > Yes, it's really not perfect solution, but do we have any better
> > solution? Maybe it would be enough to improve the blkid partition
> > table parser to not interpret the boot loader with empty PT as a
> > valid PT. Not sure.
>
> I started thinking along those lines, but it doesn't cover the above
> mentioned raid1 case.
libblkid cover both cases
> I'm now leaning towards thinking that any partition tool that doesn't
> wipe the existing signatures is broken
fdisk currently wipes the first sector only, the problem is that we
have to somehow live with boot loaders or partitioned raids etc.
IMHO it is more important to wipe devices in mkfs-like programs where
anything else than the FS/LVM/etc is unexpected.
Now when I'm thinking about it ... maybe it would be good idea to add
to fdisk a warning to inform users that there is not only the new
partition table but also anything else.
> and that's what needs fixed
> rather than trying to work around it in blkid.
Well, we don't control all the programs and the problem is that users
have already partitioned/LVM disks with obsolete superblocks/PT for
years, when we ported all the stuff to udev then it was visible and
reported as regressions...
BTW, libblkid provides API to wipe devices
fd = open(devname, O_RDWR|O_CLOEXEC);
blkid_probe_set_device(pr, fd, 0, 0);
blkid_probe_enable_partitions(pr, 1);
blkid_probe_enable_superblocks(pr, 1);
blkid_probe_set_superblocks_flags(pr, BLKID_SUBLKS_MAGIC);
while (blkid_do_probe(pr) == 0)
blkid_do_wipe(pr, FALSE);
...to wipe all from the device, nice is that it removes only magic
strings, so you don't lost data if you make a mistake (wipefs(8)
backup the magic strings too).
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: blkid doesn't find lvm pv when boot loader installed
2013-10-18 9:36 ` Karel Zak
@ 2013-10-18 11:57 ` Karel Zak
0 siblings, 0 replies; 5+ messages in thread
From: Karel Zak @ 2013-10-18 11:57 UTC (permalink / raw)
To: Phillip Susi; +Cc: util-linux
On Fri, Oct 18, 2013 at 11:36:17AM +0200, Karel Zak wrote:
> Now when I'm thinking about it ... maybe it would be good idea to add
> to fdisk a warning to inform users that there is not only the new
> partition table but also anything else.
implemented in libfdisk branch on github
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-10-18 11:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-11 16:05 blkid doesn't find lvm pv when boot loader installed Phillip Susi
2013-10-14 13:59 ` Karel Zak
2013-10-14 15:01 ` Phillip Susi
2013-10-18 9:36 ` Karel Zak
2013-10-18 11:57 ` Karel Zak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox