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