Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Does Virtual Server 2005 R2 have a command line interface, that's versatile enough?

Here is a situation. I run a Win2k VM on an old memory constrained machine. I allocate it 378MB of RAM and the VM runs just fine. Once a month, inside the VM, I backup the (a very large) database, compress it using 7Zip and ftp it to the backup site (all in a script).

Unfortunately the compression part takes a massive amount of RAM (far exceeding the 378MB), it goes for the paging file and brings absolutely everything to a crawl and literally takes 2-3 days, if left unattended. So to fix this, I have to shutdown the VM, give it temporarily 768MB of RAM and then the whole thing finishes in 20 minutes.

So, is there a way do the following automatically from the host machine in a script?

  1. Shutdown the guest OS (I think, I got this part)
  2. Change the RAM allocation from 378 to 768
  3. Start the guest OS again

then, 1 hour later, do everything in reverse.

Edit: thx to Wesley 'Nonapeptide' for the links. I cobbled up a script and it works like butter. It takes the memory amount as a parameter. Here it is for any folks who might want to do this:

if Wscript.Arguments.Count = 0 then 
  Wscript.Quit
end if

memory = Wscript.Arguments(0)

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("vbRad.com")

Set objGuestOS = objVM.GuestOS 
Set objTask = objGuestOS.Shutdown() 
objTask.WaitForCompletion(600000)

objVM.Memory = memory 

Set objTask = objVM.Startup()
objTask.WaitForCompletion(600000)
share|improve this question
1  
Have you thought about modifying the dictionary size or compression method so it doesn't take so much RAM? Zip/Deflate only takes 3MB of RAM, LZMA with a 2MB dict only takes 32MB of RAM. –  Chris S Jan 5 '11 at 19:52
    
@Chris, I did, but then the compress takes forever. –  AngryHacker Jan 6 '11 at 6:50
    
LZMA does take longer (much longer) than Deflate, but changing the dictionary size doesn't (significantly) change the amount of time it takes to compress the file(s). It will reduce the algorithm's ability to compress the file (resulting in a larger archive for most data sets). –  Chris S Jan 6 '11 at 13:48
    
@Chris S. You are absolutely right, but I do value the smaller size of the upload, since my upload bandwidth kind of sucks. Even though my solution is akin to driving a tank to catch a fly, it actually works very well. –  AngryHacker Jan 7 '11 at 21:37

1 Answer 1

up vote 3 down vote accepted

The .memory attribute for a VM object is what you would be looking for. Check out this list of methods and properties on a VM object.

The .startup method is what you're looking for to start it back up.

You might also like this second part of a tutorial that shows how to manage virtual machines with PowerShell. That shows a few examples of how VM configurations are twiddled with.

Finally, bookmark the MSDN Microsoft Virtual Server Reference. It rocks.

share|improve this answer
    
Thank you. Exactly what I was looking for. –  AngryHacker Jan 5 '11 at 19:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.