KVM + LVM: Where to put LVM?

627

Solution 1

LVM's performance overhead is trivial, using it twice won't change that. Your raid-5 device is going to have a much much greater impact than lvm.

Solution 2

A blog article at http://hyperthese.net/post/kvmized-debian-on-lvm/ suggests that you create LVM logical volumes on the host (physical server) and create filesystems directly on them, without creating partitions, and before creating the virtual machines.

I tried it out, and long story short: seemed to work, and I was able to enlarge an LV and the filesystem on it.

Here's the long story, i.e. what I did:

Created LVM logical volumes for root, var and swap for the VM, on the host (running Ubuntu 10.04):

me@host:~$ sudo lvcreate -L4G -n test-root vg1
me@host:~$ sudo lvcreate -L20G -n test-var vg1
me@host:~$ sudo lvcreate -L2G -n test-swap vg1

Created file systems and swap on LVs:

me@host:~$ sudo mkfs.ext3 /dev/mapper/vg1-test--root
me@host:~$ sudo mkfs.ext3 /dev/mapper/vg1-test--var
me@host:~$ sudo mkswap -f /dev/mapper/vg1-test--swap

Created the VM:

me@host:~$ sudo virt-install --name=test --ram=2048 --os-type=linux --os-variant=ubuntulucid --cdrom=ubuntu-server-10.04-lts-64bit.iso --disk path=/dev/mapper/vg1-test--root --disk path=/dev/mapper/vg1-test--var --disk path=/dev/mapper/vg1-test--swap --network bridge=br0 --vnc --noautoconsole

Then I connected to the new VM using virt-viewer and the Ubuntu installer was there waiting. I chose the mode 'Install a minimal virtual machine' (F4 key).

At the partitioning phase I chose the manual partitioning. The installer found virtual disks vda, vdb and vdc and recognized the first two having ext3 and last as swap. I chose the ext3 partitions and told to use them as ext3 partitions (the default was "do not use"), with "no, keep the existing data" and mount point as / for the first one and /var for the second one. Swap was set up correctly by default. Then I chose to install grub on the first disk.

I got the VM up and running fine. Fdisk shows vda as having an empty partition table and vdb and vdc as not having a valid partition table. I don't know if having or not having a partitioning table is a problem, there's some discussion about it at https://unix.stackexchange.com/questions/5162/how-to-install-grub-to-a-whole-ext4-disk-without-partition-table .

Finally I tried resizing the var disk. First, on the host:

me@host:~$ sudo lvextend -L24G /dev/vg1/test-var

Then I rebooted the VM and resized the file system on the VM:

me@test:~$ sudo resize2fs /dev/vdb

And it resized it fine.

I don't know if this is a good way to do it or not, but so far it seems to work. Any comments?

Share:
627

Related videos on Youtube

rolandow
Author by

rolandow

Updated on September 17, 2022

Comments

  • rolandow
    rolandow almost 2 years

    Here's what I am tryin to accomplish. The CMS editor of our Magento webshop, has a button to insert a <!-- pagebreak --> tag. I would like to use this, to create a read more functionality. I thought I would search/replace for this tag to do this.

    I want to search inside <p> tags, and I want people to be able to use this tag as often as they want.

    Suppose this is my original HTML:

    <p>This is my example text, but<!-- pagebreak --> this should be readable after 'click more'<!-- pagebreak --> with even more click more possible</p>
    

    I would like to convert it to something like this.. I think the first one is the easiest to accomplish, maybe by doing an preg_replace in a while loop? The second one is probably cleaner/better html (less nesting)

    <p>This is my example text, but <a href="#" onClick='#'>read more</a><div class='hiddenreadmore' id='hiddenreadmore-1'> this should be readable after 'click more'<a href="#" onClick='#'>read more</a><div class='hiddenreadmore' id='hiddenreadmore-2'> with even more click more possible</div></div></p>
    

    or

    <p>This is my example text, but <a href="#" onClick='#'>read more</a><div class='hiddenreadmore' id='hiddenreadmore-1'> this should be readable after 'click more'<a href="#" onClick='#'>read more</a></div><div class='hiddenreadmore' id='hiddenreadmore-2'> with even more click more possible</div></p>
    

    So I came up with this, but I think there should be a way to do it with one replace.

    $pattern = '#\<p\>(.+?)\<\!-- pagebreak --\>(.+?)\<\/p\>#s';
    $count = true;
    while ($count) {
        $text = preg_replace($pattern, '<p>$1 <a href="#">read more</a><div class="hidden">$2</div></p>', $text, -1, $count);
    }
    
  • Allen
    Allen over 13 years
    LVM is great. It makes things like removing a disk and snapshots easy. Suppose you had to move a VM's data from a file backed vdisk to an lv backed vdisk while the VM remains up?
  • theomega
    theomega over 12 years
    The rebooting of the VM for resizing sometimes is a no-go because the services on it can not afford a downtime.
  • jarnoan
    jarnoan over 12 years
    Maybe there is a way to get the VM notice the virtual disk size change without reboot, but I don't know how. A good thing in this approach is also that it is trivial to mount the VM filesystem on the physical host (when the VM is shut down of course).
  • rolandow
    rolandow about 12 years
    I do have to check that, because otherwise I may accidently "hide" the rest of the page. This way I can 'force' the user to use this inside a paragraph only.
  • rolandow
    rolandow about 12 years
    Yes, but you are assuming here that only one pagebreak exists in one paragraph. My problem is that a user might put two pagebreaks in one paragraph.
  • Manuel
    Manuel about 12 years
    I'm afraid that if you really need to check the needle to be in a paragraph your option is the only one i can think of.
  • jarnoan
    jarnoan about 12 years
    Having used partitionless disks for some time now I cannot recommend it. Grub and some other tools expect to have a partition table. I've already got one VM in unbootable state after upgrade changed something and messed up Grub data.