# 调用 AttachVolume 操作时发生错误 (VolumeInUse)：卷已附加到实例

- **ID:** `aws/ec2-ebs-volume-stuck-attaching`
- **领域:** aws
- **类别:** resource_error
- **错误码:** `VolumeInUse`
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

EBS 卷正在附加到 EC2 实例，但已附加到另一个实例，或者由于分离不完整而处于“卡住”状态。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| EC2 2016-11-15 | active | — | — |
| AWS CLI 2.16.0 | active | — | — |
| Amazon Linux 2023 | active | — | — |

## 解决方案

1. ```
   使用 detach-volume 命令从当前实例分离卷，等待状态变为 'available'，然后附加到所需实例。
   ```
2. ```
   如果卷卡在 'attaching' 状态，请停止其附加到的实例，然后使用 AWS 控制台或 CLI 的 --force 标志强制分离，然后重新附加。
   ```

## 无效尝试

- **Force detach the volume from the current instance without proper checks.** — Force detach can cause data corruption or leave the volume in an inconsistent state, and may require manual cleanup. (65% 失败率)
- **Restart the EC2 instance to which the volume is attached.** — Restarting doesn't detach the volume; it remains attached to the same instance. (90% 失败率)
- **Attach the volume to a different device name on the same instance.** — The error says it's already attached; you cannot attach the same volume twice to the same instance. (85% 失败率)
