NavigationUser loginSpam?See spam posts on this site? If so, please don't reply to the spam! Instead, just report the URL to the webmaster. |
trying to write linuxrcI am trying to learn the boot process of Linux I have been reading for many days I need some help for the linuxrc script In case some one has read it please give me some link where I can read the source code of linuxrc script .That comes with Debian ISO |
Understanding the GNU / Debian Linux Boot Process
Please read this article
http://playingwithsid.blogspot.com/2007/10/understanding-gnu-debian-linux-boot.html
Cheers
--arky
Currently Playing With Sid
Understanding the GNU / Debian Linux Boot Process
actually before posting this question I had studied the links that you gave me any ways thanks for the reply , I actually want to read the source code of init and linuxrc that is invoked during the boot process .
Understanding the GNU / Debian Linux Boot Process
Have you looked at the documentation of 'linux from scratch'?
http://www.linuxfromscratch.org/
The documentation is still improving. There are also many articles on the net about the boot process and some are pretty good; 'google' turns up some good results with:
linux boot process linuxrc
Those articles probably do a better job of explaining some things than the LFS docs.
trying to write linuxrc
Oh yes I have looked the site that you are referring to actually some links were useful see these
http://www.geocities.com/potato.geo/bootlinuxcd-old.html
http://www.stockwith.uklinux.net/hints/
http://groups.google.com/group/alt.os.linux.suse/browse_thread/thread/87c601c3279398a9/899b4d108d69b81e?hl=en&lnk=st&q=#899b4d108d69b81e
http://groups.google.com/group/alt.os.linux.suse/browse_thread/thread/49256a53c7f6bacb/0b70e1e985d07766?hl=en&lnk=st&q=vmlinuz+initrd#0b70e1e985d07766
but I feel some more documentation is required look at this thread where I got the answer and now I came to conclusion that linuxrc is not invoked rather the init does the all on installation cd's
this link was most helpful to me
http://groups.google.com/group/alt.os.linux.suse/browse_thread/thread/87c601c3279398a9/899b4d108d69b81e?hl=en&lnk=st&q=#899b4d108d69b81e
but still I could not understand what is init doing on the installation CD so that I write one myself step by step
trying to write linuxrc
> but still I could not understand what is init doing on the
> installation CD so that I write one myself step by step
So get the source for 'init' and look at it.
If you have SYSV type init (default), then the code is in the
package for sysvinit:
apt-get source sysvinit
Also, unpack the initrd image (if you have one) to see what it
uses for 'init' - the program in the initrd image may be
completely different from what runs when the boot process is
complete. "linuxrc" is in the initrd-tools package.
trying to write linuxrc
I think this should help me but is there any online documentation that has these contents as you suggested
trying to write linuxrc
> I think this should help me but is there any online
> documentation that has these contents as you suggested
I don't know what you mean. The final "init" is a binary, so if you want to see what it does or how it works, install the source for it like in my previous post.
The 'linuxrc' can be easily extracted (it is called 'init' but it is a script):
mkdir junk
cd junk
cp /boot/initrd.img-whatever initrd.img-whatever.gz
gunzip initrd.img-whatever.gz
cpio -i < initrd.img-whatever
Then you can look at 'init' using an ordinary text editor.
This 'init' attempts to set up the system so that everything is ready when it switches to the real init program. 'udev' is set up, kernel logging, some virtual filesystems such as proc and sys are mounted, some drivers are loaded, and finally the real root filesystem is mounted and the real 'init' program is run.
trying to write linuxrc
I did exaxtly what you have mentioned and then opened the init to read it in vi but the text and characters that came were garbled and then I started for asking the source of linuxrc or init script from the initrd on the installation cd
cpio -i < initrd.img-whatever
after doing this as you said it was not readable in vi ,I have checked it that is why I am asking for the source if you are able to read then simply copy paste that here in this thread that should help me both the init and linuxrc
trying to write linuxrc
after doing this as you said it was not readable in vi ,I have checked it that is why I am asking for the source if you are able to read then simply copy paste that here in this thread that should help me both the init from the initrd and linuxrc
in my case after extracting the initrd of installation media I saw some files and direcotries in which there was init which was symlink to
/sbin/initbut was not readabletrying to write linuxrc
If the 'init' looks like garbage you are probably looking at a compiled binary. Without looking at the CD image that you have, there's no way of telling what code was used to produce it.
For CDs, "isolinux" is the usual way to boot, so you can read the documentation (it's scattered all over the place):
http://syslinux.zytor.com/iso.php
If you want to remaster a CD or create your own custom bootable CD, use 'google' to find articles on how to work with:
bootcd
dfsbuild
Building a system is not simple and there are so many ways to do things; unless you can explain exactly what you want to do, no one will be able to suggest any specific solutions. I still have no idea what you want to do with 'linuxrc', I've already said that on a running system the initrd image will have a linuxrc which is usually a batch script and you can read it, and I've told you how to download the source code for "init". If you really want to look at that binary "init" (/sbin/init), you need to be able to read the source code for it. If the source code doesn't make sense to you, then no one can help you with this. You probably don't want to edit that binary init because that code becomes the "parent process" on the system.
trying to write linuxrc
Ok by now I have checked as per said I downloaded mkinitrd-6.0.9-5.src.rpm
sysvinit-2.86 src rpm and installed which gave bz2 and tar files in
/usr/src/redhat/SOURCESdirectory that I had to manually extractthere was an mkinitrd script which had functions named
findnetdriver(),handlenetdev(),to me the interesting part started from line number 1209 where the script started building the filesystemvecho "Building initrd in $MNTIMAGE"
this was the line after which I guess it starts making the initrd but here what I saw it took the entries from
/etc/fstabwhich I think should not be done because when you start installation from CDROM it does not have any entries in/etc/fstabexcept the ones like proc etcsome lines I am copy pasting line no 1249
===================================mkdir $MNTIMAGE/dev/mapper
mknod $MNTIMAGE/dev/ram0 b 1 0
mknod $MNTIMAGE/dev/ram1 b 1 1
ln -sf ram1 $MNTIMAGE/dev/ram
mknod $MNTIMAGE/dev/null c 1 3
mknod $MNTIMAGE/dev/zero c 1 5
mknod $MNTIMAGE/dev/systty c 4 0
if ! echo "$(uname -m)" | grep -q "s390"; then
for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 ; do
mknod $MNTIMAGE/dev/tty$i c 4 $i
done
fi
for i in 0 1 2 3 ; do
mknod $MNTIMAGE/dev/ttyS$i c 4 $(($i + 64))
done
mknod $MNTIMAGE/dev/tty c 5 0
mknod $MNTIMAGE/dev/console c 5 1
mknod $MNTIMAGE/dev/ptmx c 5 2
mknod $MNTIMAGE/dev/rtc c 10 135
if [ "$(uname -m)" == "ia64" ]; then
mknod $MNTIMAGE/dev/efirtc c 10 136
fi
=============================================
and there onwards it gives all the messages like loading drivers etc but the linuxrc part that I had been searching is missing here
now what next should I try.
trying to write linuxrc
Ok I have got I think
sysvinit-2.86/srcthere was a file init.c which is what I wanted to see
I think you are referring to
http://packages.debian.org/etch/initrd-tools/all/filelistI got it thanks a lot for the replies and staying here till end.
trying to write linuxrc
> ... I saw it took the entries from /etc/fstab which I think
> should not be done
That is correct; mkinitrd typically builds for the system
you are running it on. The scripts can be customized, but
that doesn't help you if that's what you're trying to learn.
I had an old installer iso so I logged in as root and did:
mkdir tmp
mount -t iso9660 -o loop blahblahblah.iso tmp
cd tmp
Now there's an "install" directory and inside there is
"initrd.gz". You need to copy it somewhere else because
that directory is read only:
mkdir ~/myinit
cp install/initrd.gz ~/myinit/
cd ..
umount tmp
rmdir tmp
cd ~/myinit
Now you can unpack it:
gunzip initrd.gz
mkdir tmp
mount -o loop initrd tmp
cd tmp
Now look around again - no "linuxrc" or "init" in the top
directory. (But if you looked at "isolinux/isolinux.cfg"
in the mounted iso image earlier, you would have seen that
the 'init' parameter is set to sbin/init.)
cd sbin
less init
Now you should see the shell script that is used to set up the boot CD.
>mount -o loop initrd tmp
>>mount -o loop initrd tmpbut when I ran the above command it said me
# mount -o loop initrd /tmp/mount: you must specify the filesystem type
so I could not mount it as said a
and that is the reason I started asking for code on various forums then I copied it from my installation CD to a temp directory
>>the 'init' parameter is set to
sbin/initThis is absolutely right
these are the contents when I did
>>mkdir ~/myinit>>cp install/initrd.gz ~/myinit/
>>cd ..
>>umount tmp
>>rmdir tmp
>>cd ~/myinit
>>gzip -dc initrd | cpio -id
then an ls -l showed
total 728
drwxr-xr-x 2 root root 4096 Oct 28 15:42 bin
drwxr-xr-x 2 root root 4096 Oct 23 14:31 dev
-rw-r--r-- 1 root root 10761 Oct 23 14:31 devz
drwxr-xr-x 2 root root 4096 Oct 23 14:31 download
drwxr-xr-x 9 root root 4096 Oct 28 15:40 etc
-rwxr-xr-x 1 root root 580988 Oct 23 14:31 init -> /sbin/init
-rw-r--r-- 1 root root 5604 Oct 23 14:31 installkey.gpg
drwxr-xr-x 5 root root 4096 Oct 28 15:42 lib
-rw-r--r-- 1 root root 257 Oct 23 14:31 linuxrc.config
drwxr-xr-x 2 root root 4096 Oct 23 14:31 mnt
lrwxrwxrwx 1 root root 38 Oct 23 14:31 modules -> lib/modules/2.6.18.2-34-default/initrd
drwxr-xr-x 2 root root 4096 Oct 23 14:31 mounts
drwxr-xr-x 2 root root 4096 Oct 23 14:31 proc
drwxr-xr-x 2 root root 4096 Oct 23 14:31 root
drwxr-xr-x 2 root root 4096 Oct 23 15:21 sbin
drwxr-xr-x 2 root root 4096 Oct 23 14:31 sys
drwxrwxrwt 2 root root 4096 Oct 23 14:31 tmp
drwxr-xr-x 7 root root 4096 Oct 23 14:31 usr
drwxr-xr-x 10 root root 4096 Oct 23 14:31 var
and this init was
lrwxrwxrwx 1 root 252 10 Oct 23 16:26 init -> /sbin/initas you rightly said.
>mount -o loop initrd tmp
Your install CD is very different from mine.
If that 'init' file you have is not plain text then it's a binary executable file and should have 'ELF' near the start of the file:
less init
If it is an ELF file, then use 'strings' and search the results for clues such as 'version':
strings init|less
For that 'init' symlink, you should look in the 'sbin' directory that initrd that you unpacked, not in your actual /sbin directory.
trying to write linuxrc
>>For that 'init' symlink, you should look in the 'sbin' directory that initrd that you unpacked, not in your actual
/sbindirectory.I did the same actually and even there it is ELF so I never got the init actually
trying to write linuxrc
I find it strange that it is all the binary init - unfortunately I probably don't have the same .iso as you so I can't check if you missed something. The sysv init would have no idea how to do the basic setup of your system - it is rather mindless - but if it is in fact the only init invoked, then the place to look for the equivalent of the 'linuxrc' script is in etc/rcS.d - the symlink there with the lowest S?? number should point to the equivalent of linuxrc.