LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud
User Name
Password
Linux - Virtualization and Cloud This forum is for the discussion of all topics relating to Linux Virtualization and Linux Cloud platforms. Xen, KVM, OpenVZ, VirtualBox, VMware, Linux-VServer and all other Linux Virtualization platforms are welcome. OpenStack, CloudStack, ownCloud, Cloud Foundry, Eucalyptus, Nimbus, OpenNebula and all other Linux Cloud platforms are welcome. Note that questions relating solely to non-Linux OS's should be asked in the General forum.

Notices


Reply
  Search this Thread
Old 10-12-2010, 01:28 PM   #1
vzxen
Member
 
Registered: Jul 2010
Posts: 126

Rep: Reputation: 4
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.
 
Old 10-12-2010, 03:04 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
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.
 
Old 10-12-2010, 10:53 PM   #3
vzxen
Member
 
Registered: Jul 2010
Posts: 126

Original Poster
Rep: Reputation: 4
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 ?
 
Old 10-13-2010, 04:11 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
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.
 
Old 10-13-2010, 04:30 AM   #5
vzxen
Member
 
Registered: Jul 2010
Posts: 126

Original Poster
Rep: Reputation: 4
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.
 
Old 10-13-2010, 05:07 AM   #6
hurryi
Member
 
Registered: Apr 2010
Distribution: RHEL
Posts: 77

Rep: Reputation: 8
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] migrating from vmware to kvm, lvm partitioned guest failed to boot chakoshi Linux - Virtualization and Cloud 3 03-20-2011 04:34 PM
how to restore backup from an LVM Guest OS on KVM Lucid tkmsr Linux - Virtualization and Cloud 2 09-29-2010 06:12 AM
Assign IP to Guest VM in KVM vzxen Linux - Virtualization and Cloud 9 09-28-2010 04:14 AM
KVM: Mouse under Windows Guest performs way better than under Centos Guest martdj Linux - Virtualization and Cloud 3 03-29-2010 04:20 AM
LXer: Xen: How to Convert An Image-Based Guest To An LVM-Based Guest LXer Syndicated Linux News 0 04-19-2009 04:00 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud

All times are GMT -5. The time now is 09:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration