LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-28-2003, 01:46 PM   #1
nxny
Member
 
Registered: May 2002
Location: AK - The last frontier.
Distribution: Red Hat 8.0, Slackware 8.1, Knoppix 3.7, Lunar 1.3, Sorcerer
Posts: 771

Rep: Reputation: 30
Question Dissecting linuxrc ( initrd )


Guys,

I unzipped my initrd and mounted it as a loopback filesystem, so I could pull it apart and see what's going on inside. The the filesystem doesnt seem have binaries/scripts named mkdevices and mkrootdev, but these are getting executed somewhere down the line. Does anyone know where these 'come from'? kernel built in?!

Here's my linuxrc
Code:
#!/bin/nash

echo "Loading xor module"
insmod /lib/xor.o
echo "Loading raid5 module"
insmod /lib/raid5.o
echo "Loading jbd module"
insmod /lib/jbd.o
echo "Loading ext3 module"
insmod /lib/ext3.o
echo Mounting /proc filesystem
mount -t proc /proc /proc
raidautorun /dev/md0
echo Creating block devices
mkdevices /dev
echo Creating root device
mkrootdev /dev/root
echo 0x0100 > /proc/sys/kernel/real-root-dev
echo Mounting root filesystem
mount -o defaults --ro -t ext3 /dev/root /sysroot
pivot_root /sysroot /sysroot/initrd
umount /initrd/proc
and here are all the files in this filesystem
(output from find mountpoint -name '*' | xargs ls -l)
Code:
-rwxr-xr-x    1 root     root        92524 Dec 19 00:26 ./bin/insmod
lrwxrwxrwx    1 root     root           10 Dec 19 00:26 ./bin/modprobe -> /sbin/nash
-rwxr-xr-x    1 root     root        29544 Dec 19 00:26 ./bin/nash
crw-r--r--    1 root     root       5,   1 Dec 19 00:26 ./dev/console
brw-rw----    1 root     disk       9,   0 Nov 30 16:34 ./dev/md0
crw-r--r--    1 root     root       1,   3 Dec 19 00:26 ./dev/null
brw-r--r--    1 root     root       1,   1 Dec 19 00:26 ./dev/ram
crw-r--r--    1 root     root       4,   0 Dec 19 00:26 ./dev/systty
crw-r--r--    1 root     root       4,   1 Dec 19 00:26 ./dev/tty1
crw-r--r--    1 root     root       4,   2 Dec 19 00:26 ./dev/tty2
crw-r--r--    1 root     root       4,   3 Dec 19 00:26 ./dev/tty3
crw-r--r--    1 root     root       4,   4 Dec 19 00:26 ./dev/tty4
-rw-r--r--    1 root     root        88435 Dec 18 14:42 ./lib/ext3.o
-rw-r--r--    1 root     root        66996 Dec 18 14:42 ./lib/jbd.o
-rw-r--r--    1 root     root        23460 Dec 18 14:42 ./lib/raid5.o
-rw-r--r--    1 root     root        11548 Dec 18 14:42 ./lib/xor.o
-rwxr-xr-x    1 root     root          547 Dec 19 00:26 ./linuxrc
lrwxrwxrwx    1 root     root            3 Dec 19 00:26 ./sbin -> bin

Last edited by nxny; 02-28-2003 at 05:23 PM.
 
Old 03-02-2003, 12:49 AM   #2
nxny
Member
 
Registered: May 2002
Location: AK - The last frontier.
Distribution: Red Hat 8.0, Slackware 8.1, Knoppix 3.7, Lunar 1.3, Sorcerer
Posts: 771

Original Poster
Rep: Reputation: 30
*BUMP*
 
Old 03-02-2003, 03:32 AM   #3
rch
Member
 
Registered: Feb 2003
Location: Santa Clara,CA
Distribution: Mandriva
Posts: 909

Rep: Reputation: 48
Re: Dissecting linuxrc ( initrd )

Quote:
Originally posted by nxny
Guys,

I unzipped my initrd and mounted it as a loopback filesystem, so I could pull it apart and see what's going on inside. The the filesystem doesnt seem have binaries/scripts named mkdevices and mkrootdev, but these are getting executed somewhere down the line. Does anyone know where these 'come from'? kernel built in?!

Here's my linuxrc
Code:
#!/bin/nash

echo "Loading xor module"
insmod /lib/xor.o
echo "Loading raid5 module"
insmod /lib/raid5.o
echo "Loading jbd module"
insmod /lib/jbd.o
echo "Loading ext3 module"
insmod /lib/ext3.o
echo Mounting /proc filesystem
mount -t proc /proc /proc
raidautorun /dev/md0
echo Creating block devices
mkdevices /dev
echo Creating root device
mkrootdev /dev/root
echo 0x0100 > /proc/sys/kernel/real-root-dev
echo Mounting root filesystem
mount -o defaults --ro -t ext3 /dev/root /sysroot
pivot_root /sysroot /sysroot/initrd
umount /initrd/proc
and here are all the files in this filesystem
(output from find mountpoint -name '*' | xargs ls -l)
Code:
-rwxr-xr-x    1 root     root        92524 Dec 19 00:26 ./bin/insmod
lrwxrwxrwx    1 root     root           10 Dec 19 00:26 ./bin/modprobe -> /sbin/nash
-rwxr-xr-x    1 root     root        29544 Dec 19 00:26 ./bin/nash
crw-r--r--    1 root     root       5,   1 Dec 19 00:26 ./dev/console
brw-rw----    1 root     disk       9,   0 Nov 30 16:34 ./dev/md0
crw-r--r--    1 root     root       1,   3 Dec 19 00:26 ./dev/null
brw-r--r--    1 root     root       1,   1 Dec 19 00:26 ./dev/ram
crw-r--r--    1 root     root       4,   0 Dec 19 00:26 ./dev/systty
crw-r--r--    1 root     root       4,   1 Dec 19 00:26 ./dev/tty1
crw-r--r--    1 root     root       4,   2 Dec 19 00:26 ./dev/tty2
crw-r--r--    1 root     root       4,   3 Dec 19 00:26 ./dev/tty3
crw-r--r--    1 root     root       4,   4 Dec 19 00:26 ./dev/tty4
-rw-r--r--    1 root     root        88435 Dec 18 14:42 ./lib/ext3.o
-rw-r--r--    1 root     root        66996 Dec 18 14:42 ./lib/jbd.o
-rw-r--r--    1 root     root        23460 Dec 18 14:42 ./lib/raid5.o
-rw-r--r--    1 root     root        11548 Dec 18 14:42 ./lib/xor.o
-rwxr-xr-x    1 root     root          547 Dec 19 00:26 ./linuxrc
lrwxrwxrwx    1 root     root            3 Dec 19 00:26 ./sbin -> bin
actually the devices are created on your initrd as they are created
by mknod
read the initrd.txt file in the kernel source
if you want to create your own initrd
the steps are given there
don't forget the use of the ram disk!
to check your initrd
chroot it
keep posted
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
linuxrc:please help in editing bongski55 Red Hat 3 06-11-2009 05:29 AM
linuxrc problem? cstovall Linux - Software 0 11-08-2005 07:22 PM
when linuxrc will get crash? alwar Linux - Software 0 01-19-2005 11:56 PM
GENTOO - "init=/linuxrc" (/linuxrc: not found | kernel panic!!) halo14 Linux - Distributions 6 01-14-2005 01:03 PM
Setting up an initrd, having probs with /linuxrc jtX Linux - Newbie 1 12-03-2003 09:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:14 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