2

I would like to create a COW device for an existing block device using dmsetup. The block device is:

# blockdev --getsz /dev/loop0
3534848

I am trying to use a 256M ramdisk as the backing store:

# blockdev --getsz /dev/zram1
524288

I am using the following command, which appears to match the documentation as well as other sources:

# dmsetup create mysnap --table '0 3534848 snapshot /dev/loop0 /dev/zram1 N 4'

But it fails with:

device-mapper: reload ioctl on mysnap failed: Invalid argument
Command failed

And the kernel provides the following additional information:

[ 8372.346442] device-mapper: table: 253:11: snapshot: Couldn't create exception store
[ 8372.346454] device-mapper: ioctl: error adding target to table

I am hoping someone can explain why the above command is resulting in an error.

larsks
  • 41,276
  • 13
  • 117
  • 170

2 Answers2

0

Apparently it has to do with the chunksize value. Using a chunksize of 4 as in my question results in the error, but if I use 8 or 16, etc, it works just fine:

dmsetup create mysnap --table '0 3534848 snapshot /dev/loop0 /dev/zram1 N 8'
larsks
  • 41,276
  • 13
  • 117
  • 170
0

dmesg was giving me a different error in my case:

[ 5473.934324] device-mapper: table: 253:0: len=1953521668 not aligned to h/w logical block size 4096 of sdb
[ 5473.934327] device-mapper: core: Cannot calculate initial queue limits
[ 5473.934331] device-mapper: ioctl: unable to set up device queue for new table.

I was able to fix this by dropping the length down to the next multiple of 4096 (which I could do, because there were enough unused sectors at the end of the disk).

Possibly the main moral of the story is just that in many cases the kernel may give helpful messages that dmsetup won't necessarily pass on.

mwfearnley
  • 757
  • 9
  • 21