Skip to main content

Adding a LVM Cinder Volume

 

mkfs.ext /dev/md0
mkdir /cinder-vol
mount /dev/md0 /cinder-volumes
dd if=/dev/zero of=/cinder-vol/cinder-vol bs=1 count=0 seek=3950G
losetup /dev/loop2 /cinder-vol/cinder-vol
pvcreate /dev/loop2
vgcreate cinder-vol /dev/loop2

Double check your work with pvdisplay and vgdisplay:

 [root@openstack ~]# pvdisplay
--- Physical volume ---
PV Name /dev/loop2
VG Name cinder-vol
PV Size <3.86 TiB / not usable 4.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 1011199
Free PE 1011199
Allocated PE 0
PV UUID HwHPNB-48pG-igg4-EU7d-Rucj-vniF-lrYP22

[root@openstack ~]# vgdisplay
--- Volume group ---
VG Name cinder-vol
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size <3.86 TiB
PE Size 4.00 MiB
Total PE 1011199
Alloc PE / Size 0 / 0
Free PE / Size 1011199 / <3.86 TiB
VG UUID ILuHCP-9822-V1GS-lMu7-eiRu-UD3S-9xqDwY

vim /etc/cinder/cinder.conf

[lvm]
volume_backend_name=lvm
volume_driver=cinder.volume.drivers.lvm.LVMVolumeDriver
iscsi_ip_address=192.168.2.57
iscsi_helper=lioadm
volume_group=cinder-vol
volumes_dir=/cinder-vol/cinder-vol

systemctl restart openstack-cinder-scheduler
systemctl restart openstack-cinder-volume

Update /usr/lib/systemd/system/openstack-losetup.service

ExecStart=/usr/bin/sh -c '/usr/sbin/losetup -j /cinder-vol/cinder-vol | /usr/bin/grep /cinder-vol/cinder-vol || /usr/sbin/losetup -f /cinder-vol/cinder-vol'
ExecStop=/usr/bin/sh -c '/usr/sbin/losetup -j /cinder-vol/cinder-vol | /usr/bin/cut -d : -f 1 | /usr/bin/xargs /usr/sbin/losetup -d'