# Copyright (C) 2009 One Laptop Per Child # Licensed under the terms of the GNU GPL v2 or later; see COPYING for details. . $OOB__shlib versioned_fs=$(read_config base versioned_fs) buildnr=$(read_buildnr) BLOCK_SIZE=512 NUM_HEADS=16 NUM_SECTORS_PER_TRACK=62 # FIXME trap signals and cleanup # FIXME check that traps due to errors are caught BOOT=$intermediatesdir/mnt-boot ROOT=$intermediatesdir/mnt-root umount $BOOT &>/dev/null || : umount $ROOT &>/dev/null || : mkdir -p $BOOT mkdir -p $ROOT make_image() { local vals=$1 local disk_size=${vals%,*} local ext= expr index "$vals" ',' &>/dev/null && ext=${vals#*,} echo "Making image of size $disk_size" echo "Create disk and partitions..." local num_blocks=$(($disk_size / $BLOCK_SIZE)) local num_cylinders=$(($num_blocks / $NUM_HEADS / $NUM_SECTORS_PER_TRACK)) local image_size=$(($num_cylinders * $NUM_HEADS * $NUM_SECTORS_PER_TRACK * $BLOCK_SIZE)) local os_part1_begin=$(($NUM_SECTORS_PER_TRACK * $BLOCK_SIZE)) [ -z "$ext" ] && ext="zd" local img=$intermediatesdir/$(image_name).$ext.disk.img dd if=/dev/urandom of=$img.fill bs=4096 count=1 2>/dev/null rm -f $img.fill.2mb for x in $(seq 512); do cat $img.fill >> $img.fill.2mb; done local n=$(($image_size / (1048576 * 2) + 1)) rm -f $img dd if=/dev/zero of=$img bs=1M count=1 2>/dev/null for x in $(seq $n); do cat $img.fill.2mb >> $img; done truncate --size=$image_size $img rm -f $img.fill.2mb /sbin/sfdisk -S 32 -H 32 --force -uS $img <