Objective
Attach a previously created Google volume to an instance.
Table of Contents
Overview
Once you've created a volume, you may attach it to an instance. There are two ways you can attach a volume to an instance:
-
Attach now - Attach this volume to an operational server. You will also have the option to configure the volume to attach at boot time the next time the server launches.
-
Attach on boot time - Attach this volume to the server instance (at boot time) the next time the server launches.
Note: you cannot attach a volume to a locked instance. It will fail.
Both attachment options are covered in this tutorial.
Important! If you manually attach a volume to an instance, none of its attached volume(s) will be deleted when the server is terminated. You will need to manually terminate each volume once it's been detached from the instance.
Steps
Attach a Volume to a Running Instance
- Go to Clouds > Google > Volumes and click the nickname of the volume that you want to attach to a running instance. In order to attach the same volume to multiple instances, you must take a snapshot of the original volume and then create multiple volumes from the same snapshot. A volume's status will be "available" if it is currently not attached to a running instance. Otherwise, a volume's status will be "in-use."
- Click the Attach now button.
- Next, you will need to select which running instance the volume will be attached to, as well as the device location where the volume will be mounted. Choose an "/dev/sd" device name for Linux instances or an "xvd" device name for Microsoft Windows instances.
- Note, if attaching more than 4 volumes, you will need to use the Override checkbox and specify a new, unused device name according to the operating system used (per above).
- Click OK.
- The volume will become available for use when the volume's status is listed as "attached."
Detach the Volume
To detach the volume, click the eraser action icon under the Actions column.
Note: If you terminate the server, the attached volume(s) will not be deleted. You will need to manually terminate each volume once it has been detached from the instance.
Attach a Volume when an Instance is Launched
You can also configure a volume(s) to automatically be attached to a component when it is launched.
Server Level
Go to a server's homepage and click the Volumes tab. Click Attach Volume.
-
Volume - Select the volume attachment.
-
Device name - List of common (Xen/Linux) device names to which the volume will be attached.
- Select the "Override" option to specify a different value not in the list.
- Choose a "/dev/sd" device name for Linux instances running on an EC2-patched kernel, or an "xvd" device name for Microsoft Windows instances.
Note: For Xen native kernels (used by images such as Ubuntu (official) and Debian) the device is utilized by the kernel of the instance with "xvd" instead of "sd", e.g. attaching as /dev/sdk is accessible on the instance with /dev/xvdk.
-
Attachment options - See the "Overview" section above for detailed descriptions of each attachment option.
- Attach now
- Attach on boot
Click OK.