个人工具

UbuntuHelp:UEC/BundlingImages

来自Ubuntu中文

Wikibot讨论 | 贡献2009年11月17日 (二) 20:59的版本 (创建新页面为 '{{From|https://help.ubuntu.com/community/UEC/BundlingImages}} {{Languages|UbuntuHelp:UEC/BundlingImages}} Using UEC consists of creating and registering images with the Cloud Co...')

(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航, 搜索

Using UEC consists of creating and registering images with the Cloud Controller. There is more than one way to obtain a virtual image:

  • Download an image from the network, bundle and upload it
  • Create a custom image using VMBuilder
  • Use the Image store to download and install and image

Here we will describe the process of downloading one of the Official Ubuntu UEC Images that we publish and maintain on a regular basis.

Note: the shell variables that are set in the below code snippets are very useful for scripts or to reuse them when typing commands.
  1. Download the UEC image for the architecture you want. You can do it from your browser or from the command line:
TIMESTAMP=$(date +%Y%m%d%H%M%S)
RELEASE=karmic
ARCH=amd64    # Or this might be i386
[ $ARCH = "amd64" ] && IARCH=x86_64 || IARCH=i386
UEC_IMG=$RELEASE-uec-$ARCH
URL=http://uec-images.ubuntu.com/$RELEASE/current/
[ ! -e $UEC_IMG.tar.gz ] &&  wget $URL/$UEC_IMG.tar.gz # This may take a bit, depending on your connectivity
  1. Next, you will need to bundle, upload and register a kernel, ramdisk and finally your image:
    1. Unpack the UEC image tarball
    [ ! -e $UEC_IMG.img ] && tar -S -xzf $UEC_IMG.tar.gz
    
    1. Bundle the kernel
    BUCKET_KERNEL="k-$TIMESTAMP"
    UEC_KERNEL=$UEC_IMG-vmlinuz-virtual
    euca-bundle-image -i $UEC_KERNEL -r $IARCH --kernel true
    euca-upload-bundle -b $BUCKET_KERNEL -m /tmp/$UEC_KERNEL.manifest.xml
    EKI=$(euca-register $BUCKET_KERNEL/$UEC_KERNEL.manifest.xml | grep "^IMAGE" | awk '{print $2}') && echo $EKI
    
    1. Bundle the initrd
    BUCKET_INITRD="r-$TIMESTAMP"
    UEC_INITRD=$UEC_IMG-initrd-virtual
    euca-bundle-image -i $UEC_INITRD -r $IARCH --ramdisk true
    euca-upload-bundle -b $BUCKET_INITRD -m /tmp/$UEC_INITRD.manifest.xml
    ERI=$(euca-register $BUCKET_INITRD/$UEC_INITRD.manifest.xml | grep "^IMAGE" | awk '{print $2}') && echo $ERI
    
    1. Bundle the image itself (this can take some time)
    BUCKET_IMAGE="i-$TIMESTAMP"
    UEC_IMG=$RELEASE-uec-$ARCH
    euca-bundle-image -i $UEC_IMG.img -r $IARCH --kernel $EKI --ramdisk $ERI # This will take a long time (~10m)
    euca-upload-bundle -b $BUCKET_IMAGE -m /tmp/$UEC_IMG.img.manifest.xml
    EMI=$(euca-register $BUCKET_IMAGE/$UEC_IMG.img.manifest.xml | grep "^IMAGE" | awk '{print $2}') && echo $EMI
    
    Alternate: The uec-tools branch has a script named 'register-uec-tarball' that combines the steps above.
    # invoke as ./register-uec-tarball <tarball> <bucket> [<arch>]
    ./register-uec-tarball ubuntu-9.10-uec-amd64.tar.gz ubuntu-9.10-uec-release-amd64
     
    1. Now, your kernel, ramdisk and image will have been uploaded into Eucalyptus and should be ready to run. To confirm, run the following command:
    euca-describe-images
    
    You should see a registered kernel, ramdisk and image and they should be marked as 'available'.