[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: pvcreate on loopback file with lvm2

"pavel.orehov@gmail.com" <pavel.orehov@gmail.com> writes:

> Hi,
> I have installed lvm2 on debian and trying to run:
> pvcreate /dev/snap
> (when /dev/snap is a loopback file)
> and get an error "Device /dev/snap not found".
> My exact steps:
> 1) dd if=/dev/urandom of=/dev/snap bs=4096 count=1310702 (lopback file
> 5GB)
> 2) mkfs.ext3 /dev/snap
> 3) pvcreate /dev/snap
> Why ? Can't i create it on loopback file?

1. That creates a file (not a device).
2. That creates an ext3 filesystem inside the file.
3. That would overwrite the first blocks of the ext3 with the lvm
metadata. Probably leaving both of them intact for the time being but
randomly break if you use both.

You need to do a few things different:

1. dd if=/dev/urandom of=snap bs=1M count=5000 (or whatever)
2. losetup /dev/loop0 snap (put that in some rcS.d script before lvm
   so it is there again on a reboot)
3. check /etc/lvm/lvm.conf that it includes loopback devices (again so
   it gets seen on reboot)
4. pvcreate /dev/loop0


Reply to: