File: //snap/google-cloud-cli/396/help/man/man1/gcloud_compute_instances_attach-disk.1
.TH "GCLOUD_COMPUTE_INSTANCES_ATTACH\-DISK" 1
.SH "NAME"
.HP
gcloud compute instances attach\-disk \- attach a disk to an instance
.SH "SYNOPSIS"
.HP
\f5gcloud compute instances attach\-disk\fR \fIINSTANCE_NAME\fR \fB\-\-disk\fR=\fIDISK\fR [\fB\-\-boot\fR] [\fB\-\-csek\-key\-file\fR=\fIFILE\fR] [\fB\-\-device\-name\fR=\fIDEVICE_NAME\fR] [\fB\-\-disk\-scope\fR=\fIDISK_SCOPE\fR;\ default="zonal"] [\fB\-\-force\-attach\fR] [\fB\-\-interface\fR=\fIINTERFACE\fR] [\fB\-\-mode\fR=\fIMODE\fR;\ default="rw"] [\fB\-\-zone\fR=\fIZONE\fR] [\fIGCLOUD_WIDE_FLAG\ ...\fR]
.SH "DESCRIPTION"
\fBgcloud compute instances attach\-disk\fR is used to attach a disk to an
instance. For example,
.RS 2m
$ gcloud compute instances attach\-disk example\-instance \e
\-\-disk DISK \-\-zone us\-central1\-a
.RE
attaches the disk named 'DISK' to the instance named 'example\-instance' in zone
\f5\fIus\-central1\-a\fR\fR.
After you create and attach a new disk to an instance, you must format and mount
(https://cloud.google.com/compute/docs/disks/add\-persistent\-disk#formatting)
the disk so that the operating system can use the available storage space. You
can attach an existing non\-boot disk to more than one instance. For more
information, see Share a disk between VMs.
.SH "EXAMPLES"
To attach a disk named 'my\-disk' as a boot disk to an instance named
\'my\-instance', run:
.RS 2m
$ gcloud compute instances attach\-disk my\-instance \-\-disk=my\-disk \e
\-\-boot
.RE
To attach a device named 'my\-device' for read\-only access to an instance named
\'my\-instance', run:
.RS 2m
$ gcloud compute instances attach\-disk my\-instance \e
\-\-device\-name=my\-device \-\-mode=ro
.RE
.SH "POSITIONAL ARGUMENTS"
.RS 2m
.TP 2m
\fIINSTANCE_NAME\fR
Name of the instance to operate on. For details on valid instance names, refer
to the criteria documented under the field 'name' at:
https://cloud.google.com/compute/docs/reference/rest/v1/instances
.RE
.sp
.SH "REQUIRED FLAGS"
.RS 2m
.TP 2m
\fB\-\-disk\fR=\fIDISK\fR
The name of the disk to attach to the instance.
.RE
.sp
.SH "OPTIONAL FLAGS"
.RS 2m
.TP 2m
\fB\-\-boot\fR
Attach the disk to the instance as a boot disk.
.TP 2m
\fB\-\-csek\-key\-file\fR=\fIFILE\fR
Path to a Customer\-Supplied Encryption Key (CSEK) key file that maps Compute
Engine resources to user managed keys to be used when creating, mounting, or
taking snapshots of disks.
If you pass \f5\-\fR as value of the flag, the CSEK is read from stdin. See
https://cloud.google.com/compute/docs/disks/customer\-supplied\-encryption for
more details.
.TP 2m
\fB\-\-device\-name\fR=\fIDEVICE_NAME\fR
An optional name that indicates the disk name the guest operating system will
see. (Note: Device name does not correspond to mounted volume name). Must match
the disk name if the disk is going to be mounted to a container with
\-\-container\-mount\-disk (alpha feature).
.TP 2m
\fB\-\-disk\-scope\fR=\fIDISK_SCOPE\fR; default="zonal"
The scope of the disk. \fIDISK_SCOPE\fR must be one of:
.RS 2m
.TP 2m
\fBregional\fR
The disk specified in \-\-disk is interpreted as a regional disk in the same
region as the instance. Ignored if a full URI is provided to the \f5\-\-disk\fR
flag.
.TP 2m
\fBzonal\fR
The disk specified in \-\-disk is interpreted as a zonal disk in the same zone
as the instance. Ignored if a full URI is provided to the \f5\-\-disk\fR flag.
.RE
.sp
.TP 2m
\fB\-\-force\-attach\fR
Attach the disk to the instance even if it is currently attached to another
instance. The attachment will succeed even if detaching from the previous
instance fails at first. The server will continue trying to detach the disk from
the previous instance in the background.
.TP 2m
\fB\-\-interface\fR=\fIINTERFACE\fR
The interface of the disk. \fIINTERFACE\fR must be one of:
.RS 2m
.TP 2m
\fBNVME\fR
NVME
.TP 2m
\fBSCSI\fR
SCSI
.RE
.sp
.TP 2m
\fB\-\-mode\fR=\fIMODE\fR; default="rw"
Specifies the mode of the disk. \fIMODE\fR must be one of:
.RS 2m
.TP 2m
\fBro\fR
Read\-only.
.TP 2m
\fBrw\fR
Read\-write.
.RE
.sp
.TP 2m
\fB\-\-zone\fR=\fIZONE\fR
Zone of the instance to operate on. If not specified, you might be prompted to
select a zone (interactive mode only). \f5gcloud\fR attempts to identify the
appropriate zone by searching for resources in your currently active project. If
the zone cannot be determined, \f5gcloud\fR prompts you for a selection with all
available Google Cloud Platform zones.
To avoid prompting when this flag is omitted, the user can set the
\f5\fIcompute/zone\fR\fR property:
.RS 2m
$ gcloud config set compute/zone ZONE
.RE
A list of zones can be fetched by running:
.RS 2m
$ gcloud compute zones list
.RE
To unset the property, run:
.RS 2m
$ gcloud config unset compute/zone
.RE
Alternatively, the zone can be stored in the environment variable
\f5\fICLOUDSDK_COMPUTE_ZONE\fR\fR.
.RE
.sp
.SH "GCLOUD WIDE FLAGS"
These flags are available to all commands: \-\-access\-token\-file, \-\-account,
\-\-billing\-project, \-\-configuration, \-\-flags\-file, \-\-flatten,
\-\-format, \-\-help, \-\-impersonate\-service\-account, \-\-log\-http,
\-\-project, \-\-quiet, \-\-trace\-token, \-\-user\-output\-enabled,
\-\-verbosity.
Run \fB$ gcloud help\fR for details.
.SH "NOTES"
These variants are also available:
.RS 2m
$ gcloud alpha compute instances attach\-disk
.RE
.RS 2m
$ gcloud beta compute instances attach\-disk
.RE