|
|
调用 nova volume-detach <server> <volume> 可以卸载云主机已挂载的云硬盘/ Y/ y# y ]) Y1 h
但是如过卸载云主机的系统卷时会报如下错误:* r6 f% Q y* l, f4 `, r
ERROR (Forbidden): Can't detach root device volume (HTTP 403)
9 g6 j2 L o) C, {' s. o6 Q* F* t7 w
如果想要卸载掉系统卷,可按如下步骤操作:' C4 P9 r1 H! T) y
1.cinder数据库中更改系统卷的mountpoint (系统卷的默认挂载点为/dev/vda)
# q$ ?3 L3 G0 _* ]+ o1 O1 ]) Fuse cinder;
& q m6 N- n$ L2 nupdate volume_attachment set mountpoint='/dev/vdb' where volume_id = 'oldVolumeId' and deleted = 0;
' U+ p! {- q5 M. `( h8 n! e- X% O2 ^. X4 Q
2.nova数据库中更改系统卷的device_name(系统卷默认为/dev/vda) 和 启动顺序boot_index(系统卷默认为0)& Y; i0 A* L4 O4 C
说明: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 。
' P5 V/ C {& B- }% Z$ G4 |use nova;
2 U y: c" H$ S+ gupdate block_device_mapping set device_name = '/dev/vdb', boot_index=1 where volume_id = 'oldVolumeId' and deleted = 0;
' v9 r4 i* z, y1 y* S! t, j5 Z# E% h2 P, d: q3 i7 P& w# u2 Q3 v8 X# `
3.在做完以上2步后再去卸载系统卷就可以了 e4 I& s. [$ d$ n$ L
nova volume-detach <instanceId> <volumeId>.
i% ?/ s3 t1 F4 Y m8 a3 Q& m. g5 Z2 _8 ^! I5 {( \; z- |
**************************************************************************; i3 e4 i y5 K! K
说明: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
- ?1 g9 X" U7 \3 S+ k( |同样的道理想要挂载系统卷可按如下步骤操作:
1 g; D% G) m1 H, g, N$ }0 i% ^1.设置系统卷的挂载点" o# I- G/ L2 Y2 C3 w/ @- g
use cinder;
1 y$ S$ B b" A. |) o9 x. qupdate volume_attachment set mountpoint='/dev/vda' where volume_id = 'shinyNewVolumeId' and deleted = 0;
# X# O; n# V1 U8 o& ~# t+ a8 c6 K, Q2 P1 Q
2.设置块设备映射名称和启动顺序" Z6 I2 @; h: X5 M
use nova;# V {" O. a" o7 u0 J3 B
update block_device_mapping set device_name = '/dev/vda', boot_index=0 where volume_id = 'shinyNewVolumeId' and deleted = 0;0 F5 b& E% p! Y: Q
7 f! I& d4 Z: E4 g. y9 l3.为正在创建的实例强制生成一个新的和正确的libvirt配置
- a& g% b" O1 W4 Fnova reboot --hard <instanceId>
$ z. D* `. V. P. u
1 ?) s" R8 f+ F2 m/ a* D
/ M- s" j$ B, p6 u2 J3 N* A, e2 Y
% p! b: d/ D% ~( {+ P7 n. j |
|