Skip to contentSkip to conversation

pvcreate on a loopback device - error: (newbie)

linux-lvm John Que 2 participants 2 messages Sep 20, 2006

lore
Share & tools
lore

John Que

author
#0 lore raw

Hello,

I had tried to do some test with LVM on a loopback device follwing some tutorials on the web.

I get errors.
what I do is this:

dd if=/dev/zero of=/work/tmp/disk-image count=10240 mke2fs /work/tmp/disk-image
mount -o loop /work/tmp/disk-image /work/loop/ 78 14:23

pvcreate /dev/loop1

error:
Failed to wipe new metadata area
/dev/loop1: Format-specific setup of physical volume failed. Failed
to setup physical volume "/dev/loop1"

what did I do wrong ?

Regards,
John

#1 lore raw
Quoted 14 lines · John Que

Hello,

I had tried to do some test with LVM on a loopback device follwing some tutorials on the web.

I get errors.
what I do is this:

dd if=/dev/zero of=/work/tmp/disk-image count=10240 mke2fs /work/tmp/disk-image
mount -o loop /work/tmp/disk-image /work/loop/ 78 14:23

pvcreate /dev/loop1

Quoted 7 lines

error:
Failed to wipe new metadata area
/dev/loop1: Format-specific setup of physical volume failed. Failed
to setup physical volume "/dev/loop1"

what did I do wrong ?

If you want to use LVM on a loopback device, you don't create a filesystem on it first.

You need to do something like
# Create new empty disk-image
dd if=/dev/zero of=disk-image count=10240

 # set up a loop-device for it
 losetup /dev/loop2 disk-image
 # initialize that loop-device for LVM
 pvcreate /dev/loop2
 # Create a VG on it
 vgcreate Test /dev/loop2

Now you can create Logical Volumes on that VG, e.g.:
# Create a logical volume
lvcreate --size 4M --name MyLV Test
# Create a filesystem on it
mke2fs /dev/Test/MyLV

 # mount the filesystem
 mkdir MyLV
 mount /dev/Test/MyLV MyLV

And if you want to remove everything...
umount MyLV
rmdir MyLV
lvremove /dev/Test/MyLV
vgremove Test
losetup -d /dev/loop2
rm disk-image

Signature · 1 line
Markus Laire