Stop and start your instance
You can stop and start your instance if it has an Amazon EBS volume as its root device. The instance retains its instance ID, but can change as described in the Overview section.
When you stop an instance, we shut it down. We don't charge usage for a stopped instance, or data transfer fees, but we do charge for the storage for any Amazon EBS volumes. Each time you start a stopped instance we charge a minimum of one minute for usage. After one minute, we charge only for the seconds you use. For example, if you run an instance for 20 seconds and then stop it, we charge for a full one minute. If you run an instance for 3 minutes and 40 seconds, we charge for exactly 3 minutes and 40 seconds of usage.
While the instance is stopped, you can treat its root volume like any other volume, and modify it (for example, repair file system problems or update software). You just detach the volume from the stopped instance, attach it to a running instance, make your changes, detach it from the running instance, and then reattach it to the stopped instance. Make sure that you reattach it using the storage device name that's specified as the root device in the block device mapping for the instance.
If you decide that you no longer need an instance, you can terminate it. As soon as
the state
of an instance changes to shutting-down
or terminated
, we stop
charging for that instance. For more information, see Terminate your instance. If you'd rather hibernate the instance, see
Hibernate your Linux instance. For more information, see Differences between reboot, stop, hibernate, and
terminate.
Contents
Overview
You can only stop an Amazon EBS-backed instance. To verify the root device type of
your instance, describe the instance
and check whether the device type of its root volume is ebs
(Amazon EBS-backed instance) or
instance store
(instance store-backed instance). For more information, see
Determine the root device type of your AMI.
When you stop a running instance, the following happens:
-
The instance performs a normal shutdown and stops running; its status changes to
stopping
and thenstopped
. -
Any Amazon EBS volumes remain attached to the instance, and their data persists.
-
Any data stored in the RAM of the host computer or the instance store volumes of the host computer is gone.
-
In most cases, the instance is migrated to a new underlying host computer when it's started (though in some cases, it remains on the current host).
-
The instance retains its private IPv4 addresses and any IPv6 addresses when stopped and started. We release the public IPv4 address and assign a new one when you start it.
-
The instance retains its associated Elastic IP addresses. You're charged for any Elastic IP addresses associated with a stopped instance. With EC2-Classic, an Elastic IP address is dissociated from your instance when you stop it. For more information, see EC2-Classic.
-
When you stop and start a Windows instance, the EC2Config service performs tasks on the instance, such as changing the drive letters for any attached Amazon EBS volumes. For more information about these defaults and how you can change them, see Configuring a Windows instance using the EC2Config service in the Amazon EC2 User Guide for Windows Instances.
-
If your instance is in an Auto Scaling group, the Amazon EC2 Auto Scaling service marks the stopped instance as unhealthy, and may terminate it and launch a replacement instance. For more information, see Health Checks for Auto Scaling Instances in the Amazon EC2 Auto Scaling User Guide.
-
When you stop a ClassicLink instance, it's unlinked from the VPC to which it was linked. You must link the instance to the VPC again after starting it. For more information about ClassicLink, see ClassicLink.
For more information, see Differences between reboot, stop, hibernate, and terminate.
You can modify the following attributes of an instance only when it is stopped:
-
Instance type
-
User data
-
Kernel
-
RAM disk
If you try to modify these attributes while the instance is running,
Amazon EC2 returns the IncorrectInstanceState
error.
What happens when you stop an instance
When an EC2 instance is stopped using the stop-instances
command, the following is
registered at the OS level:
-
The API request sends a button press event to the guest.
-
Various system services are stopped as a result of the button press event. Graceful shutdown is triggered by the ACPI shutdown button press event from the hypervisor.
-
ACPI shutdown is initiated.
-
The instance shuts down when the graceful shutdown process exits. There is no configurable OS shutdown time.
-
If the instance OS does not shut down cleanly within a few minutes, a hard shutdown is performed.
By default, when you initiate a shutdown from an Amazon EBS-backed instance (for example, using the shutdown or poweroff command), the instance stops. You can change this behavior so that it terminates instead. For more information, see Change the instance initiated shutdown behavior.
Using the halt command from an instance does not initiate
a shutdown. If used, the instance does not terminate; instead, it places the CPU
into
HLT
and the instance remains running.
Stop and start your instances
You can stop and start your Amazon EBS-backed instance using the console or the command line.
To stop and start an Amazon EBS-backed instance using the command line
You can use one of the following commands. For more information about these command line interfaces, see Access Amazon EC2.
-
stop-instances and start-instances (AWS CLI)
-
Stop-EC2Instance and Start-EC2Instance (AWS Tools for Windows PowerShell)
Modify a stopped instance
You can change the instance type, user data, and EBS-optimization attributes
of a stopped instance using the AWS Management Console or the command line interface.
You can't use
the AWS Management Console to modify the DeleteOnTermination
, kernel, or RAM disk attributes.
To modify an instance attribute
-
To change the instance type, see Change the instance type.
-
To change the user data for your instance, see Work with instance user data.
-
To enable or disable EBS–optimization for your instance, see Modifying EBS–Optimization.
-
To change the
DeleteOnTermination
attribute of the root volume for your instance, see Update the block device mapping of a running instance. You are not required to stop the instance to change this attribute.
To modify an instance attribute using the command line
You can use one of the following commands. For more information about these command line interfaces, see Access Amazon EC2.
-
modify-instance-attribute (AWS CLI)
-
Edit-EC2InstanceAttribute (AWS Tools for Windows PowerShell)
Troubleshoot stopping your instance
If you have stopped your Amazon EBS-backed instance and it appears "stuck" in the
stopping
state, you can forcibly stop it. For more information, see
Troubleshoot stopping your
instance.