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

Re: [linux-lvm] LVM on a fake disk

Jordi Prats wrote:
Hi all,
How can I define voluem groups and logical volumes using a disk image on a file that will be the root filesystem of another machine (not the one that is defining them)?

The link below provides some details which may help. You can use losetup to associate a loop device with a regular file, then treat it as you would to a normal block device.



# create a sparse file to use as the block device in the guest
dd if=/dev/zero of=disk1.img seek=8096 bs=1M count=0

# setup a loopback device
losetup /dev/loop0 disk1.img

/dev/loop0 can now be used like a normal block device. If you partition the device thou it's slightly different - you need to use kpartx to make the partitions usable.


# create a partition table on the device (/boot cannot be on an LVM volume)
fdisk /dev/loop0

# make the partitions visible (they will appear as /dev/mapper/loop0pX, where X is a partition number)
kpartx -a /dev/loop0

# then you can use LVM on the devices
pvcreate /dev/mapper/loop0p1

The LVM's point of view there is nothing special that needs to be done other than scanning for the volume groups (vgscan) and activating/deactivating them (vgchange -ay <vg>/ vgchange -an <vg>).


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