Let's pretend our directories are:
~/work/android: directory where you did your git, envbuild, lunch/choosecombo from.
~/work/tmp: empty directory for us to play in
~/bin: directory on your path
If you have already done a build, you will find out/target/product/generic/system.img. This is a YAFFS2 file.
Preparation
In my case, I did not have a way to mount yaffs2 filesystems. I am sure I could have done some insmods and such; but instead, I chose to just compile this unyaffs.
~/work/tmp$ wget http://unyaffs.googlecode.com/files/unyaffs.c~/work/tmp$ wget http://unyaffs.googlecode.com/files/unyaffs.h~/work/tmp$ gcc -o unyaffs unyaffs.c~/work/tmp$ cp unyaffs ~/bin~/work/tmp$ rm *
Extracting system.img
~/work/tmp$ cp ~/work/android/out/target/product/generic/system.img .
~/work/tmp$ mkdir tmp2
~/work/tmp$ cd tmp2
~/work/tmp/tmp2$ unyaffs ../system.img
((modify files... for example, etc/init.goldfish.sh))
Rebuilding system.img
~/work/tmp$ rm system.img
~/work/tmp$ ~/work/android/out/host/linux-x86/bin/mkyaffs2image tmp2 system.img
Now you should be able to use the new system.img with your emulator =)
userdata.img and persist.img
These are handled in exactly the same way, just change the filenames.