Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Vagrant which is better out of halt and suspend?

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

vagrant halt  

OR

vagrant suspend 

What's the difference?

like image 873
danday74 Avatar asked Mar 02 '17 07:03

danday74


People also ask

What is vagrant halt?

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.

How do I start vagrant after halt?

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.

How do you stop a VM on vagrant?

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.

Does vagrant destroy delete files?

This command stops the running machine Vagrant is managing and destroys all resources that were created during the machine creation process.


1 Answers

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.

like image 186
Frederic Henri Avatar answered Sep 25 '22 10:09

Frederic Henri