X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=cirros-testvm%2Fsrc-cirros%2Fbuildroot-2015.05%2Fsupport%2Fscripts%2Fbuild-ext3-img;fp=cirros-testvm%2Fsrc-cirros%2Fbuildroot-2015.05%2Fsupport%2Fscripts%2Fbuild-ext3-img;h=1cab710c2555a7f6d2de84807cb57961081dba09;hb=b0a0f15dfaa205161a7fcb20cf1b8cd4948c2ef3;hp=0000000000000000000000000000000000000000;hpb=c6ac3cd55ee2da956195eee393b0882105dfad4e;p=packages%2Ftrusty%2Fcirros-testvm.git diff --git a/cirros-testvm/src-cirros/buildroot-2015.05/support/scripts/build-ext3-img b/cirros-testvm/src-cirros/buildroot-2015.05/support/scripts/build-ext3-img new file mode 100755 index 0000000..1cab710 --- /dev/null +++ b/cirros-testvm/src-cirros/buildroot-2015.05/support/scripts/build-ext3-img @@ -0,0 +1,152 @@ +#!/bin/sh + +BLOCKSIZE=516096 +WORKING_DIR=`pwd` + +echo "This script will create a bootable ext3 image from buildroot." + +echo "Enter the path to the image (${WORKING_DIR})" +read IMG_PATH + +if [ "${IMAGE_PATH}" = "" ]; then + IMAGE_PATH=${WORKING_DIR} +fi + +echo "Enter the name of the image file (buildroot.img)" +read IMG_NAME + +if [ "${IMAGE_NAME}" = "" ]; then + IMAGE_NAME="buildroot.img" +fi + +IMAGE=${IMAGE_PATH}/${IMAGE_NAME} + +echo "Enter the path and filename for the root filesystem" +echo "tarball that you want to install into the image" +read ROOT_PATH + +if [ "${ROOT_PATH}" = "" ]; then + echo "Error: you must specify a path." + exit 1 +fi + +CYLINDERS=`du --summarize --block-size=${BLOCKSIZE} ${ROOT_PATH}` +BYTE_SIZE=`du --summarize --block-size=${BLOCKSIZE} --human-readable ${ROOT_PATH}` + +CYLINDERS=${CYLINDERS%${ROOT_PATH}} +BYTE_SIZE=${BYTE_SIZE%${ROOT_PATH}} + +CYLINDERS=`expr ${CYLINDERS} "*" 2` + +echo "Now I will create an ext3 image file" +echo "using ${CYLINDERS} cylinders, with ${BLOCKSIZE} bytes per block" +echo "in other words, ${BYTE_SIZE}bytes..." + + dd if=/dev/zero of=${IMAGE} bs=${BLOCKSIZE}c count=${CYLINDERS} + +# Create file partition and filesystem + + # STEP 1. create partition + /sbin/losetup /dev/loop3 ${IMAGE} + # probably should figure out how to use GNU parted to do this non-interactively + /sbin/fdisk -u -C${CYLINDERS} -S63 -H16 /dev/loop3 + /sbin/losetup -d /dev/loop3 + + # STEP 2. make file system (ext3) + /sbin/losetup -o 32256 /dev/loop3 ${IMAGE} + /sbin/mkfs.ext3 /dev/loop3 + /sbin/losetup -d /dev/loop3 + +# Install Software to the image + mkdir -p ${IMAGE_PATH}/temp + mount -o offset=32256,loop ${IMAGE} ${IMAGE_PATH}/temp + tar -xvf ${ROOT_PATH} --directory ${IMAGE_PATH}/temp + # make sure to unmount the image + umount ${IMAGE_PATH}/temp + rm -rf ${IMAGE_PATH}/temp + +# Create a VMware .vmx file +cat > ${IMAGE_PATH}/buildroot.vmx <