In Vagrant which is better out of halt and suspend?

danday74 picture danday74 · Mar 2, 2017 · Viewed 10k times · Source

When I'm about to shutdown my host machine off should I:

vagrant halt 

OR

vagrant suspend

What's the difference?

Answer

Frederic Henri picture Frederic Henri · Mar 2, 2017

tl;dr

Use vagrant halt when you want to power off your machine, use vagrant suspend when you want to hibernate your machine.


From the Vagrant docs:

vagrant suspend

A suspend effectively saves the exact point-in-time state of the machine, so that when you resume it later, it begins running immediately from that point, rather than doing a full boot.

This generally requires extra disk space to store all the contents of the RAM within your guest machine, but the machine no longer consumes the RAM of your host machine or CPU cycles while it is suspended.

vagrant halt

This command shuts down the running machine Vagrant is managing.

Which one you want to use?

It is basically up to you - do you have on-going work on the VM (maybe multiple applications opened through GUI, etc) you would prefer to suspend the VM so when you power up the machine, everything is there (Vagrant/VirtualBox would need to store the state of the instance on your hard drive consuming some hard drive space from your host). If you want to start from a clean start as all your process are setup from init, then go for vagrant halt

Example:

  • If you don't work much on your VM, meaning that all your project files are stored on your host and shared with your VM to see how they reflect using a LAMP server, then you can safely go with vagrant halt

  • If when you start your instance, you need to manually start specific processes, or you work on files directly in the VM; then it's better to suspend it so that when you turn it back on, it'll save your session and retrieve the instance in the same state it was in before you suspended it.