3

I am running a Fedora 23 VM. My requirement is very simple:

All the packages that were installed during the running of the VM have to uninstalled when it is given a shutdown signal. In other words, when it reboots it should be like a freshly installed Fedora VM.

What configuration changes should I make to the OS/VM to get this desired effect?

I thought having some script to log package installations, and mark them for removal when the system starts up. Is there an existing dnf/yum method to do this already?

EDIT It was misleading to say that I need a freshly installed VM. If so, a snapshot would have served the purpose. I want to retain my config changes on the VM, like firewall rules, network-config ...(basically most of the things in /etc)

6
  • 1
    If you are using VirtualBox, try to create the virtual machine without disk. Or, boot from the iso but don't install it, just try the live media, so, you can make changes, but they will be lost on every reboot. It is similar to the option "Try Ubuntu", but I'm not sure if Fedora has something like that.
    – GTRONICK
    Nov 10 '16 at 13:12
  • I thought of that. I only want the packages uninstalled. The other configuration should be retained. Hoping that there is an option in package-management that lets you do it.
    – 0aslam0
    Nov 10 '16 at 13:22
  • So, you need something like a deep freezer used in Windows. Look at this: Deep freeze in Fedora, also look for Gofris, it is like a Deep Freeze version for Linux.
    – GTRONICK
    Nov 10 '16 at 13:55
  • You could always use Vagrant.
    – Wildcard
    Nov 25 '16 at 4:56
  • @Wildcard vagrant destroy is what you are referring to right? But even that wipes out config data. Correct me, if I am wrong
    – 0aslam0
    Nov 25 '16 at 5:01
1

If I am not mistaken, VirtualBox, Gnome Boxes, and virt-manager all have a snapshot feature. You can take a snapshot of the freshly installed VM, then revert back to that snapshot with one or two clicks before/after every session.

6
  • That makes sense. But any additional configuration that I have done will be lost when I revert back.
    – 0aslam0
    Nov 24 '16 at 11:38
  • Does the "additional configuration" include data saved over time, or just initial configuration of the system?
    – Mio Rin
    Nov 24 '16 at 17:33
  • Both actually. But I have additional storage nodes, so if i can preserve the config data , then that should suffice.
    – 0aslam0
    Nov 24 '16 at 17:35
  • 1
    If you keep the data on an external storage node (NAS or similar), then all you need to do is take the snapshot of the VM after you've set up the configuration of the system. That should include the connections to the external data nodes.
    – Mio Rin
    Nov 24 '16 at 18:14
  • You are still missing a piece there. Let's say I made snapshot-A with my config changes. Still I may need to change some ip rules, or disable a service ; in other words config data can change from time to time. When I revert back to snapshot-A, those new changes will be gone. In the question, I should have not mentioned, like a freshly installed. My bad!
    – 0aslam0
    Nov 25 '16 at 4:49
1

qemu has a -snapshot option just for that. All the disk modifications are stored in memory and not sent to the disk image. So when the emulator is terminated, the changes are gone.

With most virtualisation solutions, you should be able to take a snapshot and roll it back afterwards.

With qemu again, you can make a one-shot qcow2 or qed disk image file that only records the changes from a base image (even raw image like a real disk):

qemu-img create -o backing_file=/dev/VG_VMs/vm1_disk0 vm1_oneshot.qcow2

Just discard that file when it's no longer needed, and create another one to start anew. It's also possible to flush the modifications to the base image if you want to.

Your Answer

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

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