|
|
调用 nova volume-detach <server> <volume> 可以卸载云主机已挂载的云硬盘* G2 L4 o! }8 m* i1 x7 T _2 A, z9 O
但是如过卸载云主机的系统卷时会报如下错误:
& ` p7 r z! C8 P2 SERROR (Forbidden): Can't detach root device volume (HTTP 403)1 I5 v- S4 S1 ~1 O
0 P, ]5 F o, J5 Y0 Z M
如果想要卸载掉系统卷,可按如下步骤操作:
1 i- Q$ |3 C. s; L/ c! u1.cinder数据库中更改系统卷的mountpoint (系统卷的默认挂载点为/dev/vda)
/ J+ k) _7 f6 d- g% c, O1 Juse cinder;5 X6 M" H: ?4 R0 I
update volume_attachment set mountpoint='/dev/vdb' where volume_id = 'oldVolumeId' and deleted = 0;
9 m/ k, P' @2 D& T4 | u5 c! d
: j# N9 K# }3 ]' c8 z$ m7 \* N, ?2.nova数据库中更改系统卷的device_name(系统卷默认为/dev/vda) 和 启动顺序boot_index(系统卷默认为0)4 @! X0 ^3 E) E6 o. @7 {' 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 。
; G9 @" h8 s! x1 r/ \use nova;6 s3 s9 ^5 u# a7 Y% O
update block_device_mapping set device_name = '/dev/vdb', boot_index=1 where volume_id = 'oldVolumeId' and deleted = 0;
" K9 p4 H, g$ d; W, R+ J) p* h: i) y( S8 e }+ C D
3.在做完以上2步后再去卸载系统卷就可以了# `/ S$ ]1 g2 w5 H9 @' S
nova volume-detach <instanceId> <volumeId>.7 O# r5 Y: _- P" G1 u
# L! S7 x, ^* t9 y. _/ p3 Q" i**************************************************************************. k' Y7 h+ j5 w" `
说明: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
" C- l# |; ]6 c" v1 |, D同样的道理想要挂载系统卷可按如下步骤操作:
; Y, `4 r! j$ @0 b+ Z1.设置系统卷的挂载点8 d" S- f6 `7 p9 w6 k' N
use cinder;
2 h0 C; t/ {, p) B: tupdate volume_attachment set mountpoint='/dev/vda' where volume_id = 'shinyNewVolumeId' and deleted = 0;/ o& ~) V5 P2 {, G
( u0 L9 _1 B" j+ a: d! }
2.设置块设备映射名称和启动顺序
; k- i/ v- S8 e" h7 Y' O% cuse nova;" s+ q; N6 T# J+ n( i
update block_device_mapping set device_name = '/dev/vda', boot_index=0 where volume_id = 'shinyNewVolumeId' and deleted = 0;* H( g( p U9 M5 m J. D4 d
/ S3 S3 w7 ?6 f9 j, o3.为正在创建的实例强制生成一个新的和正确的libvirt配置
! @/ @- j( w/ ~3 F7 gnova reboot --hard <instanceId>+ l6 ]1 u6 D2 X0 N a- ~+ B& z
% [; G0 i" w, M8 g8 y5 |, U
' k a0 f2 i( X3 c. Q& \- U
/ `4 {' p: M0 i; C2 N |
|