--原文連接http://egonzalez.org/multiple-store-locations-for-glance-images/api
First we need to create the directories where hard disks are going to be mountedthis
sudo mkdir /var/lib/glance/lvm-images sudo mkdir /var/lib/glance/extended-images
Next, we mount the devices at the directories created in the previous steprest
sudo mount /dev/sdc1 /var/lib/glance/lvm-images/ sudo mount /dev/sdd1 /var/lib/glance/extended-images/
An important step is making the glance user the owner of that directoriescode
chown glance:glance /var/lib/glance/lvm-images/ chown glance:glance /var/lib/glance/extended-images/
Once the previous steps has been made, we need to configure the /etc/glance/glance-api.conf file. In this file, we’re going to configure glance to use multiple directories to store images. We search the section 「Filesystem Store Options」 and modify/create the following: We will leave the option 「filesystem_store_datadir=」 empty, if we comment this option, glance will use it as default store location and will show us an error during image creation. And we add the option 「filesystem_store_datadirs」, once for any directory we created in previous steps. We can use priorities on glance, priority 200 has precedence over priority 100, if we don’t specify any priority, default will be 0orm
# ============ Filesystem Store Options ======================== filesystem_store_datadir= filesystem_store_datadirs=/var/lib/glance/images filesystem_store_datadirs=/var/lib/glance/lvm-images:200 filesystem_store_datadirs=/var/lib/glance/extended-images:100
Once we have configured glance-api.conf, restart glance-api serviceip
systemctl restart openstack-glance-api
Now we’re going to create an imageci
glance image-create --name CirrosDatadir --file ~/Images/cirros-0.3.4-i386-disk.img --disk-format qcow2 --container-format bare --progress [=============================>] 100% +------------------+--------------------------------------+ | Property | Value | +------------------+--------------------------------------+ | checksum | 79b4436412283bb63c2cba4ac796bcd9 | | container_format | bare | | created_at | 2015-08-13T11:34:00.000000 | | deleted | False | | deleted_at | None | | disk_format | qcow2 | | id | 6ac8f5b9-5863-46ca-bb04-db352d35d829 | | is_public | False | | min_disk | 0 | | min_ram | 0 | | name | CirrosDatadir | | owner | 738ec25d8b9c41f9b0cf84ce25730e92 | | protected | False | | size | 12506112 | | status | active | | updated_at | 2015-08-13T11:34:09.000000 | | virtual_size | None | +------------------+--------------------------------------+