Jump to content
We're Hiring! Full Stack Developer ×

Sharing a single disc image with several vms?


meep

Recommended Posts

I want to have a single base os disc image that can be used for multiple vms. I think this is a function of btrfs but I'm not sure and just can't remember the starting point.

 

The idea is to save space by using a single image, with discrete vms saving incremental diffs as snapshots or something.

 

I might be talking through my hat or it might be just  a docker thing but I'm sure I read its possible with vm disc images as well.

Link to comment

I want to have a single base os disc image that can be used for multiple vms. I think this is a function of btrfs but I'm not sure and just can't remember the starting point.

 

The idea is to save space by using a single image, with discrete vms saving incremental diffs as snapshots or something.

 

I might be talking through my hat or it might be just  a docker thing but I'm sure I read its possible with vm disc images as well.

Although this is theoretically possible with BTRFS, it is not supported by unRAID (at least at the moment).
Link to comment

Ok, thanks.

 

It's bugging me where I read about this. Guess I'm expanding my cache disk to accommodate a few more vm image files...

docker is supposed to do exactly this, right now, so that may be what you were thinking about. I remember it being discussed in the past for vm's as well, so you aren't going crazy.
Link to comment

Ok, thanks.

 

It's bugging me where I read about this. Guess I'm expanding my cache disk to accommodate a few more vm image files...

 

I think it was mentioned in one of the Linus Tech videos. Maybe the 7 VM's in 1 PC.

 

Gary

Link to comment

Ok, thanks.

 

It's bugging me where I read about this. Guess I'm expanding my cache disk to accommodate a few more vm image files...

 

I think it was mentioned in one of the Linus Tech videos. Maybe the 7 VM's in 1 PC.

 

Gary

 

I've been searching for this as well.. it was something like "some trickery with btrfs to save space."  Can't seem to find how to do it.. network mapping or symlinking a Steam library works okay from another vm's cached vdisc (though smb sharing from the host's main cache share is slow even with SMB2/3 turned off -- 5-10 sec launches vs 2 min launch).  I'll be re-watching those videos again today probably, see if I can get any more detail on it.

Link to comment

So it looks like it's covered here: 

(it's in the 7 gamers 1pc video)

...

Could you elaborate on what Linus talked about a snapshotting like feature in btrfs @ 10m:55s to 11m:26s. His exact words are:

 

"A snapshotting like feature of btrfs that allowed us to create one of our virtual hard disks and then clone it kind of like a shortcut in windows for all of the other 6 so none of those files get replicated and whats cool about that is even if you delete this file or that one the filesystem is smart enough to know not to actually eliminate the data so everyone can access it. Very very cool. So if one person uninstalls a program it doesn't uninstall for everybody"

...

and replied to by jonp:

I talk about the command I used in another post here:

 

http://lime-technology.com/forum/index.php?topic=44400.msg424931#msg424931

 

 

So it looks to me like, create your vdisk and load it up with stuff and snapshot it using reflink... seems to me to be much like a symlink, but while making a snapshot at the same time....  Interesting

Link to comment

Let me repeat what was said in that quoted thread:

 

Mind f-ing blown

 

Right now I have 4 Win10 VMs, each with 30GB vdisk which I basically copied from initial VM after I managed to set up everything for it (usb passthrough, all Win updates, initial win configuration, etc.). So I have 120GB taken for those vdisks. And now it seems that I could just use that reflink voodoo and have most of that space actually free to use? And any change would just be local to particular VM without affecting others? That is some crazy sh!t going on.

Link to comment

Let me repeat what was said in that quoted thread:

 

Mind f-ing blown

 

Right now I have 4 Win10 VMs, each with 30GB vdisk which I basically copied from initial VM after I managed to set up everything for it (usb passthrough, all Win updates, initial win configuration, etc.). So I have 120GB taken for those vdisks. And now it seems that I could just use that reflink voodoo and have most of that space actually free to use? And any change would just be local to particular VM without affecting others? That is some crazy sh!t going on.

 

That's kinda of what it seems like to me, the main window of my unraid setup shows that I'm using 358 gb storage on the cache array, but when I break out the handy calculator, just vdiscs show that i should be using 376... not including everything in the user shares.  (which should be upwards of another 125+), so I'm "using" 501 (yay napkin math) but have 140g free of 498.  I'd say that a good combination of reflink and symlinks are at work!  In layman's terms, looks like it makes a snapshot, and allocates a very little bit of space to hold it's snapshotty goodness... and any changes to that snapshot file actually increase the space used by that snapshot. 

 

So VM, 30 gig (doing it with qcow2 saves a ton of space, and I've not seen any performance difference between raw and that... ymmv), get it set up... snapshot a few times, VMStorage1.qcow2, 2, 3, 4... use those in your vms... and you've used like 45 gigs instead of 120 at the start AND your original is intact. *boggles*  So, if you're planning on using this for a games library or the like, update the original (or a snapshot for that matter) snapshot again 1234, attach new snapshotted vdiscs to your vms, profit.  Still low space usage.

 

Question for any of you gurus out there -- I suppose this doesn't work if the original is on your regular magnet array, does it? It would probably make a copy of the file to the cache and use the space like if the original was deleted... that would just be a-maze-ing if it worked like that

Link to comment

So VM, 30 gig (doing it with qcow2 saves a ton of space, and I've not seen any performance difference between raw and that... ymmv), get it set up... snapshot a few times, VMStorage1.qcow2, 2, 3, 4... use those in your vms... and you've used like 45 gigs instead of 120 at the start AND your original is intact. *boggles*  So, if you're planning on using this for a games library or the like, update the original (or a snapshot for that matter) snapshot again 1234, attach new snapshotted vdiscs to your vms, profit.  Still low space usage.

 

Yeah, snapshot, attach to Vm, profit. That's kind of awesome that it's actually little bit scary :)

 

So if I understand it correctly to use this for my VMs which are residing in "cache only" usershare on SSD I have to:

  • format my cache SSDs as BTRFS
  • create my VM vdisk not as raw but as qcow2

 

Does having cache SSD formatted as BTRFS changes anything for normal cache related unRaid operations? Should I maybe have separate SSDs for my magical snapshotted VMs and for "cache"?

Link to comment

Before you go off the deep end and get a result you weren't planning on, please do a simple experiment. At the command line, change to the folder holding your vdisk file, and type

ls -lsk

The first number in the line shows how much space that specific file actually uses on the drive, the second number shows what it is capable of growing to if the vdisk file is completely filled with content. Sparse files allow you to oversubscribe your disk space so that what the VM sees as truly empty space (all zeroes) doesn't take up any room on the host disk. As soon as you ask for that space to be filled, you can run into out of space errors.

 

If you were already aware of this phenomenon, please accept my apologies and ignore me.

Link to comment

@jonathanm

 

I am like Jon Snow, I know nuthin' :)

 

I will try this later but just for sake of clarity can you explain how this thing affects VMs using snapshots instead of "real" copied of vdisk? with regular separate vdisk files I can simply increase their sizes and when I enable additional space in Disk Management windows will just see it. Does it work differently when using reflink and snapshots?

 

Or am I completely missing the point?

Link to comment

Wish I'd asked this question a week earlier!

 

Over the weekend I managed to completely hose my Win10 VM buy upgrading AMD display drivers from v15 to v16. Blue screen of death on startup with an anti .sys file error and no way to boot into recovery mode. One great use case for this would be to dry out upgrades and drivers on a cloned version of VM before applying to the real thing.

 

Though I guess some careful planning would be required. My use case would be to run multiple HTPCs. It would be super useful to set up a single image and replicate it multiple times without the storage overhead. But as soon as you start applying updates (system, software etc.) they diverge. I imagine needing to 'reset' every so often, re-creating the linked images from a known good one.

 

Wondering if there's a way to recreate a full image file from a linked image? You could use disk tools in a guest OS maybe but is there a command line that will do it?

 

 

Link to comment

...

ls -lsk

The first number in the line shows how much space that specific file actually uses on the drive, the second number shows what it is capable of growing to if the vdisk file is completely filled with content. ... As soon as you ask for that space to be filled, you can run into out of space errors.

 

If you were already aware of this phenomenon, please accept my apologies and ignore me.

 

I figured something like that would happen, but thanks for the heads up! The idea of oversubscribing space is neat, but I'm not planning on making a habit of doing it.  I didn't know about the ls -lsk command line to get the  "current/max" though!  It's good to know, I was wondering if it was possible.  So raw does populate sparsely rather than allocating all the disk space at the time of creation, but unlike qcow2, it shows the total possible used in size rather than "what's been used" if that makes sense. 

 

Right now, I've only got 2 vms and plan on adding another SSD/cache drive before adding another machine to the pool. 

 

Thanks again for the information!

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...