Adam Moskowitz wrote:
> I need to create and populate EXT2 image files; that is, files that
> contain an EXT2 image and could be mounted like so:
>
>     mount -o loop ext2.img /mnt
>
> I know how to create the file (dd) and format it as an EXT2 image
> (mke2fs), but here's the catch: I need to be able to do the equivalent
> of mkdir, cp, chown, chmod, and chgrp *WITHOUT MOUNTING THE IMAGE FILE*,
> and to be able to do all of this from a script.
>
> Ideally it would look something like this:
>
>     #!/bin/bash
>     . . .
>     dd if=/dev/zero of=ext2.img bs=1024 32768"
>     mke2fs -F ext2.img
>     . . .
>     magic_ext2_prog -f ext2.img mkdir /another-dir
>     for f in some-dir/* ; do
>       magic_ext2_prog -f ext2.img cp $f /another-dir
>       magic_ext2_prog -f ext2.img chown adamm:adamm /another-dir/$f
>       magic_ext2_prog -f ext2.img chmod 0644 /another-dir/$f
>     done
>
> I know about the program "debugfs," and it will let me do some of what I
> want (mainly using the "-R request" option), but the man page warns that
> debugfs isn't really meant for this and has some trough edges (which
> worries me a bit); also (and more problematic), I don't see a way to use
> the "modify_inode" request from "-R".
>
> Does anyone know of other tools that will let me populate an EXT2 image
> file, again, *WITHOUT* mounting the file?
>
> Thanks,
> AdamM
>   
Oh, definitely take a look at knoppix and/or unionfs. It does what I 
think you are looking for. It works with an original ISO and cloop 
unionfs to keep the backing-store image read-only while making a 
writable write-aside copy in memory that you can modify. It's how they 
enable you to boot a linux on a CD and still do device discovery and 
manipulation for your hardware as well as allowing you to edit files. 
Every time there is a write, it gets written elsewhere and the original 
backing store remains unmodified.

http://www.knoppix.net/wiki/Cloop
http://www.fsl.cs.sunysb.edu/project-unionfs.html

_______________________________________________
Discuss mailing list
Discuss@lopsa.org
http://lopsa.org/cgi-bin/mailman/listinfo/discuss
This list provided by the League of Professional System Administrators
 http://lopsa.org/

Reply via email to