lfs-uefi: fix efivar-37 FTBFS
[linux_from_scratch_hints.git] / modular-build.txt
blob4f7d772f23a997f23ef12f49b7743bfff5faeece
1 AUTHOR:         Jim Gifford <lfs-hints at jg555.com>
2                 
3 DATE:           2004-05-18
5 LICENSE:        GNU Free Documentation License Version 1.2
7 SYNOPSIS:       Guide for a Modular Kernel
9 DESCRIPTION:    This hint will provide information to assist in the
10                 use of a modular kernel. This is a guide, not detailed
11                 information on how to build a kernel.
13 PREREQUISITES:  NONE
15 HINT:
17 INTRODUCTION:
19         In this hint we will explain how to use modules with LFS. This is 
20         not a requirement. The information here is used as an example, since every
21         LFS build is specific to the equipment that it's built on. 
22         
23         If you are not sure of what modules to load, you may not
24         want to use the information that is listed in this appendix. If this is your
25         first LFS build, it is recommended to use a a monolithic kernel. Read this
26         entire appendix before attempting a modular build.
28 REQUIREMENTS:
30         This section will explain how to properly setup the 2.6 Kernel
31         for module support.
33         Kernel Requirements for Modules
35         To use modules with the kernel it is recommended that you compile in
36         the following options. Listed are the minimal requirements only.
38         First select 
39                         Loadable module support  --->
40                         Check [*] Enable loadable module support
42         This will allow you to compile system components as modules. 
44         Caveats
46         Not everything in the kernel can be compiled as a module, to
47         verify that a particular option can be compiled as a module look for
48         < > brackets before a kernel component.
50         Even if the component compiles as a module, your particular setup
51         may not work properly with modules. A good example of this would be an
52         initrd. You can compile <M> RAM disk support as a module, but you would
53         lose the initrd functionality since initrd depends on ramfs, and since
54         ramfs is a module, your initrd functionality is no longer available. 
56         Another example of this is Frame Buffer Console devices, if you want
57         them available at boot-up, you need to compile them into the kernel and not as
58         modules. The list goes on, but most of the time it is trial and error to figure
59         out why a modular system doesn't work.
61         Check [*] Enable loadable module support
63         After selecting the above option, you will now be able to create 
64         loadable modules on your LFS system. This also adds more build steps to
65         your final kernel build.
67         Since you have selected loadable module support, you will need at adjust
68         your build of the kernel by adding the next two commands to the build process
69         after make bzImage you will need to issue the following commands.
71         make modules
72         make modules_install
74         Check <userinput>[*]   Automatic kernel module loading
76         After selection these options your kernel will support modules and the
77         autoloading of modules via the modprobe command.
79 MODPROBE:
81         In this section we will explain how to use setup a proper
82         modprobe.conf file for use with LFS.
84         Basic Configuration
86         The modprobe.conf file follows the devices structure layout that is
87         included with the kernel. Check your linux-{linux-version}/Documentation/devices.txt
88         for information. That file is you guide on how to configure
89         modprobe.conf. WARNING - This may be overwhelming to the novice user
90         and directions need to be followed exactly for everything to work
91         properly.
93         I will give you an example using the floppy drive. Each floppy drive
94         has a major # and a minor number. But each floppy drive uses the same
95         driver named floppy. So we can look into devices.txt file and we
96         will find that the major # for a floppy drive is 2, and that it is
97         a block device. In our modprobe.conf file we would specify the
98         following:
100         alias block-major-2 floppy
102         Advanced Configuration
104         If you have more than one SCSI interface the same rules do apply, 
105         but with a slight variance. Say we have a mega-raid controller and a aic7xxx
106         device. We want the mega-raid adapter to be the first one loaded, and the
107         aic7xx the next device. We would search are devices.txt and figure out
108         what the first SCSI drive major and minor # is. In this example the major
109         is 8 and the minor is 1. Remember before a SCSI disk can be used, the
110         sd_mod driver needs to be loaded first. Now depending the # of 
111         drives you have on your mega-raid controller, you will need to
112         figure out what the first drive is going to be for your aic7xxx
113         controller. Remember to check you devices.txt and figure out
114         what is the interval between drives, for SCSI drives it is 16.
115         You will need to add take the # of drives available on your mega-raid
116         controller, which we will use 3 and multiply that by 16, which would give
117         you 48. So the next controllers drive would start out 64, the next logical
118         value. To accomplish this, you will need to specify the following
119         in your modprobe.conf:
121         alias block-major-8 sd_mod
122         alias block-major-8-1 megaraid
123         alias block-major-8-48 aic7xxx
125 MODPROBE.CONF:
127         In this section we will give you an working example of a proper
128         modprobe.conf file for use with LFS. </para>
130         Sample modprobe.conf
132         Below is an example modprobe.conf file. You will need to edit
133         this file and replace the values that are in brackets with the unique
134         values from your system.
136         Create the /etc/modprobe.conf file by running the following
137         command:
139         cat > /etc/modprobe.conf << "EOF"
141         # Binary Format
142         alias binfmt-0000 binfmt_misc
144         # Block Major
145         alias block-major-1 rd
146         alias block-major-2 floppy
147         alias block-major-7 loop
148         alias block-major-8 sd_mod
149         alias block-major-8-1 [scsi module for /dev/sda]
150         alias block-major-8-16 [scsi module for /dev/sdb]
151         alias block-major-8-32 [scsi module for /dev/sdc]
152         alias block-major-11 sr_mod
153         alias block-major-11-0 [scsi module for /dev/sr0]
154         alias block-major-11-1 [scsi module for /dev/sr1]
156         # Character Major
157         alias char-major-3 ide-core
158         alias char-major-4 serial_core
159         alias char-major-5 serial_core
160         alias char-major-4-64 8250
161         alias char-major-4-65 8250
162         alias char-major-5-64 8250
163         alias char-major-5-65 8250
164         alias char-major-6 lp
165         alias char-major-9 st
166         alias char-major-9-1 [scsi module for /dev/st0]
167         alias char-major-10 misc
168         alias char-major-10-1 psaux
169         alias char-major-10-130 softdog
170         alias char-major-10-135 rtc
171         alias char-major-10-144 nvram
172         alias char-major-10-184 microcode
173         alias char-major-13 input
174         alias char-major-13-32 mousedev
175         alias char-major-21 sg
176         alias char-major-22 ide-core
177         alias char-major-33 ide-core
178         alias char-major-34 ide-core
179         alias char-major-37 ide-tape
180         alias char-major-56 ide-core
181         alias char-major-57 ide-core
182         alias char-major-108 ppp_generic
183         alias char-major-188 usbserial
184         
185         # Net PF
186         alias net-pf-1 unix
187         alias net-pf-2 ipv4
188         alias net-pf-10 off
189         alias net-pf-17 af_packet
190         
191         # Aliases
192         alias dos msdos
193         alias dummy0 dummy
194         alias dummy1 dummy
195         alias iso9660 isofs
196         alias parport_lowlevel parport_pc
197         
198         # Network Devices
199         alias eth0 [network module for eth0]
200         alias eth1 [network module for eth1]
201         alias ppp0 ppp
202         alias ppp-compress-18 ppp_mppe
203         alias ppp-compress-21 bsd_comp
204         alias ppp-compress-24 ppp_deflate
205         alias ppp-compress-26 ppp_deflate
206         alias tty-ldisc-3 ppp_async
207         alias tty-ldisc-14 ppp_synctty
208         
209         # SCSI Devices
210         alias scsi_hostadapter [first scsi device module]
211         alias scsi_hostadapter1 [second scsi device module]
213         # USB Devices
214         alias usbdevfs usbcore
215         alias usb-controller [module for first usb controller]
216         alias usb-controller1 [module for second usb controller]
217         alias char-major-81 videodev
218         
220         # Video Devices
221         alias fb0 [module for framebuffer]
223         # Character Sets
224         alias charCE nls_iso8859_1
225         alias codeUS nls_cp437
226         alias codeUTF nls_utf8
227         EOF
229         How to update modprobe.conf
231         If you need to add more devices to the modprobe.conf you will
232         need to use information from the help screen of the module and from the
233         devices.txt file that is the Documentation directory of the kernel source.
234         Below is sample data from devices.txt and how to use it in modprobe.conf
236         From devices.txt
237                 8 block       SCSI disk devices (0-15)
238                               0 = /dev/sda          First SCSI disk whole disk
239                              16 = /dev/sdb          Second SCSI disk whole disk
240                              32 = /dev/sdc          Third SCSI disk whole disk
241                              ...
242                              240 = /dev/sdp          Sixteenth SCSI disk whole disk
244                      Partitions are handled in the same way as for IDE
245                      disks (see major number 3) except that the limit on
246                      partitions is 15.
247         
248         You will need to extract the need information from above. Let's say we
249         have a /dev/sdp which is connected to aic7xxx controller. To add it to our existing
250         modprobe.conf. We would need to know the major number, in this case is block 8
251         and the minor number, in this case is 240. Now to add it to our modprobe.conf
252         file, we would add the following:
254         alias block-major-8-240 [scsi module for /dev/sdp]
256 INITRD:
258         This is not recommended if you have never built a LFS system
259         before. If you attempt this, it is at your own risk. Deviating from the book may
260         result in a non-working LFS build.
262         If you are going to make a fully modular kernel, you will need to create an initrd
263         to boot your system. You can get full instructions be following the detailed
264         instructions listed in linux-{linux-version}/Documentation/initrd.txt.
266         You can also follow the information listed in the initrd hint located at
267         http://www.linuxfromscratch.org/hints/downloads/files/initrd.txt
269 VERSION:        1.0
271 CHANGELOG:      1.0 Initial Release
273  New Version of this document can be viewed from http://cvs.jg555.com/viewcvs.cgi/lfs-hints