I have the following setup: pv (/dev/sda2) -> vg (name: vg) -> lv (name: test)
I would like to create a loopback device on /dev/sda2 (using offset) so the loopback will be exactly the test logical volume.
It is working with a testfile but somehow It is not working with a "real device".
So the steps are the following:
1., Clean the lv and create a pattern that I should find at the begin of the loopback device
# dd if=/dev/zero of=/dev/mapper/vg-test
# echo 'AAAA' > /dev/mapper/vg-test
# sync
# hexdump -C -n 10 /dev/mapper/vg-test
00000000 41 41 41 41 0a 00 00 00 00 00 |AAAA......|
0000000a
2., Check the PE size (4M)
# pvdisplay |grep 'PE Size'
PE Size 4.00 MiB
3., Check where is the first PE on the partition (1M)
# pvs -o +pe_start
PV VG Fmt Attr PSize PFree 1st PE
/dev/sda2 vg lvm2 a-- 465.56g 0 1.00m
4., Check where the lv is located on the pv (starting at the 11776 PE)
# lvdisplay -m vg/test
--- Logical volume ---
LV Name /dev/vg/test
VG Name vg
LV UUID vT5X5z-1CJH-uw4n-Jcs8-DW50-PDDB-N6PlIu
LV Write Access read/write
LV Status available
# open 0
LV Size 419.56 GiB
Current LE 107408
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:4
--- Segments ---
Logical extent 0 to 107407:
Type linear
Physical volume /dev/sda2
Physical extents 11776 to 119183
5., Create a loopback device on /dev/sda2 (pv) with offset based on the following calculation: Where is the first PE on the device (1M) + Where is the firt PE of the test lv (11776)*PE size (4M) = 47105M
# losetup -f -v -o 47105m /dev/sda2
Loop device is /dev/loop0
6., Test it with hexdump (it should give the same result like in the firts step but id doesn't do it)
# hexdump -C -n 10 /dev/loop0
00000000 00 00 00 00 00 00 00 00 00 00 |..........|
0000000a
Could somebody give me a hint where is the problem?
Thanks and regards,
B
_______________________________________________ linux-lvm mailing list linux-lvm@redhat.com https://www.redhat.com/mailman/listinfo/linux-lvm read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/