Tools similar to e2fsimage :
*
genext2fs : can create ext2 images of desired size, you can choose the owner of the files on the disk (not individually last I checked), create char/block devices on the image from a listing, etc. Used it for my own OS, wonderful tool. Dunno if it works under cygwin though. Works as non-root.
* mtools : Can access read/write FAT images. (And even, there's an obscure option *somewhere* that allows it to operate on a chosen partition of a hard disk image with partitions on it. Yes sir.). Used it to script access to qemu disk images, works fine as non-root.
* If you're interested in a tool which creates SFS (Simple FileSystem) disk images, I have written one so just ask (bash script - uses dd and hexdump, works as non-root).
For "bare" grub disk images, you can use raw offsets in your menu.lst. Here are the commands (adapted from Jezze's commands) :
Code:
dd if=/dev/zero of=os.img bs=512 count=2880
dd if=stage1 conv=notrunc of=os.img bs=512 seek=0
dd if=stage2 conv=notrunc of=os.img bs=512 seek=1
Generate the menu.lst, add it to the image and tell grub to use it :
Code:
cat > menu.lst <<EOF
# grub's menu.lst for your awesome OS.
title My Awesome OS
# 200 is kernel offset, 100 is kernel length (can be greater)
kernel (fd0)300+100
# 300 is module offset, 50 is module length (can be greater)
module (fd0)400+50
EOF
dd if=menu.lst conv=notrunc of=os.img bs=512 seek=200
grub <<EOF
device (fd0) os.img
install (fd0)0+1 (fd0) (fd0)1+199 (fd0)200+1
EOF
Add the kernel & modules :
Code:
dd if=kernel.bin conv=notrunc of=os.img bs=512 seek=300
dd if=module conv=notrunc of=os.img bs=512 seek=400
Can't remember the "raw sectors offset" syntax for grub off the top of my head, so it might be slightly different.
Also, IIRC, grub auto-detects the menu.lst if you put it just after stage2, with no gap inbetween, so in that case you wouldn't need the grub-install part, but I might be mistaken.
P.S. : I'll correct the grub syntax and upload my SFS tool somewhere when I find the relevant pieces of code in my archives...