LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Virtualization and Cloud (https://www.linuxquestions.org/questions/linux-virtualization-and-cloud-90/)
-   -   Creating LVM based guest in KVM (https://www.linuxquestions.org/questions/linux-virtualization-and-cloud-90/creating-lvm-based-guest-in-kvm-837635/)

vzxen 10-12-2010 01:28 PM

Creating LVM based guest in KVM
 
Hi,

I am having trouble to install guests out of previously made Guests.
I use KVM and for guests I use LVMs as SWAP and disk

I installed a CentOS guest and mounted it using kpartx and zipped all its contents, preserving numeric owners.

Now when I create a new Guest, I am trying to use the zip from the old machine to simply unzip it and boot.
Before unzipping, I am copying the 512 bytes of the MBR and Partition table from the original guest.
Then I unzip the zip I created after mounting the LVM of the new machine.

When I boot the machine, the console in Virt-Manager shows its hung at StartUp only and the CPU Usage is at 50% of the total Server CPU.

What am I doing wrong ?

Please help.

acid_kewpie 10-12-2010 03:04 PM

What's all this stuff about the MBR?? if you want to make a new VM from an existing disk image, just take a copy of the disk image and use it under a new VM config. I don't understand what or why you're trying to do this. Might be ignorance on my side, but I have never ever seen any reference to messing with MBR's or partition tables within any form of virtualization.

Also, AFAIK, you don't need any swap under a KVM VM, as it can use memory over subscription and let the host machine swap out the mapped memory to the hosts swap implicitly, so just make the guests memory as large as you need, and don't use a swap partition at all.

vzxen 10-12-2010 10:53 PM

Hi,

I know the dd option works well.
But the resize2fs doesnt work properly.
The Guest OS shows the size of the LVM it was installed with.

I want to be able to use the template on many servers so a Simple Snapshot is not going to work.
What is the best way to duplicate the Guest VM ?

acid_kewpie 10-13-2010 04:11 AM

resize2fs doesn't work properly? How so? The guest will have no idea what size LV the underlying virtual disk is attached to, so what are we really talking about? resize2fs clearly has nothing to do with LVM so you need to be clearer on the terminology and scope you're talking about. Why is a copy of the disk image not going to work? If you provide a consistent and well managed evironment then you should be able to drop the VM image in really easily to a new qemu config.

vzxen 10-13-2010 04:30 AM

Hi,

I installed the CentOS guest on a 2 GB LVM
Then I made a image of the LVM :
dd if=/dev/vg/centos of=/root/centos.img

Then I created a 10GB LVM and ran the following command :
dd if=/root/centos.img of=/dev/vg/10g

I made the KVM config and booted it without errors.
df now shows 2 GB in the 10GB LVM.
Why is that so ?

I tried resize2fs and still 2 GB!
Any help will be appreciated.

Also I wanted to know who should I shrink the size of the centos.img I made.
Can it be squeezed to just use the space occupied by the OS files ?
It uses only 900MB in the LVM.
But the centos.img is 2.00 GB full as I dd'd it.
Is there a way to dd only the occupied space.

hurryi 10-13-2010 05:07 AM

Hello,

i may only can help in the LVM stuff, by doing that

dd if=/dev/vg/centos of=/root/centos.img
dd if=/root/centos.img of=/dev/vg/10g

you have now an lv named 10g but it is 2G

you can check it with lvs or lvdisplay
so first u will need to extend the 10g lv to 10G (or space you have or what you want) and you will be able to increase the fs with resize2fs


All times are GMT -5. The time now is 06:00 AM.