[dm-devel] RE: Error while creating mapped device...

Kevin Corry kevcorry at us.ibm.com
Wed Jun 1 12:46:35 UTC 2005


Hi Manu,

On Wed June 1 2005 3:28 am, Manu Tayal wrote:
> The version of Linux I am using is 2.4.26 and the version of device-mapper
> is 1.00.18.
>
> I found the logs as:
>
>  Device-mapper: device /dev/hda1 too small for target
>  Device-mapper: dm-linear: Device lookup failed
>  Device-mapper: error adding target to table
>
>  Device-mapper: device /dev/hda5 too small for target
>  Device-mapper: dm-linear: Device lookup failed
>  Device-mapper: error adding target to table
>
> So there seems to be some size problem.
>
>  blockdev --getsize /dev/hda1  = 2041137
>  blockdev --getsize /dev/hda5  = 1043217
>
> Is there a limitation on the size of the device or is this a bug?

On 2.4 kernels, block device sizes are normally calculated in kilobytes, 
dispite the output you get from "blockdev --getsize". Thus you should always 
take the size in sectors and round down to the nearest even number so that it 
translates to a whole number of kilobytes. You can do this by simply masking 
off the lowest bit. So the command to create your DM device would look like 
this:

echo 0 $(($(blockdev --getsize /dev/hda1) & ~1)) linear /dev/hda1 0 | \
  dmsetup create hda1

On 2.6 kernels, block device sizes are recorded in sectors, and you would not 
experience this problem.

-- 
Kevin Corry
kevcorry at us.ibm.com
http://www.ibm.com/linux/
http://evms.sourceforge.net/




More information about the dm-devel mailing list