Attaching a Volume to a VM
You can attach a volume to a virtual machine (VM) within the same Subregion to add additional storage. You can attach several volumes to a VM (up to 40), for example to separate different types of data. For more information, see About Volumes > Volumes Attachment and Device Names.
Linking a Volume to a VM Using Cockpit v2
-
Click inside the Volumes dashboard to make checkboxes appear.
You can also select a VM in the VMs dashboard and click
Link Volume.
-
Check the box of the volume you want to link.
The volume is selected and an action menu appears. -
Click
Link VM.
The LINK VM dialog box appears. -
In the VM list, select the VM you want to link the volume to.
-
In the Device list, select the device name you want to assign to the volume.
-
Click Link.
The volume is linked to the selected VM.Once the volume is attached, you must mount it on an operating system level to make it available for use. For more information, see Initializing a Volume from a VM.
Attaching a Volume to an Instance Using Cockpit v1
Cockpit v1 is no longer fixed nor supported. Cockpit v1 is no longer available in the cloudgouv-eu-west-1 Region. For more information, see End-of-Life Policy. |
-
Click Storage > Volumes.
You can also select an instance in the Instances page and click Attach Volume(s) .
-
Click the volume you want to attach to an instance.
The volume is selected. -
Click Attach .
The ATTACH VOLUME dialog box appears. -
In the Instance list, click the instance you want to attach the volume to.
Only the instances that are in the same Availability Zone as the volume you want to attach appear in the list.
-
In the Device list, click the device name you want to assign to the volume.
-
Click Attach.
The volume is attached to the selected instance.Once the volume is attached, you must mount it on an operating system level to make it available for use. For more information, see Initializing a Volume from a VM.
Linking a Volume to a VM Using OSC CLI
The LinkVolume command attaches a Block Storage Unit (BSU) volume to a virtual machine (VM).
The volume and the VM must be in the same Subregion. The VM can be running or stopped. The volume is attached to the specified VM device.
$ osc-cli api LinkVolume --profile "default" \
--VolumeId "vol-12345678" \
--VmId "i-12345678" \
--DeviceName "/dev/sdb"
This command contains the following attributes that you need to specify:
-
DeviceName
: The name of the device. For a root device, you must use/dev/sda1
. For other volumes, you must use/dev/sdX
,/dev/sdXX
,/dev/xvdX
, or/dev/xvdXX
(where the firstX
is a letter betweenb
andz
, and the secondX
is a letter betweena
andz
). -
DryRun
: (optional) If true, checks whether you have the required permissions to perform the action. -
VmId
: The ID of the VM you want to attach the volume to. -
VolumeId
: The ID of the volume you want to attach.
The LinkVolume command returns the following elements:
-
ResponseContext
: Information about the context of the response.-
RequestId
: The ID of the request.
-
{
"ResponseContext": {
"RequestId": "0475ca1e-d0c5-441d-712a-da55a4175157"
}
}
Once the volume is attached, you must mount it on an operating system level to make it available for use. For more information, see Initializing a Volume from a VM. |
Attaching a Volume to an Instance Using AWS CLI
To attach a volume to an instance, use the attach-volume command following this syntax:
$ aws ec2 attach-volume \
--profile YOUR_PROFILE \
--volume-id vol-12345678 \
--instance-id i-87654321 \
--device /dev/xvdb \
--endpoint https://fcu.eu-west-2.outscale.com
This command contains the following attributes that you need to specify:
-
(optional)
profile
: The named profile you want to use, created when configuring AWS CLI. For more information, see Installing and Configuring AWS CLI. -
volume-id
: The ID of the volume. -
instance-id
: The ID of the instance. -
device
: The device name you want to assign to the volume.You must use /dev/xvdX or /dev/xvdXX device names. For more information, see About Volumes > Volumes Attachment and Device Names.
-
endpoint
: The endpoint corresponding to the Region you want to send the request to.
The attach-volume command returns a result as follows:
-
AttachTime
: The time at which the attachment was initiated. -
InstanceId
: The ID of the instance. -
VolumeId
: The ID of the volume. -
State
: The attachment state of your volume (attaching
|detaching
|attached
|detached
). -
Device
: The device name you specified when attaching the volume.
{
"AttachTime": "2016-02-05T13:56:48.970Z",
"InstanceId": "i-87654321",
"VolumeId": "vol-12345678",
"State": "attaching",
"Device": "/dev/xvdb"
}
The volume is attached to the specified instance.
Once the volume is attached, you must mount it on an operating system level to make it available for use. For more information, see Initializing a Volume from a VM. |
Related Pages
Corresponding API Methods
AWS™ and Amazon Web Services™ are trademarks of Amazon Technologies, Inc or its affiliates in the United States and/or other countries.