1 AUTHOR: Jim Gifford <lfs-hints at jg555.com>
5 LICENSE: GNU Free Documentation License Version 1.2
7 SYNOPSIS: initrd for LFS
9 DESCRIPTION: This hint will assist you in creating a initrd
12 PREREQUISITES: SCSI and USB Modules must be in modules.conf
13 Linux 2.4/2.6 built with modules.
14 Ram disk support compiled in
16 Root Filesystem must be compiled in
20 Introduction to Initial RAMDisk
22 This hint will help you configure an LFS system for Initial RAMDisk.
23 Which will allow you to add modules at start-up instead of compiling them
26 The script will auto-detect all SCSI, IDE and USB modules and add them
27 to the initial ramdisk. It will also detect the root from the fstab file
29 The above items, upon research are best if configured into the kernel.
30 You can look at the help of each of the items for more information.
33 Assumptions Made in this document
35 I have made the following assumptions in this document.
36 Files have been downloaded.
39 Kernel Configuration for 2.4
41 You will need to make sure the following items are configured
42 in your kernel. With out these, the initrd will not work
46 <M> Loopback device support (or <*>)
48 (4096) Default RAM disk size
49 [*] Initial RAM disk (initrd) support
51 The root and initrd file systems must be compiled into the kernel.
54 Kernel Configuration for 2.6
56 You will need to make sure the following items are configured
57 in your kernel. With out these, the initrd will not work
62 <M> Loopback device support (or <*>)
64 (4096) Default RAM disk size
65 [*] Initial RAM disk (initrd) support
67 The root and initrd file systems must be compiled into the kernel.
72 The new script has 3 choices of file systems.
73 ext2, ext3, and cramfs.
75 ext2 and ext3 are the most common file systems
76 in use, but the initrd is usually bigger.
77 My initrd with ext3 was only 412k. Compressed with
87 http://busybox.net/downloads/busybox-1.00-pre10.tar.bz2
92 Busybox has changed the way the configure the shell. It now
93 uses a menu driven option very similar to make menuconfig
96 Here is the list of the options needed. Anything else
97 will add to the size of your initrd.
99 General Configuration --->
100 [*] Support for devfs
101 NOTE - only if you using devfs
103 [*] Build BusyBox as a static binary (no shared libs)
105 [*] echo (basic SUSv3 version taking no options
106 Linux Module Utilities --->
108 [*] Support version 2.1.x to 2.4.x Linux kernels
109 NOTE - only if your using a 2.4 kernel
110 [*] Support version 2.6.x Linux kernels
111 NOTE - only if your using a 2.6 kernel
112 Another Bourne-like Shell --->
113 [*] Optimize for size instead of speed
114 [*] Enable alias support
116 Linux System Utilities --->
120 The build size on my system was 502k, considerably smaller than
123 After running make menuconfig you will need to run the
127 cp busybox /bin/busybox.static
132 For those who do not want to type out the script. It is
133 available on my CVS server at
134 http://svn.jg555.com/viewcvs.cgi/*checkout*/system/mkinitrd?rev=1&root=scripts
136 This script will create the initial RAM Disk image file.
137 By default this script creates /boot/initrd-{kernelversion}.img
139 I have sent a mkinitrd file to be placed
140 in the hints attachments at
141 http://www.linuxfromscratch.org/hints/downloads/attachments.
143 The default location for this file is /sbin
145 There are options on the new script, it will not just create
146 a initrd anymore. The kernel_version= is the only mandatory
149 Options are the following:
152 kernel_version={version} = use kernel version
155 -ide = remove ide modules [-scsi = remove scsi modules]
156 -usb = remove usb modules [-cdrom = remove cdrom modules]
157 -ide-scsi = remove ide-scsi modules
158 -devfs = remove devfs settings from initrd
159 initrdfs={ext2|ext3} = use either ext2 or ext3
160 -module={module} = remove module
161 +module={module} - add module
162 root-device={device} - skips auto detection of the root device
163 order={scsi,ide,usb,added} - sets the order of modules to be loaded
168 The following script needs to placed in /etc/rc.d/init.d.
170 You will then need to link it to rcsysinit.d.
172 It is recommended that this script be run right after
175 To link the script change to the /etc/rc.d/rcsysinit.d
176 directory and issue the following command.
178 ln -sf ../init.d/initrd S41initrd
181 # Begin $rc_base/init.d/initrd
183 # Based on sysklogd script from LFS-3.1 and earlier.
184 # Rewritten by Gerard Beekmans - gerard@linuxfromscratch.org
186 source /etc/sysconfig/rc
191 if [ -e /initrd/dev/.devfsd ]
196 if [ -e /initrd/proc ]
201 if [ -e /initrd/sys ]
206 if [ -e /initrd/linuxrc ]
209 echo "Clearing Initial RAM Disk..."
210 blockdev --flushbufs /dev/ram0
215 echo "Usage: $0 {start}"
220 # End $rc_base/init.d/initrd
225 In order to use the initrd.img file is to add the
226 following entry to you lilo.conf file.
228 initrd=/boot/initrd.img
230 So your lilo.conf should look something like this.
232 image=/boot/vmlinuz-2.4.23
234 initrd=/boot/initrd-2.4.23.img
237 If you are just testing. You should make a separate
238 entry in lilo.conf. This will still allow you to boot.
243 In order to use the initrd.img file is to add the
244 following entry to you menu.lst file.
246 initrd /boot/initrd-2.4.23.img
248 So your menu.lst should look something like this.
251 kernel (hd0,1)/boot/vmlinuz-2.4.23
252 initrd (hd0,1)/boot/initrd-2.4.23.img
257 In order to use the initrd.img file is to add the
258 following to syslinux.cfg file.
260 append initrd=initrd-2.4.23.img
262 So your syslinux.cfg should look something like this.
266 append initrd=initrd.img
272 CHANGELOG: 2.11 Forgot to update the mkinitrd svn information
273 2.10 Version Updates and CVS to SVN Information
275 2.8 Updated initrd script and mkinitrd
276 2.7 Updated Configurations
277 2.6 More 2.6 Updates -- removed romfs
278 2.5 Updated for 2.6 Kernel
279 2.4 Added a choice of the Change_Root Method
280 and the pivot_root method.
283 2.1 Forget at add genromfs build information
284 2.0 Did more Research - Found easier way to
285 do things and smaller.
286 1.5 Update CVS Information
287 1.4 Updated to New Hint Format
293 New Version of this document can be viewed from http://svn.jg555.com/viewcvs.cgi/?root=lfs-hints