Skip to content

Instantly share code, notes, and snippets.

@chilicat
Created November 2, 2013 11:56
Show Gist options
  • Save chilicat/7278139 to your computer and use it in GitHub Desktop.
Save chilicat/7278139 to your computer and use it in GitHub Desktop.
Simple script to setup a cinder volume in a file.
#!/bin/sh
if [ "$1" == "" ]; then
echo "[ERROR] Please specify volume size. Usage: $0 3G"
exit 1
fi
# Create a file
dd if=/dev/zero of=cinder-volumes bs=1 count=0 seek=$1
# Create a loop device
losetup /dev/loop2 /cinder-volumes
# Make a auto mount
echo "losetup /dev/loop2 /cinder-volumes; exit 0;" > /etc/init.d/cinder-setup-backing-file
chmod 755 /etc/init.d/cinder-setup-backing-file
ln -s /etc/init.d/cinder-setup-backing-file /etc/rc2.d/S10cinder-setup-backing-file
# Create cinder volume
pvcreate /dev/loop2
vgcreate cinder-volumes /dev/loop2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment