All of lore.kernel.org
 help / color / mirror / Atom feed
* [linux-lvm] lvm + loopback
@ 2012-03-31 16:56 Bali Zaci
  2012-03-31 19:47 ` Bali Zaci
  0 siblings, 1 reply; 2+ messages in thread
From: Bali Zaci @ 2012-03-31 16:56 UTC (permalink / raw)
  To: linux-lvm

[-- Attachment #1: Type: text/plain, Size: 2149 bytes --]

Hi all,

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

[-- Attachment #2: Type: text/html, Size: 3130 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [linux-lvm] lvm + loopback
  2012-03-31 16:56 [linux-lvm] lvm + loopback Bali Zaci
@ 2012-03-31 19:47 ` Bali Zaci
  0 siblings, 0 replies; 2+ messages in thread
From: Bali Zaci @ 2012-03-31 19:47 UTC (permalink / raw)
  To: linux-lvm

[-- Attachment #1: Type: text/plain, Size: 2599 bytes --]

Ok,

So the problem was that the losetup doesn't able to handle the 'm' char...

So the right command:
losetup -f -v -o $((47105 * 1024 * 1024)) /dev/sda2

Regards,
B

2012. március 31. 18:56 Bali Zaci írta, <zaci.bali@gmail.com>:

> Hi all,
>
> 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
>
>
>

[-- Attachment #2: Type: text/html, Size: 3668 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-03-31 19:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-31 16:56 [linux-lvm] lvm + loopback Bali Zaci
2012-03-31 19:47 ` Bali Zaci

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.