From: <tb...@ti...> - 2001-10-20 02:15:25
|
After booting from a floppy, or a cdrom, you should have a file in the root called linuxrc. This is the basic "RUN COMPUTER" script that is run early in the boot process. It sets up the ramdisks, loads some needed modules and eventually starts the shells that run on the ttys. It would be nice to be able to modify this script with some echo's and debugging output, but where do you find the file to modify? First, the .iso file is a cdrom image. On linux, you can mount a cdrom. Or you can mount the image (.iso file) using the -o loop parameter to the mount command. If you have the trinux.iso file you need to mount it with: mount -o loop trinux.iso /mnt This will be mounted read only, so you will need to make a copy that you can later use to master another trinux.iso file. So, make a folder in /tmp called /tmp/trinux. I use the find/cpio command to copy the entire cdrom to the new work directory (/tmp/trinux). cd /mnt find . -depth -print | cpio -pmduv /tmp/trinux Once this is finished, you can umount the iso image with: cd /tmp umount /mnt Inside the work directory (/tmp/trinux) you will find the boot.img. This is an image of a floppy disk. This floppy disk image, is what allows a system to boot from cdrom. You see, the bios in these X86 systems don't really know how to boot from CDROM, so we trick it into thinking it is a floppy and we hand it a floppy image at boot time. Now, just like we mounted the iso image, to see what was there, we can mount the boot.img just as if we were mounting a floppy. Again, using the -o loop parameter to mount. cd /tmp/trinux mount -o loop boot.img /mnt Now we have a pseudo floppy mounted on /mnt. Unlike the CDrom iso image, this image is not read-only. You can modify it just like a floppy. However, searching this floppy image for the elusive linuxrc file will result in disappointment. If the linuxrc file doesn't exist on the iso image, and it doesn't exist on the boot.img floppy image, then where is it? Answer: The floppy boot process loads the kernel and is smart enough to unpack a previously prepared filesystem. This filesystem must be as small as possible, because it must fit entirely on the floppy with the kernel and the other necessary files. This germ of a filesystem is contained on the boot floppy as initrd.gz. It is compressed, to make it as small as possible. It is a minux filesystem, and can be mounted and modified just like the others, using the -o loop parameter to mount. First create another mountpoint in the root. mkdir /mnt2 Now cd /mnt and copy the initrd.gz file to /tmp Unzip the initrd file and then mount it to /mnt2 cd /tmp gunzip initrd.gz mount -o loop initrd /mnt2 cd to /mnt2 and there you will find the elusive linuxrc file. You can edit this file with vi, and save the changes in place. Just remember before you go adding another 50 lines of code, that this image needs to stay the same size. You have very little room for expansion. Once you have added your echos or special (debug) code, then you need to reverse the whole process. cd /tmp. umount /mnt2 This will release the initrd image in /tmp. Now zip this guy back up. gzip initrd copy this gzipped image back to the boot floppy image that is still mounted on /mnt cp initrd.gz /mnt Now you can unmount the floppy image from /mnt umount /mnt This will release the file boot.img that is in the working copy of the cdrom image (/tmp/trinux/boot.img). Now you can create a new iso image from the work directory. Something like this should work: cd /tmp/trinux mkisofs -v -J -o ../trinux.iso -b boot.img . This should give you a new iso image in /tmp that you can burn to a cd. Either use the cdrecord command in Linux, or copy it to a Microsoft OS and run Adaptec CD Creator to burn the iso image to a fresh CD blank. Debugging the CDROM boot process can be a real chore, but hopefully once you understand where the files are hiding, you have a fighting chance. Finally, once you get your CDROM booting the way you like, or find that nasty bug that is keeping your special situation from working like it should, don't keep it to yourself. Give Matt the lowdown or the diffs so he can incorporate the fix for all of us... I hope this helps... -- -------------------- Timothy Burt Internet Specialist |