[parted-devel] [PATCH 9/9] libparted: device mapper uses 512b sectors

Brian C. Lane bcl at redhat.com
Fri Feb 6 16:24:47 UTC 2015


On Fri, Feb 06, 2015 at 10:58:44AM -0500, Phillip Susi wrote:
> On 2/5/2015 8:30 PM, Brian C. Lane wrote:
> > device mapper doesn't use the device's sector size when creating a 
> > table. It always uses 512b units. This causes partitions to be
> > created 8x smaller than expected on devices with 4906b sectors.
> 
> I'm confused.  Since devmapper always uses 512 byte sectors, what does
> the sector size of the underlying physical disk have to do with
> anything ( other than alignment )?  We're only dealing with devmapper.

We tell device-mapper the size of the disk and the partitions, right now
we are using native disk sector units for this. We need to make sure we
use 512b units when talking to device-mapper.

> 
> > +        *start *= (part->disk->dev->sector_size /
> > PED_SECTOR_SIZE_DEFAULT); +        *length *=
> > (part->disk->dev->sector_size / PED_SECTOR_SIZE_DEFAULT);
> 
> Since the sector size reported by device mapper is always 512 bytes,
> these statements are effectively no-ops ( 512 / 512 is always 1 ).

Actually, I got this backwards. *start and *length need to be divided
not multiplied.

On a 4k sector disk the device-mapper value will be 8x too large so it
should be:

*start /= (4096 / 512)

On 512b sector disks it will basically be a noop, yes. But they aren't
the problem.

-- 
Brian C. Lane | Anaconda Team | IRC: bcl #anaconda | Port Orchard, WA (PST8PDT)



More information about the parted-devel mailing list