1

I am Making a disposable (use for one task/website then delete) Virtual Machine (VM) it's a slow process to do it in VMware workstation. I want to automate it so it is like the quick ~5 second DispVM (Disposable VM=DispVM) feature in the Secure OS Qubes. Intro to Qubes

It is for just one usage case, a disposable website browser VM when you have to visit web sites with often compromised java, adobe flash, and more. So if Adobe Flash has yet another security issue, it does not matter since that VM is gone.

Sketch of idea

  • Check if the master VM has changed since the last snapshot
  • ... if the snapshot is unchanged use existing snapshot otherwise make new snapshot
  • make a linked clone (uses master vm's disk + delta file, so we don't need to copy the whole master vm)
  • Name the linked clone Disp # (auto generated sequential number)
  • when the vm is shutdown then delete the vm

I need help completing the whole desired solution.

  • How do I check if the VM has changed since the last snapshot? VM list snapshots only gives the names not time/date stamps.

  • Bash environmental variables are cleared when the script finishes/terminal is closed, so how do I store or detect how many DispVMs are running so I know what to name the next DispVM created? I saw this store variables in a file approach but hoping for a better option:

  • How can this be generalized to work for multiple DispVM running and uniquely naming themselves at the same time?

bash script:

# assume snapshot current, | tail -1 (gives last snapshot name)
$strCurrentSnapshotName = vmrun -T ws listShapshots VMs/Master-Fedora-DVM.vmx | tail -1

# make linked clone
vmrun -T ws clone VMs/Master-Fedora/Master-Fedora-DVM.vmx VMs/DVM1/DVM1.vmx linked strCurrentSnapshotName 

vmrun start VMs/DVM1/DVM1.vmx

vmrun -gu <user> -gp <pass> runProgramInGuest VMs/DVM1/DVM1.vmx /usr/bin/firefox --display=:0

# How to  check if VM is powered off 
# when list of running VMs does not contain DVM then we are ok to break and delete
while [ !(vmrun -T ws list | grep DVM) ]
do
  sleep 5
done

# now dispose of and delete vm
vmrun -T ws unregister VMs/DVM1.vmx

# shred directory and delete
find VMs/DVM1/ -type f -exec shred {} \;
vmrun -T ws deleteVM VMs/DVM1/DVM1.vmx
  • It's unclear what you are asking. Do you have a problem with getting this set up? Or are you asking how to do it? What have you tried? – Michael Frank Sep 9 '15 at 2:26
  • @MichaelFrank Yes looking for script (GUI is easy but slow and a real pain when you need say 3 DispVMs) added some code as well. Is it clear what I am aiming for with a Disposable VM? – StackAbstraction Sep 9 '15 at 3:39
  • 1
    @FranciscoTapia I am showing my work and research, including questions in the code comments. The prior comment asked what I had done so far. I clearly show research and my attempts, so why is the question unclear or not useful to you? – StackAbstraction Sep 9 '15 at 14:16
  • 2
    I don't see the question here. It looks like you're part-way to solving the problem yourself, so why not continue doing the work of writing the script until you get it working to your satisfaction? You're more than half-way there already, having figured out the syntax of vmrun and so on. You just need to make it a little more robust. Your only question I could infer might be, "Am I on the right track?" to which I'd answer, "Definitely yes". – allquixotic Sep 9 '15 at 16:49
  • 1
    @FranciscoTapia I added specific questions where I am having trouble, does that solve your concern? – StackAbstraction Sep 10 '15 at 5:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.