LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-21-2007, 01:02 PM   #1
tkmsr
Member
 
Registered: Oct 2006
Distribution: Ubuntu,Open Suse,Debian,Mac OS X
Posts: 798

Rep: Reputation: 39
adding linuxrc to initrd


How can I add linuxrc to initrd that is inside /boot folder on my pc
as give on man pages of initrd
http://www.netadmintools.com/html/initrd.man.html


What I understood is executable /linuxrc determines what is needed to (1) mount the normal root file-system (i.e. device type, device drivers, file system) and (2) the distribution media (e.g. CD-ROM, network, tape, ...). This can be done by asking the user, by auto-probing, or by using a hybrid approach.

I want to be able to create an initrd which I can give to my friend who can start installation from it . by mounting root on cd or dvd etc
 
Old 10-24-2007, 02:28 AM   #2
zulfilee
Member
 
Registered: Apr 2004
Location: India
Distribution: Redhat,Fedora
Posts: 430

Rep: Reputation: 39
Try this

# mkdir /tmp/init
# zcat /boot/initrd.img > /tmp/initrd.img
# mkdir init
# mount -o loop initrd.img init

Change the files u need inside the init dir ..

# umount init
# gzip -9 initrd.img
# mv initrd.img.gz /boot/initrd.img
 
Old 10-24-2007, 01:00 PM   #3
tkmsr
Member
 
Registered: Oct 2006
Distribution: Ubuntu,Open Suse,Debian,Mac OS X
Posts: 798

Original Poster
Rep: Reputation: 39
Quote:
Originally Posted by zulfilee View Post
Try this

# mkdir /tmp/init
# zcat /boot/initrd.img > /tmp/initrd.img
# mkdir init
# mount -o loop initrd.img init

Change the files u need inside the init dir ..

# umount init
# gzip -9 initrd.img
# mv initrd.img.gz /boot/initrd.img

Yes Actually what I did was
#gzip -dc initrd | cpio -id

so I got a directory that had a lot of files which I could modify including the init script but the only problem I faced was init was executable can I get the source code of this init script which actually does a pivot_root to mount the ISO to start the installation for any distribution fedora ,debian or suse etc etc any one
 
Old 10-25-2007, 01:31 AM   #4
zulfilee
Member
 
Registered: Apr 2004
Location: India
Distribution: Redhat,Fedora
Posts: 430

Rep: Reputation: 39
Ok am not able to get ur query properly still.
U want to edit linuxrc ? U can directly edit it since its a shell script [and not an exe].

Or can u post the list of files in ur initrd and as to which file u need the source for..
 
Old 10-25-2007, 01:39 PM   #5
tkmsr
Member
 
Registered: Oct 2006
Distribution: Ubuntu,Open Suse,Debian,Mac OS X
Posts: 798

Original Poster
Rep: Reputation: 39
Quote:
Originally Posted by zulfilee View Post
Ok am not able to get ur query properly still.
U want to edit linuxrc ? U can directly edit it since its a shell script [and not an exe].

Or can u post the list of files in ur initrd and as to which file u need the source for..
Yes you got it exactly but when I tried to edit that it was an executable ELF 32 bit some thing like that which was not opening in vi properly so I posted this question. So I feel If I get the source code then that would help me either of init or linuxrc
 
Old 10-26-2007, 01:25 AM   #6
zulfilee
Member
 
Registered: Apr 2004
Location: India
Distribution: Redhat,Fedora
Posts: 430

Rep: Reputation: 39
Getting the source should be a bit easy [or i think ]
In google just search for - "distro linuxrc.c".

If your distro is redhat linux ,the search for

redhat linuxrc.c

This should point to some locations where u can get the code.

- zulfi
 
Old 10-26-2007, 02:52 AM   #7
tkmsr
Member
 
Registered: Oct 2006
Distribution: Ubuntu,Open Suse,Debian,Mac OS X
Posts: 798

Original Poster
Rep: Reputation: 39
Quote:
Originally Posted by zulfilee View Post
Getting the source should be a bit easy [or i think ]
In google just search for - "distro linuxrc.c".

If your distro is redhat linux ,the search for

redhat linuxrc.c

This should point to some locations where u can get the code.

- zulfi
I do not have the habit of asking for help unnecessary things I have googled to an extent that is now frustrating to me
look here nothing is coming out
http://www.google.co.in/search?q=Ope...ient=firefox-a
http://www.google.co.in/search?hl=en...G=Search&meta=
http://www.google.co.in/search?hl=en...G=Search&meta=


In case you feel that there is something useful to be seen in these links do point out may be I missed something which I don't feel so .
 
Old 10-26-2007, 07:24 AM   #8
zulfilee
Member
 
Registered: Apr 2004
Location: India
Distribution: Redhat,Fedora
Posts: 430

Rep: Reputation: 39
Yeah it was not found in google.

But this should work ..

initrd.img of your system is created by mkinitrd command.
This command comes as a part of mkinitrd package.
In your Fedora PC try

$ rpm -qi mkinitrd

This will give your the rpm version.
Download the corresponding source rpm and this should have all your source files that are used to created the initrd image.




The kernel rpm runs the mkinitrd command before installing kernel to create the initrd file system. Happy tinkering ...
 
Old 10-26-2007, 07:26 AM   #9
zulfilee
Member
 
Registered: Apr 2004
Location: India
Distribution: Redhat,Fedora
Posts: 430

Rep: Reputation: 39
And one thing you may like to know [if u dont know already]

In a fedora,redhat box if u need source for any file ,
check which package the file belongs to

$ rpm -qif <filename>

Download the corresponding source rpm and installing this rpm should give you the source code.
[Default the source falls into /usr/src/redhat/SOURCES directory ]



- zulfi
 
Old 10-26-2007, 08:21 AM   #10
tkmsr
Member
 
Registered: Oct 2006
Distribution: Ubuntu,Open Suse,Debian,Mac OS X
Posts: 798

Original Poster
Rep: Reputation: 39
Quote:
Originally Posted by zulfilee View Post
The kernel rpm runs the mkinitrd command before installing kernel to create the initrd file system. Happy tinkering ...

But what about the initrd that is present on the dvd or cd that comes for installation is it also created by the same command which I don't think so
since I have checked both the initrd on cd and the one in boot folder the one installed has only the modules that are required for booting the system appropritately with the lini to script init that reads some where /etc/rc.S or inittab files and in case of the init on the dvd it should be different
since the fstab entries are to be different for installing the system



Quote:
Originally Posted by zulfilee View Post
$ rpm -qif <filename>
[Default the source falls into /usr/src/redhat/SOURCES directory ]
Ok I really did not knew this thing I am gonna try this and tell the result.
 
Old 10-26-2007, 04:38 PM   #11
tkmsr
Member
 
Registered: Oct 2006
Distribution: Ubuntu,Open Suse,Debian,Mac OS X
Posts: 798

Original Poster
Rep: Reputation: 39
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/SOURCES directory that I had to manually extract
there 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 filesystem

vecho "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/fstab which I think should not be done because when you start installation from CDROM it does not have any entries in /etc/fstab except the ones like proc etc


some 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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to compile initrd image adding new network drivers kiranbyk Linux - Software 3 05-30-2007 05:58 AM
GENTOO - "init=/linuxrc" (/linuxrc: not found | kernel panic!!) halo14 Linux - Distributions 6 01-14-2005 01:03 PM
adding QLA2300 module to initrd SuSe 8 Whodatindamud Linux - Hardware 0 06-09-2004 10:21 PM
Setting up an initrd, having probs with /linuxrc jtX Linux - Newbie 1 12-03-2003 09:30 PM
Dissecting linuxrc ( initrd ) nxny Linux - General 2 03-02-2003 03:32 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration