|
|
调用 nova volume-detach <server> <volume> 可以卸载云主机已挂载的云硬盘' N$ U) l. W2 m5 q4 G+ X8 g8 W
但是如过卸载云主机的系统卷时会报如下错误:( ]) {+ `# R, }3 ]! [
ERROR (Forbidden): Can't detach root device volume (HTTP 403)$ {. A9 ]( g, ?, _. a
% d5 d3 o4 ~( _5 u& b! H如果想要卸载掉系统卷,可按如下步骤操作:+ K) @ l$ }5 f; K( N: m7 _7 P9 g! w% B. y
1.cinder数据库中更改系统卷的mountpoint (系统卷的默认挂载点为/dev/vda)) r( N( F0 a. h1 X! L ]
use cinder;
+ l6 n+ e' ~$ K5 d% yupdate volume_attachment set mountpoint='/dev/vdb' where volume_id = 'oldVolumeId' and deleted = 0;' k5 t1 s, h3 F4 x3 A9 r6 O* e
$ m4 Y. ]' U/ e- v6 Z
2.nova数据库中更改系统卷的device_name(系统卷默认为/dev/vda) 和 启动顺序boot_index(系统卷默认为0)0 ^ h; j* q+ Y/ y
说明: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 。+ K+ w, _. Y0 X* B
use nova;
% Z1 e6 `: u5 [* I# A, F- }update block_device_mapping set device_name = '/dev/vdb', boot_index=1 where volume_id = 'oldVolumeId' and deleted = 0;
1 k& y: h, o3 B9 T; }& U) k) i! Q: r
0 |' ?0 ]( q. p7 }3.在做完以上2步后再去卸载系统卷就可以了6 S. }6 v1 r! x+ E
nova volume-detach <instanceId> <volumeId>.
4 C5 E7 i/ k+ J( D4 h3 t" |7 C: P8 ]& S9 P# v6 A
**************************************************************************
4 R! l- R a! e' N# H5 G说明: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 volume5 v$ J9 B! c* s0 u- t+ e+ M" J
同样的道理想要挂载系统卷可按如下步骤操作:/ X5 B7 G% z' H3 x. l- G; g1 B
1.设置系统卷的挂载点8 Q: z& T$ [; E0 `3 F
use cinder;/ X0 m/ I0 o% W' k& f- E+ `% i
update volume_attachment set mountpoint='/dev/vda' where volume_id = 'shinyNewVolumeId' and deleted = 0;
, h' o# O6 I9 L* _7 O
$ D0 i( `0 b0 O$ h" M, Z8 P2 w2.设置块设备映射名称和启动顺序
2 T# Z6 R! l' V" _2 P! Wuse nova;
8 R, W, p; `+ ^1 o4 Wupdate block_device_mapping set device_name = '/dev/vda', boot_index=0 where volume_id = 'shinyNewVolumeId' and deleted = 0;
7 Z8 u; M+ ?4 V5 i2 F6 Y( p. ^$ a' x0 A E/ I& [/ b: }
3.为正在创建的实例强制生成一个新的和正确的libvirt配置
9 c* \( {: F8 V4 r8 bnova reboot --hard <instanceId>- R! K. q, W; k' u+ H
a1 m) R+ ?( j3 o
- n2 m, ^0 J4 U. `) _4 ?7 Q! n2 a w$ J
% @6 V1 a7 V0 r1 B |
|