Wouldn’t it be nice to have the root filesystem of your Openstack VM inside a volume? This way you could install a lot of packages on the root partition without spreading the files over several volumes. You could take a snapshot of the entire system (OS & data) and boot right off it.
Openstack Folsom supports this feature. Here’s how you can create your own bootable volume:
- On your desktop machine, download the cloud image of the OS that you want to boot from a volume. I chose Ubuntu 12.10:
wget http://cloud-images.ubuntu.com/releases/quantal/release/ubuntu-12.10-server-cloudimg-amd64-disk1.img
- Now convert it to RAW format using qemu-img
qemu-img convert -O raw ubuntu-12.10-server-cloudimg-amd64-disk1.img ubuntu-12.10-server-cloudimg-amd64-disk1.raw
- Start up a regular VM from the Ubuntu cloud image (or any other image you have)
- Create a volume (that you later want to boot from) and attach it to the VM
- SSH into the VM and become root
- check if your volume is attached with
fdisk -l
. The volume device name is /dev/vdb in my case - ssh into your desktop machine (or wherever you have the RAW image) from the VM and write the image data directly into the volume device
ssh user@desktop cat ubuntu-12.10-server-cloudimg-amd64-disk1.raw > /dev/vdb
If you want your root partition to be larger than 2GB, you can now resize it to the volume size. To do that, start parted
, get the partition information, delete (!) the partition, create a new one with the same “start” value, but with (total size-1) as the end value. Partition type is “primary”, filesystem “ext4”.
root@3:/home/ubuntu# parted /dev/vdb
GNU Parted 2.3
Using /dev/vdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) unit B
(parted) p
Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 21474836480B
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 8225280B 2146798079B 2138572800B primary ext4 boot
(parted) rm 1
(parted) mkpart
Partition type? primary/extended? p
File system type? [ext2]? ext4
Start? 8225280
End? 21474836479
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? i
(parted) set 1 boot on
(parted) p
Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 21474836480B
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 8225280B 21474836479B 21466611200B primary ext4 boot
(parted) q
Information: You may need to update /etc/fstab.
Now you can detach the volume in Horizon and create a new instance. Choose “Boot from Volume” in “Volume Options” and choose your volume. You may also take a snapshot of the volume first, if you want to preserve it in a fresh state for later. You still need to choose an image in the “Details” section, which makes no sense in this case, since the VM is entirely booted off the volume.