openstack 卸载/挂载 系统卷

openstack 卸载/挂载 系统卷

调用 nova    volume-detach  <server>  <volume>  可以卸载云主机已挂载的云硬盘


但是如过卸载云主机的系统卷时会报如下错误:


ERROR (Forbidden): Can't detach root device volume (HTTP 403)


如果想要卸载掉系统卷,可按如下步骤操作:


1.cinder数据库中更改系统卷的mountpoint (系统卷的默认挂载点为/dev/vda)


use cinder;

update volume_attachment set mountpoint='/dev/vdb' where volume_id = 'oldVolumeId' and deleted = 0;


2.nova数据库中更改系统卷的device_name(系统卷默认为/dev/vda) 和 启动顺序boot_index(系统卷默认为0)


说明: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 。


use nova;

update block_device_mapping set device_name = '/dev/vdb', boot_index=1 where volume_id = 'oldVolumeId' and deleted = 0;


3.在做完以上2步后再去卸载系统卷就可以了


nova volume-detach <instanceId> <volumeId>.


**************************************************************************


说明: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.设置系统卷的挂载点


use cinder;

update volume_attachment set mountpoint='/dev/vda' where volume_id = 'shinyNewVolumeId' and deleted = 0;


2.设置块设备映射名称和启动顺序

use nova;

update block_device_mapping set device_name = '/dev/vda', boot_index=0 where volume_id = 'shinyNewVolumeId' and deleted = 0;


3.为正在创建的实例强制生成一个新的和正确的libvirt配置


nova reboot --hard <instanceId>

上一篇:Openstack对接Ceph时的错误

下一篇:没有了