### 問題
將正在使用中的云磁盤上傳到glance中時,即使使用強制模式(Web管理頁面中勾選了強制選擇、命令行有`--force`參數),依然無法成功。報錯信息為:磁盤正在使用中, `Volume status is in-use`。
### 原因
由于正在使用中的磁盤會有數據不斷寫入,而且存儲底層的驅動類型非常多,不一定支持熱備份。因此cinder服務默認關閉了強制上傳到鏡像服務的選項,但有時候有這樣的需求。
#### 解決方案
修改cinder配置文件`/etc/cinder/cinder.conf`
```
enable_force_upload = true
```
重啟服務
```
service cinder-volume restart
service cinder-scheduler restart
service cinder-api restart
```
將指定的磁盤上傳到glance
```
cinder upload-to-image 2d222555-9990-407d-a9b2-173743fce49c centos7-cloud-181108 --force=True --disk-format=qcow2
```
將鏡像保存到本地
```
openstack image save 13b920ad-a1e5-41aa-9714-635ae6d44741 --file centos7-cloud-181111.qcow2
```
### 相關鏈接
[https://bugs.launchpad.net/cinder/+bug/1523230](https://bugs.launchpad.net/cinder/+bug/1523230)