I have a 1 TB drive attached via USB. It contains an LVM physical volume filling the entire device (without any partition table). When I tried to extend a logical volume by using the entire PV, the device-mapper started to complain that the section allocated by LVM on the PV is larger than the device. The error message from the device-mapper (as shown by dmesg) reports a size of 1953320367 [dm] sectors:
device-mapper: table: 254:0: sdf too small for target: start=1821353984, len=132169728, dev_size=1953320367
But LVM created a PV with 238467 physical extents, which is 1953521664 [lvm] sectors (which is about 100 MB more):
$ pvdisplay /dev/sdf
--- Physical volume ---
PV Name /dev/sdf
VG Name apu-vg1
PV Size 931.51 GiB / not usable 1.71 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 238467
Free PE 100
Allocated PE 238367
PV UUID LrKDDW-4dXz-kDgh-CK78-OWhY-4sCH-rKT0e4
Now if I run hdparm -gI on the device, I can see two values for the size of the device. Under geometry, there's the same value that is reported by the device-mapper as the device's size. But under LBA48 user addressable sectors, there's the value 1953525168 [lba], which is less than one PE larger than the combines size of the PEs of the PV. This makes me think that this is the value that LVM sees:
$ hdparm -Ig /dev/sdf
/dev/sdf:
geometry = 121588/255/63, sectors = 1953320367, start = 0
ATA device, with non-removable media
Model Number: ST1000LM024 HN-M101MBB
Serial Number: S2RUJ9BC702524
Firmware Revision: 2AR10001
Transport: Serial, ATA8-AST, SATA 1.0a, SATA II Extensions, SATA Rev 2.5, SATA Rev 2.6, SATA Rev 3.0
Standards:
Used: unknown (minor revision code 0x0028)
Supported: 8 7 6 5
Likely used: 8
Configuration:
Logical max current
cylinders 16383 16383
heads 16 16
sectors/track 63 63
--
CHS current addressable sectors: 16514064
LBA user addressable sectors: 268435455
LBA48 user addressable sectors: 1953525168
...
Now to my questions:
- Why are there two different values for the device's size used by different parts of the kernel?
- And, how do I handle/fix this situation so that the LVM will not make PVs that are larger than the space the device-mapper is willing/able to access?