When I'm about to shutdown my host machine off should I:
vagrant halt
OR
vagrant suspend
What's the difference?
This command shuts down the running machine Vagrant is managing. Vagrant will first attempt to gracefully shut down the machine by running the guest OS shutdown mechanism. If this fails, or if the --force flag is specified, Vagrant will effectively just shut off power to the machine.
Command: vagrant resume [name|id] This resumes a Vagrant managed machine that was previously suspended, perhaps with the suspend command. The configured provisioners will not run again, by default. You can force the provisioners to re-run by specifying the --provision flag.
There are two ways to 'stop' a running Vagrant machine. You can either suspend or halt. vagrant halt shuts down the Vagrant machine - as though you shut down the machine cleanly, for example running a sudo shutdown now from the terminal in Ubuntu. Which, as the command would imply, forces the shutdown regardless.
This command stops the running machine Vagrant is managing and destroys all resources that were created during the machine creation process.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With