Re: ext2 creator
Niall O Broin <[email protected]>
| Newsgroups | gmane.linux.bbc.devel |
|---|---|
| Organization | Irish Linux Users Group |
| Message-ID | <[email protected]> |
On Monday 15 September 2003 06:38, Nate Riffe wrote:
> For as long as I've been involved with the project, the root.bin
> initrd has been created using debugfs and a "script" which is fed into
> it. This has basically been ok for us, nevermind that the resulting
> filesystem is incomplete and does not pass fsck due to the
> incompleteness of our script. For a few days, I have been trying to
> design a similar system for producing a root filesystem image for a
> UML system. Debugfs's weaknesses are clearly showing (inability to
> create symlinks or chmod files, etc) and I am in need of a more
> appropriate tool. Specifically, I am looking for something more like
> genromfs or mkisofs, which creates a filesystem image and then fills
> it with the files it finds in a directory specified on the command
> line. I have not been able to find such a tool for creating ext2
> filesystems. Does anyone know of one?
Am I missing something here ? Surely this is trivial as
#!/bin/sh
FILE=$1
SOURCE=$2
MOUNT=/tmp/root.bin.$$
SIZE=$(du -s $SOURCE|awk '{print $1}')
#
# make a big enough empty file, put a filesystem on it, and copy files to it
#
dd if=/dev/zero of=$FILE bs=1k count=$SIZE
ls -l $FILE
mke2fs -m 0 -F $FILE
mkdir $MOUNT
mount -o loop $FILE $MOUNT
cd $SOURCE
cp -a . $MOUNT
umount $MOUNT
rmdir $MOUNT
This could probably use some refining but It Worked For Me. One oddity I
observed was that just by chance I tested it with my /etc which du -sh shows
to be 28M and yet when I mount the resultant filesystem, du -sh shows it to
be 19M. I'm guessing this is related to my / being on jfs, but I'm not sure.
In any event I think this is minor because the initrd will be quite a bit
smaller, and is then gzipped, so a bunch of zeros on the end will hardly
matter. Of course as we're always so tight with space on the BBC, this might
need to be modified to use the absolute minimum of space.
--
Niall