Detaching a Volume from a VM
You can detach a volume from a virtual machine (VM), which enables you to attach it to another VM and then access your data again.
Unlinking a Volume from a VM Using Cockpit v2
For Linux VMs, the mounting of the volume must be permanent to prevent failure when starting the VM. For more information, see Initializing a Volume from a VM > (optional) Make the Mounting Permanent. |
-
In the Volumes dashboard, check the box of the volume you want to unlink from a VM.
-
Unlinking a volume on which data is being used or written may damage your resources.
-
You can unlink the root device from a VM if this VM is stopped. However, you will not be able to restart this VM using this root device.
The volume is selected.
You can also select a VM in the VMs dashboard and click Unlink Volume.
-
-
Click Unlink from VM.
A confirmation dialog box appears. -
Click Unlink.
The volume is unlinked from the VM.
Unlinking a Volume from a VM Using OSC CLI
For Linux VMs, the mounting of the volume must be permanent to prevent failure when starting the VM. For more information, see Initializing a Volume from a VM > (optional) Make the Mounting Permanent. |
The UnlinkVolume command detaches a Block Storage Unit (BSU) volume from a virtual machine (VM).
To detach the root device of a VM, this VM must be stopped.
$ osc-cli api UnlinkVolume --profile "default" \
--VolumeId "vol-12345678"
This command contains the following attributes that you need to specify:
-
DryRun
: (optional) If true, checks whether you have the required permissions to perform the action. -
ForceUnlink
: (optional) Forces the detachment of the volume in case of previous failure. Important: This action may damage your data or file systems. -
VolumeId
: The ID of the volume you want to detach.
The UnlinkVolume 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"
}
}
Unlinking a Volume from a VM Using oapi-cli
For Linux VMs, the mounting of the volume must be permanent to prevent failure when starting the VM. For more information, see Initializing a Volume from a VM > (optional) Make the Mounting Permanent. |
The UnlinkVolume command detaches a Block Storage Unit (BSU) volume from a virtual machine (VM).
To detach the root device of a VM, this VM must be stopped.
$ oapi-cli --profile "default" UnlinkVolume \
--VolumeId "vol-12345678"
This command contains the following attributes that you need to specify:
-
DryRun
: (optional) If true, checks whether you have the required permissions to perform the action. -
ForceUnlink
: (optional) Forces the detachment of the volume in case of previous failure. Important: This action may damage your data or file systems. -
VolumeId
: The ID of the volume you want to detach.
The UnlinkVolume 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"
}
}
Detaching a Volume from an Instance Using AWS CLI
For Linux instances, the mounting of the volume must be permanent to prevent failure when starting the instance. For more information, see Initializing a Volume from a VM > (optional) Make the Mounting Permanent. |
Before you begin: Install and configure AWS CLI. For more information, see Installing and Configuring AWS CLI. |
To detach a volume from an instance, use the detach-volume command following this syntax:
$ aws ec2 detach-volume \
--profile YOUR_PROFILE \
--volume-id vol-12345678 \
--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. -
endpoint
: The endpoint corresponding to the Region you want to send the request to. For more information, see Installing and Configuring AWS CLI.
The detach-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 the 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":"detaching",
"Device":"/dev/xvdb"
}
The volume is detached from the instance and is now available.
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.