2

I have configured the Virtual Box in my machine. Now, I have the original Virtual Box images available under the folder /home/original_vbox_images.

Now, the Virtual Box, as per the configuration, uses the images from the location /root/VirtualBox VMs/. I am planning on providing root access to the users in the guest OS installed in Virtual Box. So basically, the users can do anything with root access in the guest OS machine. (I expect the users to even execute rm -rf /).

Now, during reboot, I want the initial Virtual Box image that I have with me to be available again. So, I thought of doing something like this.

vi /root/Desktop/newscript.sh
cp -R /home/original_vbox_images/ /root/VirtualBox VMs/

Now, after giving execute permission on the script, I will add it to /etc/rc.local as below.

vi /etc/rc.local
sh /root/Desktop/newscript.sh

As of now, I have 10 GB HDD. However, I plan on increasing the capacity of the Virtual HDD.

The problem is, the copy might take longer time and won't be efficient. I am looking for some other elegant solution.

7
  • I am unsure of what distro you want to use, but you could possibly just have the VM be setup as a LiveBoot/CD. This would possibly be a workaround which would accomplish what you want. (Not sure if this would answer your question or not) Commented Aug 21, 2014 at 19:23
  • Have you considered just configuring the system to boot to a writable snapshot? When I was just starting out that's what I did with the idea that no matter what I did I could just boot to the real volume, delete the snapshot, and create a new one with the same name and I'd be back at square one. Commented Aug 21, 2014 at 19:32
  • @NoTime, thanks. I use RHEL as the host system. I am trying to get it working with multiple guest operating systems inside virtual box. Commented Aug 21, 2014 at 20:58
  • @JoelDavis, I am not sure what you mean. Could you please elaborate? Commented Aug 21, 2014 at 20:58
  • I meant set up the VM image as LiveBoot/CD (there is a check box), however I believe the answer that Renan gave is closer to what you want. i.e. Create each machine image, then use the command VBoxManage modifyhd *filename*.vdi --type immutable (where *filename* is the name of the VM image). For each VM you are using. This allows the user to do anything, but upon restart the "original" image is restored. Commented Aug 21, 2014 at 21:07

1 Answer 1

4

I think you can set the virtual machine's disk to be immutable in order to get what you want.

[...] immutable images only remember write accesses temporarily while the virtual machine is running; all changes are lost when the virtual machine is powered on the next time. As a result, as opposed to "normal" images, the same immutable image can be used with several virtual machines without restrictions.

Then, when the virtual machine is shutdown, the changes are lost.

2
  • Would the command be: VBoxManage modifyhd *filename*.vdi --type immutable? Commented Aug 21, 2014 at 19:39
  • @NoTime I tried here and this syntax worked. Commented Aug 21, 2014 at 19:42

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.