Hi Mark,
This is my instructions howto create initrd.
NOTE: if your initrd is _not_ the same size as in kernel image
you have to patch and compile kernel with size of your initrd

How to create ram disk:

1. Create your own dir:
לתתתתתתתmkdir -p /work/RAM

2. Go to work from your dir:
לתתתתתתתcd /work/RAM

3. Make new ramdisk image file of size 46080 Blocks
   (real will be 44619 1k-blocks)
   if=<read_from_file_name>
   of=<write_to_file>
   bs=<block_size>
   count=<number_of_blocks>
לתתתתתתתdd if=/dev/zero of=ramdisk_new bs=1k count=46080

4. Associate loop device /dev/loop0 with ramdisk_new file:
לתתתתתתתlosetup /dev/loop0 ramdisk_new

5. Build ext2 filesystem in ramdisk_new file by using loop device:
לתתתתתתת-t <type_of_file_system>
לתתתתתתת-i <bytes/inode_ratio>
לתתתתתתת-m <reserved_blocks_percentage_for_super_user>
לתתתתתתתmkfs -t ext2 -i 4096 -m 0 /dev/loop0 46080

   NOTE: another way to do:
   לתתתתmke2fs -m 0 -b 1024 /dev/loop0
   לתתתתtune2fs -i 0 /dev/loop0

6. Mount created ram disk file 'ramdisk_new' by using loop device:
לתתתתתתתmount -t ext2 /dev/loop0 /mnt/tmp

7. Check created file system:
לתתתתתתתdf /mnt/tmp
Filesystem           1k-blocks      Used Available Use% Mounted on
/dev/loop0               44619        13     44606   1% /mnt/tmp

לתתתתתתתls -al
total 17
drwxr-xr-x    3 root     root         1024 Aug 15 12:34 ./
drwxrwxrwx    8 root     root         4096 Aug  8 11:53 ../
drwxr-xr-x    2 root     root        12288 Aug 15 12:34 lost+found/

8. Copy or create whatever you want.
   Example:
לתתתתתתת(cd /usr; find . | cpio -pmd /mnt/tmp)
   will copy all /usr tree into ramdisk_new file

9. Unmount ramdisk_new:
לתתתתתתתumount /mnt/tmp

10. Detach ramdisk_new file from /dev/loop0
לתתתתתתתlosetup -d /dev/loop0

11. Clean up new ramdisk file:
     fsck /work/RAM/initrd_new

12. Compress ramdisk_new file with maximum compression:
לתתתתתתתgzip -v9 < ramdisk_new > initrd

Regards,
Julia

"Post, Mark K" wrote:

> As the subject states, I'm trying to build a new (completely custom) initrd
> file.  The method I've been following is this:
>         dd if=/dev/zero of=initrd bs=1024 count=10240
>         mke2fs -F -b 4096 initrd
>         mount initrd /mnt -o loop
>         populate the initrd
>         umount /mnt
>         gzip initrd
>
> I then copy the initrd.gz file to my VM guest where I want to use it, punch
> the kernel (with initrd support in it), parmfile, and initrd.gz file to the
> reader, and IPL from the reader.
>
> Everything seems fine until it gets to mounting the root file system (the
> parmfile has root=/dev/ram0 in it).  At that point I get the
> EXT2-fs: Magic mismatch, very weird !
> error.
>
> If I take the same kernel and parmfile, and use one of the initrd files from
> SuSE or Red Hat, that works just fine.  So I know my kernel and parmfile are
> good, and the only variable is the initrd itself.
>
> The other strange this is that if I IPL with a usable initrd, and then copy
> the unusable initrd over, I can mount it on the loopback device as an ext2
> file system with no problems.  Very strange.
>
> Any help anyone can offer?
>
> Mark Post

--
 o    || Julia Karastoianova > Turbolinux, Inc.
/\_  _|| [EMAIL PROTECTED]  > Research & Development in the U.S.
\__`[_ | ph. (650)228-5156   > 8000 Marina Blvd, Suite 300,
][ \, || fax (650)228-5001   > Brisbane CA 94005 USA

Reply via email to