This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

create .img file for custom image

Other Parts Discussed in Thread: AM3352

I'm trying to create a .img file that I can later burn to a SD card to program my systems.

AM3352

SDK and tools from ti-processor-sdk-linux-am3335x-evm-01.00.00.00

I can use create-sdcard.sh script to program a SD card.  That works properly.

But my total filesystem size is < 500MB and I don't want the 16GB (or however big my SD card is) image that I get when I just "dd" from the SD card to an image file.

I've tried creating a file on disk, partitioning it, formatting the partitions, and copying the files there which seems to work, but when I unmount the file and remount it I get mount errors.  Similar behavior happens if I write it to an SD card and then try to mount the SD card.

Steps to duplicate (run as super-user):

#!/bin/bash
qemu-img create sdcard.img 500M

sfdisk -D -H 255 -S 63 -C 63 sdcard.img << EOF
,9,0x0C,*
10,,,-
EOF

kpartx -av sdcard.img
mkfs.vfat -F 32 -n "BOOT" /dev/mapper/loop0p1
mkfs.ext3 -L "rootfs" /dev/mapper/loop0p2

mkdir boot rootfs

mount /dev/mapper/loop0p1 boot/
mount /dev/mapper/loop0p2 rootfs/

cp -rd $HOME/work/boot/MLO boot/
cp -rd $HOME/work/boot/u-boot.img boot/
cp -rd $HOME/work/rootfs/* rootfs/

sync
sync

umount boot/ rootfs/
rmdir boot/ rootfs/
kpartx -dv sdcard.img

ddrescue -f sdcard.img /dev/sdb


Peter