LinuxCommandLibrary

vagrant-halt

Stops a running Vagrant virtual machine

TLDR

Halt the currently running Vagrant machine gracefully

$ vagrant halt
copy

Halt a specific machine by its ID or name gracefully
$ vagrant halt [id_or_name]
copy

Forcefully halt the current running machine(s) (This can affect multiple running machines if they are part of the same Vagrant environment)
$ vagrant halt [[-f|--force]]
copy

Forcefully halt a specific machine by its ID or name
$ vagrant halt [[-f|--force]] [id_or_name]
copy

SYNOPSIS

vagrant halt [options] [name|id]

PARAMETERS

--force
    Forcefully shuts down the machine. Avoids attempting a graceful shutdown.

[name|id]
    The name or ID of the Vagrant machine to halt. If omitted, all running machines in the Vagrant environment will be halted.

DESCRIPTION

The vagrant halt command gracefully shuts down a running Vagrant machine. It sends an ACPI shutdown signal to the guest operating system, allowing it to cleanly power off. This is preferable to simply powering off the virtual machine using the virtualization provider's tools, as it allows the guest OS to save state and perform necessary shutdown procedures.

If the machine is already halted or doesn't exist, Vagrant will report that it is not running. If the guest OS doesn't respond to the ACPI signal within a reasonable timeout, Vagrant may force a power-off, which is less desirable. It's generally recommended to halt the machine from within the guest OS if possible before using `vagrant halt` as a failsafe.

This command is used for shutting down virtual machines controlled by Vagrant, simulating a regular system shutdown.

CAVEATS

If the guest OS is unresponsive, using vagrant halt might hang indefinitely. In such cases, consider using the --force flag, but be aware that this can lead to data loss if the guest OS has not properly saved its state.

POWER STATE CONSIDERATIONS

After executing vagrant halt, the machine enters a 'powered off' state. To restart the machine, you will need to use vagrant up. Using virtualization tool to start machine won't update Vagrant's state and may cause problems.

PARALLEL HALTED MACHINES

It is possible to halt multiple machines in parallel. The Vagrantfile should be configured to support multiple machines. Then you can target a specific machine by specifying its name or ID as a parameter to `vagrant halt`, e.g., `vagrant halt web`. If no name or ID is provided, all running machines in the environment will be halted sequentially (or in parallel based on Vagrantfile config).

HISTORY

The vagrant halt command has been a core part of Vagrant since its early development. It was created to provide a consistent and manageable way to shut down virtual machines managed by Vagrant, ensuring a controlled shutdown process regardless of the underlying virtualization provider (VirtualBox, VMware, etc.).

SEE ALSO

vagrant up(1), vagrant suspend(1), vagrant destroy(1), shutdown(8)

Copied to clipboard