找回密码
 注册
查看: 2528|回复: 0

openstack 虚机 卸载/挂载 系统卷

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2021-5-25 06:00:00 | 显示全部楼层 |阅读模式
调用 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
您需要登录后才可以回帖 登录 | 注册

本版积分规则

返回首页|Archiver|手机版|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )

GMT+8, 2026-6-12 00:04 , Processed in 0.020911 second(s), 24 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表