|
|
调用 nova volume-detach <server> <volume> 可以卸载云主机已挂载的云硬盘
; V4 P% q1 _, T; J' C# Y7 T但是如过卸载云主机的系统卷时会报如下错误:* o7 m6 ^3 Z8 G( i8 {" {8 q
ERROR (Forbidden): Can't detach root device volume (HTTP 403)
* M8 v" i5 F1 V( Z) c# [* w! I, V* F4 i; ]4 e# }# r9 h
如果想要卸载掉系统卷,可按如下步骤操作:% E4 E1 Y( g6 { S7 o9 L
1.cinder数据库中更改系统卷的mountpoint (系统卷的默认挂载点为/dev/vda)" l4 D% `" ]; G! F8 @- k
use cinder;6 l Y8 v: @3 q: [
update volume_attachment set mountpoint='/dev/vdb' where volume_id = 'oldVolumeId' and deleted = 0;9 @" E1 r4 x2 M
4 W( D8 d/ t8 X+ i2 f$ {% S2.nova数据库中更改系统卷的device_name(系统卷默认为/dev/vda) 和 启动顺序boot_index(系统卷默认为0)
2 D. N- B3 B% n& S/ W说明:basically the mountpoint/device name must not be /dev/vda and boot_index must not be 0. If this is true, you can successfully remove the volume 。
' w: Q! m! n' j- P; A6 l% b+ Cuse nova;3 S# J {7 Y: H7 C! T4 P
update block_device_mapping set device_name = '/dev/vdb', boot_index=1 where volume_id = 'oldVolumeId' and deleted = 0;
5 y6 R# O7 X- ^- d ?5 A
( [4 E/ _' a$ h Z+ s3.在做完以上2步后再去卸载系统卷就可以了
# B& {" y% q5 jnova volume-detach <instanceId> <volumeId>.
0 J0 v% r# _/ M+ s4 q; L
9 N& ?; p1 G. T/ [**************************************************************************
9 ^! v; O+ s$ Y3 |说明:To attach another volume, do the same thing in reverse after having used nova volume-attach. That is, set the name back to /dev/vda and set the boot_index to 0 for the new volume
; u8 ^8 D0 m! \- V6 o7 l. i同样的道理想要挂载系统卷可按如下步骤操作:
* }3 N; y' e0 ?: z3 r; ~1.设置系统卷的挂载点
0 q4 t x) p+ E0 p8 |4 ^: `- Muse cinder;
) c& r' {2 q7 t u: supdate volume_attachment set mountpoint='/dev/vda' where volume_id = 'shinyNewVolumeId' and deleted = 0;
/ P$ O3 G; Z& B& L- W7 _( e0 ^" \ b7 r4 O
2.设置块设备映射名称和启动顺序$ {2 _) ~! D+ R9 [3 n; u. x
use nova;. _" Z" e9 K7 M$ W
update block_device_mapping set device_name = '/dev/vda', boot_index=0 where volume_id = 'shinyNewVolumeId' and deleted = 0;7 q9 m' v/ S6 U4 }" @! o
7 J# x C0 F& X/ ?/ g5 V9 R+ t3.为正在创建的实例强制生成一个新的和正确的libvirt配置
$ F. e% t! d: _/ y$ m: G' J* v. {nova reboot --hard <instanceId>/ C! H9 A( n; e+ f9 o
# }3 r! V0 A* V8 T+ x) _9 E5 H+ [; ?) s" A7 E+ F; ]7 \; K% M
" c/ i) q$ p* I ]1 d9 b* q7 X
|
|