Amos Shapira
2012-Sep-21 11:22 UTC
[libvirt-users] sharing read-only LOCAL disks among KVM guests
Hello, Is it possible to share a single host's Logical Volume among multiple local KVM guests which mount it read-only? I'm asking this because I have an idea to run multiple idential KVM guests (they all have exactly the same software installed on them), booting them from a shared local Logical Volume read-only root file system, or alternatively let them share the bulk of the software (/usr, /opt, /lib) from a common KVM host Logical volume. Is this possible? All my searches so far failed to turn up anything like this. Would it be possible using qcow2 instead of raw LV? If so - would it be worth the performance hit of switching from LV to qcow2? The motivation for this is two-fold: 1. Speed-up - I suspect that sharing the same disk block among all KVM agents (we currently have 14 KVM guests on each server) should lead to better cache utilisation and reduce disk access. Also the cost of maintaining the mutiple identical servers and keeping them up to date could be eating into our server's resource usage. 2. Maintenance - if I get to share the common disk image among all of them then I only need to install/update it once instead of once for each KVM guest (we already use Puppet but it doesn't mean it comes for free). Thanks, --Amos -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://listman.redhat.com/archives/libvirt-users/attachments/20120921/f6f64cab/attachment.htm>
Daniel P. Berrange
2012-Sep-21 11:30 UTC
[libvirt-users] sharing read-only LOCAL disks among KVM guests
On Fri, Sep 21, 2012 at 09:22:24PM +1000, Amos Shapira wrote:> Hello, > > Is it possible to share a single host's Logical Volume among multiple local > KVM guests which mount it read-only? > > I'm asking this because I have an idea to run multiple idential KVM guests > (they all have exactly the same software installed on them), booting them > from a shared local Logical Volume read-only root file system, or > alternatively let them share the bulk of the software (/usr, /opt, /lib) > from a common KVM host Logical volume. > > Is this possible? All my searches so far failed to turn up anything like > this.>From the libvirt POV, there's nothing much todo except add <readonly/>inside the <disk> element. This will ensure QEMU only gets given read permission on the disk backend. The important thing is to then make sure your guests actually mount the filesystem with the readonly flag.> Would it be possible using qcow2 instead of raw LV? If so - would it be > worth the performance hit of switching from LV to qcow2?The type of backend storage doesn't really affect things if the disk is fully readonly. Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
Henrik Ahlgren
2012-Sep-21 11:58 UTC
[libvirt-users] sharing read-only LOCAL disks among KVM guests
On Fri, Sep 21, 2012 at 09:22:24PM +1000, Amos Shapira wrote:> 2. Maintenance - if I get to share the common disk image among all of them > then I only need to install/update it once instead of once for each KVM > guest (we already use Puppet but it doesn't mean it comes for free).How do you plan on upgrading the read-only VMs after the initial installation, or are they short-lived and frequently recreated from scratch using a fresh image? Read-only, shared /usr between machines is a nice idea in theory, but at least the modern linux distros' package management tend not to support it that well in practice. IMHO using a QCOW2 backing files as base templates works pretty well and gives you similar disk space savings, at least initially. And KSM does the same with RAM.