0

I have a KVM guest, running on a KVM host...both Gentoo Linux.

The guest is called webserver.img. It is 21 gigs large, but I am only using 5 gigs inside the image.

I want to make a logical volume with NO filesystem(raw) and have the size about 10gigs, place the contents of webserver.img on it, and boot from the raw logical volume.

How could I get the contents of webserver.img onto ....for example.../dev/mapper/logical_volume1?

I thought about dd if=webserver.img of=/dev/mapper/logical_volume1 but I am worried that will copy over the filesystem or there might be some corruption.

  • Does your webserver.img have a partition table? Could you check output of fdisk -l webserver.img or file webserver.img – AlexD Apr 21 '13 at 6:58
  • Why not use a proper filesystem rather than a disk image? – Andrew Apr 22 '13 at 4:12
0

You can use image files (as you do now) and you can export block devices (as such). I am not sure whether you can safely write an image file to a block device and use the block device as an image file then. Probably wouldn't make much sense anyway.

You should stay with image files.

  1. make a file system on the LV (e.g. mke2fs -t ext4 /dev/mapper/logical_volume1
  2. mount the volume (mount -t ext4 /dev/mapper/logical_volume1 /mnt/logical_volume1)
  3. shutdown the VM
  4. copy the image file (cp -p /path/to/webserver.img /mnt/logical_volume1)
  5. adapt the VM configuration to the new path (rename the old image file to be sure)
  6. restart the VM

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.