Here is my code for attachment of EC2 with EBS volume.
private static AttachVolumeResult attachEBSVolume(String volumeId, String instanceId, String device){
AttachVolumeRequest attachVolReq = new AttachVolumeRequest(volumeId, instanceId, device);
return ec2.attachVolume(attachVolReq);
}
Its works fine for the first time but when I run it again It gives the following exception. Kindly tell me how can solve it and please also tell me what is the deviceName (3rd parameter) parameter in the parameter and what can be its possible values. Thanks
This is function call shown below
attachEBSVolume(createRes.getVolume().getVolumeId(), "InstanceIDhere", "xvdg");
Below is the Exception Arise ::
AWS Error Code: InvalidParameterValue, AWS Error Message: Invalid value 'xvdg' for unixDevice. Attachment point xvdg is already in use.
You can attach only one EBS volume with one EC2 device. There are multiple devices available for example xvdg, xvdh, , /dev/sdf. In the code what you are doing is that You are trying to attach a different EBS volume to same device , which is not allowed by AWS. so You can attach only one EBS volume with one device.
You can save the ID of EBS volume using this function
CreateVolumeResult createRes = makeEBSVolume(volSize, availabilityZone, "taghere");
createRes.getVolume().getVolumeId() // to save the volume ID
After saving this ID you can attach this ID with your EC2 (instance ID) every time you need.
You are trying to attach different volumes to the same "xvdg" device.
You should use different devices too - xvdh, xvdi, ... xvdp.
Then inside of the instance you will see them as /dev/xvdg, /dev/xvdh, etc.
Here is my code for attachment of EC2 with EBS volume.
private static AttachVolumeResult attachEBSVolume(String volumeId, String instanceId, String device){
AttachVolumeRequest attachVolReq = new AttachVolumeRequest(volumeId, instanceId, device);
return ec2.attachVolume(attachVolReq);
}
Its works fine for the first time but when I run it again It gives the following exception. Kindly tell me how can solve it and please also tell me what is the deviceName (3rd parameter) parameter in the parameter and what can be its possible values. Thanks
This is function call shown below
attachEBSVolume(createRes.getVolume().getVolumeId(), "InstanceIDhere", "xvdg");
Below is the Exception Arise ::
AWS Error Code: InvalidParameterValue, AWS Error Message: Invalid value 'xvdg' for unixDevice. Attachment point xvdg is already in use.
You can attach only one EBS volume with one EC2 device. There are multiple devices available for example xvdg, xvdh, , /dev/sdf. In the code what you are doing is that You are trying to attach a different EBS volume to same device , which is not allowed by AWS. so You can attach only one EBS volume with one device.
You can save the ID of EBS volume using this function
CreateVolumeResult createRes = makeEBSVolume(volSize, availabilityZone, "taghere");
createRes.getVolume().getVolumeId() // to save the volume ID
After saving this ID you can attach this ID with your EC2 (instance ID) every time you need.
You are trying to attach different volumes to the same "xvdg" device.
You should use different devices too - xvdh, xvdi, ... xvdp.
Then inside of the instance you will see them as /dev/xvdg, /dev/xvdh, etc.
0 commentaires:
Enregistrer un commentaire