OpenStack命令行:
openstack volume create --snapshot { snapshot_id | snapshot_name } volume_name [ --size size ]
Cinder命令行:
cinder create --snapshot-id snapshot_id --name volume_name [ size ]
此命令用来通过快照创建新卷。
参数
参数 | 描述 |
---|---|
snapshot_id | 快照ID。 |
snapshot_name | 快照名称。 |
volume_name | 卷的名称。 |
size | 卷的容量。 说明 如果指定,必须大于等于快照时刻的源卷容量。 |
示例
示例1
创建卷clone-w1,容量为100 GiB。
[root@controller cinder(keystone_admin)]# openstack volume create --snapshot 025a1fbc-5423-44b0-85fc-913f07479842 clone-w1 --size 100
+---------------------+--------------------------------------+
| Field | Value |
+---------------------+--------------------------------------+
| attachments | [] |
| availability_zone | nova |
| bootable | false |
| consistencygroup_id | None |
| created_at | 2025-04-23T10:17:44.907350 |
| description | None |
| encrypted | False |
| id | d579d547-ef69-4653-835a-66e7d30ce6bc |
| migration_status | None |
| multiattach | False |
| name | clone-w1 |
| properties | |
| replication_status | None |
| size | 100 |
| snapshot_id | 025a1fbc-5423-44b0-85fc-913f07479842 |
| source_volid | None |
| status | creating |
| type | stor1 |
| updated_at | None |
| user_id | d60fa5458fda4f96bbf581bf6c2dd63e |
+---------------------+--------------------------------------+
示例2
创建卷clone-w4,容量为100 GiB。
[root@controller cinder(keystone_admin)]# cinder create --snapshot-id 025a1fbc-5423-44b0-85fc-913f07479842 --name clone-w4 100
+---------------------+--------------------------------------+
| Field | Value |
+---------------------+--------------------------------------+
| attachments | [] |
| availability_zone | nova |
| bootable | false |
| consistencygroup_id | None |
| created_at | 2025-04-23T10:17:44.907350 |
| description | None |
| encrypted | False |
| id | d579d547-ef69-4653-835a-66e7d30ce6bc |
| migration_status | None |
| multiattach | False |
| name | clone-w1 |
| properties | |
| replication_status | None |
| size | 100 |
| snapshot_id | 025a1fbc-5423-44b0-85fc-913f07479842 |
| source_volid | None |
| status | creating |
| type | stor1 |
| updated_at | None |
| user_id | d60fa5458fda4f96bbf581bf6c2dd63e |
+---------------------+--------------------------------------+