lfs-uefi: fix efivar-37 FTBFS
[linux_from_scratch_hints.git] / initrd.txt
blob419565b0b933c580bb868cbd12e2903c59963f16
1 AUTHOR:         Jim Gifford <lfs-hints at jg555.com>
3 DATE:           2004-06-20
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
10                 for your LFS system
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
15                         initrd selected
16                         Root Filesystem must be compiled in
17                 Busybox-1.00-pre10
18 HINT:
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
24 into the kernel.
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.
32 ---
33 Assumptions Made in this document
35         I have made the following assumptions in this document.
36         Files have been downloaded.
38 ---
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 
43         properly.
45         Block devices  --->
46                 <M> Loopback device support (or <*>)
47                 <*> RAM disk support
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.
53 ---
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 
58         properly.
60         Device Drivers  --->
61                 Block devices  --->
62                         <M> Loopback device support (or <*>)
63                         <*> RAM disk support
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.
68         
69 ---
70 File Systems
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
78         gzip -9
80 ---
81 Needed Programs
82         
83         busybox 1.00-pre10
84         ----
86         Download From
87         http://busybox.net/downloads/busybox-1.00-pre10.tar.bz2 
89         Information
90         http://busybox.net
91         
92         Busybox has changed the way the configure the shell. It now
93         uses a menu driven option very similar to make menuconfig
94         in linux.
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
102         Build Options  --->
103                 [*] Build BusyBox as a static binary (no shared libs)
104         Coreutils  --->
105                 [*] echo (basic SUSv3 version taking no options
106         Linux Module Utilities  ---> 
107                 [*] insmod
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
115                 (0) history size
116         Linux System Utilities  --->
117                 [*] pivot_root
118                 [*] mount
120         The build size on my system was 502k, considerably smaller than
121         bash.
123         After running make menuconfig you will need to run the
124         following commands.
126         make
127         cp busybox /bin/busybox.static
130 mkinitrd
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
135         
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. 
142         
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
147         option
149         Options are the following:
151         Required
152         kernel_version={version} = use kernel version
154         Optional
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
164                                                                                                         
166 initrd script
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
173         mountfs.
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
180         #!/bin/sh
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
187         source $rc_functions
189         case "$1" in
190                 start)
191                         if [ -e /initrd/dev/.devfsd ]
192                                 then
193                                         umount /initrd/dev
194                         fi
196                         if [ -e /initrd/proc ]
197                                 then
198                                         umount /initrd/proc
199                         fi
201                         if [ -e /initrd/sys ]
202                                 then
203                                         umount /initrd/sys
204                         fi
206                         if [ -e /initrd/linuxrc ]
207                                 then
208                                         umount /initrd
209                                         echo "Clearing Initial RAM Disk..."
210                                         blockdev --flushbufs /dev/ram0
211                                         evaluate_retval
212                         fi
213                         ;;
214                 *)
215                         echo "Usage: $0 {start}"
216                         exit 1
217                         ;;
218         esac
220 # End $rc_base/init.d/initrd
221                 
223 For Lilo
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
233         label=test
234         initrd=/boot/initrd-2.4.23.img
235         read-only
237         If you are just testing. You should make a separate
238         entry in lilo.conf. This will still allow you to boot.  
241 For Grub
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.
250         title test
251         kernel (hd0,1)/boot/vmlinuz-2.4.23
252         initrd (hd0,1)/boot/initrd-2.4.23.img
255 For Syslinux
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.
264         label test
265         kernel vmlinuz
266         append initrd=initrd.img
270 VERSION:        2.11
272 CHANGELOG:      2.11 Forgot to update the mkinitrd svn information
273                 2.10 Version Updates and CVS to SVN Information
274                 2.9 Fixes Typos
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.
281                 2.3 Fixed Typos
282                 2.2 Fixed Typos
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
288                 1.3 Updated Script
289                 1.2 Fixed Typos
290                 1.1 Updated Script
291                 1.0 Initial Version
293  New Version of this document can be viewed from http://svn.jg555.com/viewcvs.cgi/?root=lfs-hints