Ask Your Question
0

How do I create a custom image for openstack?

asked 2011-02-23 18:06:22 -0500

maximiliano-caceres gravatar image

I want to build my own images to publis on my openstack cloud in ubuntu 10.10. I see that the tar.gz files contained inside vmlinuz, initrd and img files. "as I can create? What are the formats of each? Are KVM, RAW, qcow2?

help me please, it is important!

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2011-02-23 18:16:53 -0500

vishvananda gravatar image

They are raw. The easiest way would be to modify existing images. You can run images then you can modify the image all you want. Finally, you can euca-bundle-image

Another possibility (which may be easier) is to specify --nouse_cow in your flagfile, then when you are done modifying the image, you can do a shutdown -h now from inside the instance, then copy the disk file into a new image:

cp -r /var/lib/nova/images/<old-ami> /var/lib/nova/images<new-ami> cp -r /var/lib/nova/instances/<instance-id>/disk /var/lib/nova/images/<new-ami>/image

sed -i s/<old-ami>/<new-ami>/g /var/lib/nova/images/<new-ami>/info.json

(if you modify the kernel and ramdisk, you will need to copy them out of the image and make new ones and modify the info.json accordingly)

Vish

On Feb 23, 2011, at 10:06 AM, Maxmiliano Caceres wrote:

New question #146594 on OpenStack Compute (nova): https://answers.launchpad.net/nova/+q...

I want to build my own images to publis on my openstack cloud in ubuntu 10.10. I see that the tar.gz files contained inside vmlinuz, initrd and img files. "as I can create? What are the formats of each? Are KVM, RAW, qcow2?

help me please, it is important!


You received this question notification because you are a member of Nova Core, which is an answer contact for OpenStack Compute (nova).

edit flag offensive delete link more
0

answered 2011-03-01 15:20:30 -0500

maximiliano-caceres gravatar image

thanks for the answers but I discovered how to build my own custom images and wrote a tutorial:

Building a simple custom image First, generate and download a RAW image file form the UForge Builder same this fedora_12_ami_0.1rev2_raw.tar.gz

Decompress this file tar -xvf fedora_12_ami_0.1rev2_raw.tar.gz

Obtaining the disk image file First, mount the .raw file like a new device sudo losetup -f fedora_12_ami_0.1rev2_raw/fedora_12_ami_0.1rev2_raw.raw sudo losetup -a You'll see this message: /dev/loop0: [0803]:13606914 ($filepath) Observe what is the mounting location of our device: /dev/loop0 when $filepath is the route to the mounted .raw file.

Next, we know the starting point of the partition that we are interested fdisk /dev/loop0 NOTE: sure that the result is DOS-compatible, if you see this message WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u'). Follow the instructions and type c <enter>, then u <enter> and finally p <enter>.

You'll see something like: Disk /dev/loop0: 2147 MB, 2147475456 bytes 255 heads, 63 sectors/track, 261 cylinders, total 4194288 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00090d7a

  Device Boot      Start         End      Blocks   Id  System

/dev/loop0p1 * 63 3144388 1572163 83 Linux /dev/loop0p2 3144389 4192964 524288 82 Linux swap / Solaris Observe what is the start point of the /dev/loop0p1 partition. This number should be multiplied by 512 to obtain the correct value should enter only after trying to mount this partition. In this case: 63 x 512 = 32256.

Unmount the loop0 device losetup -d /dev/loop0

And then mount only the first partition of de same previous RAW file adding the -o parameter with value previously calculated. sudo losetup -f -o 32256 fedora_12_ami_0.1rev2_raw/fedora_12_ami_0.1rev2_raw.raw sudo losetup -a You'll see this message: /dev/loop0: [0803]:13606914 ($filepath) Observe again what is the mounting location of our device: /dev/loop0.

Copy the entire partition to a new part1.raw file sudo dd if=/dev/loop0 of=/tmp/part1.raw now we have our raw file of only the first partition

Unmount the loop0 device sudo losetup -d /dev/loop0

Obtaining the kernel and initrd files

Mount our new part1.raw file sudo mount -o loop /tmp/part1.raw /mnt sudo mount And observe then what is the mounting location of our device: /dev/loop0.

Finally access the root directory of the mounted device and copy the vmlinuz-2.6.31.5-127.fc12.i686 and initramfs-2.6.31.5-127.fc12.i686.img files.

Building our custom OpenStack image file

Once we have the . raw, initrfms, vmlinuz (and the rest we want to include) should rename them with a common name that includes the structure-UEC-$ arch $ arch "which defines the type of architecture i386 (32 bit) or amd64 (64 bit). For example:

ttylinux-uec-amd64-12.1_2.6.35-22_1 ... (more)

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2011-02-23 18:06:22 -0500

Seen: 202 times

Last updated: Mar 01 '11