6 echo "This script will create a bootable ext3 image from buildroot."
8 echo "Enter the path to the image (${WORKING_DIR})"
11 if [ "${IMAGE_PATH}" = "" ]; then
12 IMAGE_PATH
=${WORKING_DIR}
15 echo "Enter the name of the image file (buildroot.img)"
18 if [ "${IMAGE_NAME}" = "" ]; then
19 IMAGE_NAME
="buildroot.img"
22 IMAGE
=${IMAGE_PATH}/${IMAGE_NAME}
24 echo "Enter the path and filename for the root filesystem"
25 echo "tarball that you want to install into the image"
28 if [ "${ROOT_PATH}" = "" ]; then
29 echo "Error: you must specify a path."
33 CYLINDERS
=`du --summarize --block-size=${BLOCKSIZE} ${ROOT_PATH}`
34 BYTE_SIZE
=`du --summarize --block-size=${BLOCKSIZE} --human-readable ${ROOT_PATH}`
36 CYLINDERS
=${CYLINDERS%${ROOT_PATH}}
37 BYTE_SIZE
=${BYTE_SIZE%${ROOT_PATH}}
39 CYLINDERS
=`expr ${CYLINDERS} "*" 2`
41 echo "Now I will create an ext3 image file"
42 echo "using ${CYLINDERS} cylinders, with ${BLOCKSIZE} bytes per block"
43 echo "in other words, ${BYTE_SIZE}bytes..."
45 dd if=/dev
/zero of
=${IMAGE} bs=${BLOCKSIZE}c count=${CYLINDERS}
47 # Create file partition and filesystem
49 # STEP 1. create partition
50 /sbin
/losetup
/dev
/loop3
${IMAGE}
51 # probably should figure out how to use GNU parted to do this non-interactively
52 /sbin
/fdisk
-u -C${CYLINDERS} -S63 -H16 /dev
/loop3
53 /sbin
/losetup
-d /dev
/loop3
55 # STEP 2. make file system (ext3)
56 /sbin
/losetup
-o 32256 /dev
/loop3
${IMAGE}
57 /sbin
/mkfs.ext3
/dev
/loop3
58 /sbin
/losetup
-d /dev
/loop3
60 # Install Software to the image
61 mkdir
-p ${IMAGE_PATH}/temp
62 mount
-o offset
=32256,loop
${IMAGE} ${IMAGE_PATH}/temp
63 tar -xvf ${ROOT_PATH} --directory ${IMAGE_PATH}/temp
64 # make sure to unmount the image
65 umount
${IMAGE_PATH}/temp
66 rm -rf ${IMAGE_PATH}/temp
68 # Create a VMware .vmx file
69 cat > ${IMAGE_PATH}/buildroot.vmx
<<EOF
71 virtualHW.version = "3"
73 uuid.location = "56 4d 5c cc 3d 4a 43 29-55 89 5c 28 1e 7e 06 58"
74 uuid.bios = "56 4d 5c cc 3d 4a 43 29-55 89 5c 28 1e 7e 06 58"
76 uuid.action = "create"
77 checkpoint.vmState = ""
79 displayName = "Buildroot"
81 guestinfo.vmware.product.long = ""
82 guestinfo.vmware.product.url = "http://dcgrendel.be/vmbuilder/"
88 sched.mem.pshare.enable = "TRUE"
89 MemAllowAutoScaleDown = "FALSE"
95 mks.enable3d = "FALSE"
96 vmmouse.present = "TRUE"
98 tools.syncTime = "TRUE"
99 tools.remindinstall = "FALSE"
101 isolation.tools.hgfs.disable = "FALSE"
102 isolation.tools.dnd.disable = "FALSE"
103 isolation.tools.copy.enable = "TRUE"
104 isolation.tools.paste.enabled = "TRUE"
105 gui.restricted = "FALSE"
107 ethernet0.present = "TRUE"
108 ethernet0.connectionType = "bridged"
109 ethernet0.addressType = "generated"
110 ethernet0.generatedAddress = "00:0c:29:7e:06:58"
111 ethernet0.generatedAddressOffset = "0"
114 usb.generic.autoconnect = "FALSE"
116 sound.present = "TRUE"
117 sound.virtualdev = "es1371"
119 ide0:0.present = "TRUE"
120 ide0:0.fileName = "buildroot.vmdk"
121 ide0:0.deviceType = "disk"
124 ide0:0.writeThrough = "FALSE"
125 ide0:0.startConnected = "TRUE"
127 ide1:0.present = "FALSE"
129 ide1:0.deviceType = "disk"
132 ide1:0.writeThrough = "FALSE"
133 ide1:0.startConnected = "FALSE"
135 floppy0.present = "FALSE"
137 serial0.present = "FALSE"
139 serial1.present = "FALSE"
141 parallel0.present = "FALSE"
146 /sbin
/grub
--no-floppy --batch <<EOT
147 device (hd0) ${IMAGE}
148 geometry (hd0) ${CYLINDERS} 16 63