Вы находитесь на странице: 1из 6

old.slackware.

ru

http://old.slackware.ru/article.ghtml?ID=654

slackware.ru : RAM
Written 1996,2000 by Werner Almesberger <werner.almesberger@epfl.ch> and Hans Lermen
<lermen@fgan.de>
initrd.txt
Linux. , ,
( initrd 1.3.73) .
, , Linux-
initrd (redhat'
, afaik, initrd ). , initrd

(., ,
,
.),
.
, ``''
Linux-.
, initrd
Linux,
. : Bootdisks-HOWTO,
lilo syslinux.
-Sincerely yours,
hunter
initrd RAM (boot loader).
RAM , (root filesystem)
. , ,
. , ( initrd)
.
initrd , , , ,
- , - initrd
.
initrd.
[1].
initrd, , :
1. RAM
2. initrd ``'' RAM , initrd
3. initrd
4. /linuxrc ( ,
. uid 0 ,
init)
5. linuxrc ``''
6. pivot_root, linuxrc

7. (.,
/sbin/init)
8. initrd

, . ,
initrd.
initrd :
initrd=<path>
(., LOADLIN) RAM .
LILO RAM /etc/lilo.conf
INITRD
noinitrd
initrd , RAM ,
``'' . initrd /dev/initrd. , ,
, initrd
. , , .
. /dev/initrd
. ,
/dev/initrd .
root=/dev/ram0
( devfs)
root=/dev/rd/0
( devfs) initrd ,
RAM .
-, initrd ``''
, .:
# mkdir /initrd
. (man page) pivot_root(2).
(.,
),
/initrd.
, initrd ,
( devfs):
# mknod /dev/initrd b 1 250
# chmod 400 /dev/initrd
-, RAM .
initrd (.,
).
-, RAM .
, ,
initrd.
:
(floppy) ( , )
RAM (, )
loopback ( )
, loopback :
1. , loopback
2. , .:
# dd if=/dev/zero of=initrd bs=300k count=1
# mke2fs -F -m0 -b 1024 initrd

( - , Minix Ext2)
. ,
1024 . ,
initrd , kernel panic.
3. , .:
# mount -t ext2 -o loop initrd /mnt
4. console ( devfs,
):
# mkdir /mnt/dev
# mknod /mnt/dev/console c 5 1
5. , initrd.
/linuxrc.
. /linuxrc ``x'' (execute)
6. initrd
:
# chroot /mnt /linuxrc
, initrd ,
(., ,
, -, .. ,
, pivot_root ).
7. :
# umount /mnt
8. initrd ``initrd''. , :
# gzip -9 initrd
initrd,
/linuxrc /bin/sh. ,
newlib [2] initrd .
, initrd. Linux
initrd. ,
:
root=/dev/ram0 init=/linuxrc rw
devfs, :
root=/dev/rd/0 init=/linuxrc rw
devfs. (rw initrd).
LOADLIN, :
LOADLIN <kernel> initrd=<disk_image>
.:
LOADLIN C:\LINUX\BZIMAGE initrd=C:\LINUX\INITRD.GZ root=/dev/ram0 init=/linuxrc rw
LILO, INITRD=<path> /etc/lilo.conf

APPEND, .:

image = /bzImage
initrd = /boot/initrd.gz
append = "root=/dev/ram0 init=/linuxrc rw"
/sbin/lilo .
, .
initrd.
, linuxrc Linux
``'' .
:


(initrd)
initrd RAM
:
- . :
# mkdir /new-root
# mount -o ro /dev/hda1 /new-root
pivot_root,
pivot_root (. pivot_root(8); pivot_root util-linux
2.10h [3]). pivot_root
, .
pivot_root. :
# cd /new-root
# mkdir initrd
# pivot_root . initrd
, linuxrc
, , standard input/output/error,
. :
# exec chroot . what-follows <dev/console >dev/console 2>&1
, what-follows - , ., /sbin/init .1
devfs /dev,
devfs chroot /dev/console.
. pivot_root .
, :
pivot_root

``.''

chroot
(chroot)

/dev/console exec
initrd RAM :
# umount /initrd
# blockdev -flushbufs /dev/ram0 # /dev/rd/0 if using devfs
initrd NFS, .
pivot_root(8).
. linuxrc -
, change_root (. ``
'')
initrd
. :
1. (.,
RAM , initrd, a.out ext2) initrd
2. /linuxrc : (a) ``''
(.. , , ) (b)
(., CD-ROM, , , ... ).
,
.
3. /linuxrc
4. /linuxrc (
)
5. /linuxrc pivot_root , chroot,

6.
7. initrd
(., /initrd ,
/dev/ram0 /dev/rd/0 )
8.
initrd
, ``''
.
, , Linux
.
( - ),
. ,
initrd . /linuxrc
.
,
,
, , initrd ,
(
).
, , , CD-ROM
initrd CD, .,
, initrd, RAM CD;
LOADLIN CD,
RAM CD .
pivot_root .
, , .

``'' (..
rdev root=... )
linuxrc. , initrd
, , , /initrd,
.
root, init rw. (
, , initrd.)
/proc , ``''
linuxrc /proc/sys/kernel/real-root-dev,
.:
# echo 0x301 >/proc/sys/kernel/real-root-dev
, NFS .
, , "change_root", ,
"pivot_root".
1
Almesberger, Werner; "Booting Linux: The History and the Future"
ftp://icaftp.epfl.ch/pub/people/almesber/booting/bootinglinux-current.ps.gz
2
newlib (experimental), initrd ftp://icaftp.epfl.ch/pub/people/almesber/misc/newliblinux/
3
Brouwer, Andries; "util-linux: Miscellaneous utilities for Linux" ftp://ftp.win.tue.nl/pub/linux-local/utils/utillinux/
Footnotes
...1
. . initrd
pivot_root(8). , .
/sbin/init ,
initrd .
hunter
2003-08-06