PDA

View Full Version : How to compile the kernel in 1 minute


fender0107401
August 8th, 2009, 16:08
On my old computer(cpu=pd915) the compilation time is about 70s.

On my new computer(cpu=amd athlon 5200) the compilation time is about 40s.

This trick is very simple. :e

First and the following line to your make.conf.


NO_MODULES=true


It will prevent the system compile the module that I do not need(for details please man make.conf).

If I need something, I always add it to the kernel directly.

Second install the ccache.

Now compile the kernel, and when you recompile it you will be surprised.

Warning: If you compile the kernel in this way , you will DO NOT compile any modules, so you will have only one kernel in the /boot/kernel directory! This means you can't kldload anything!

% ls /boot/kernel
kernel
% du -h /boot/kernel
5.2M /boot/kernel

dennylin93
August 9th, 2009, 03:27
Another option is to set MODULES_OVERRIDE in /etc/make.conf to decide which modules should be compiled.

vermaden
August 9th, 2009, 14:29
Other things you can do to reduce both buildkernel and buildworld time :
1. Add WITHOUT_* options to src.conf(5) to reduce base system components.
2. Mount /usr/obj on mdmfs(8) disk in RAM (1GB should do).
3. Copy /usr/src to mdmfs(5) disk in RAM.
4. Use make -j X buildkernel for multicore CPUs, set 2 for single core, 4 for dual core, 8 for quad core and so, I have best results with these values.

zeiz
August 12th, 2009, 22:27
fender0107401 wrote:
If I need something, I always add it to the kernel directly.

HOW?!!!

Otherwise there are 600 modules in /boot/kernel. Module names aren't always comprehensive.
Perhaps I need only 20 modules but how to recognize them among those 600?
Is there any description of the modules around here?

xiaoj
August 13th, 2009, 02:04
Another option is to set MODULES_OVERRIDE in /etc/make.conf to decide which modules should be compiled.

how to know the the exact name of mudules in MODULES_OVERRIDE line?

1. Add WITHOUT_* options to src.conf(5) to reduce base system components.

is src.conf in /etc directory?
as to WITHOUT_* how to know the exact value about "*"

zeiz
August 13th, 2009, 02:50
Thanks. I read the handbook and the mans.
It's anyway hundreds of entries to make.conf...unless I know what I want to OVERRIDE.

I am about how to tune a kernel so that no modules would be required.
Or at least to get a "translation" of all the modules' names to be able to decide what could be removed.

I know my h/w and I know that I don't have raid, scsi, wireless, bluetooth and other fancy stuff. Only 2 sound cards, only 1 video...etc.

I just built custom kernel using src.conf but anyway I got hundreds of modules and now I'm trying to move what I think useless to tmp-dir and then see what happened:)

PS. I found not all but many "transalations" in /boot/defaults/loader.conf !

dennylin93
August 13th, 2009, 03:30
how to know the the exact name of mudules in MODULES_OVERRIDE line?

is src.conf in /etc directory?
as to WITHOUT_* how to know the exact value about "*"

The easiest way to tell which modules you use is probably kldstat. The command lists all the modules that are loaded. ls /boot/kernel/ | grep "ko" will show a complete list of modules you have built.

zeiz
August 13th, 2009, 04:57
kldstat doesn't show for instance usb, usb_quirk but if I remove usb_quirk.ko I cannot mount flash-drive.

graudeejs
August 13th, 2009, 06:02
kldstat doesn't show for instance usb, usb_quirk but if I remove usb_quirk.ko I cannot mount flash-drive.

did you try kldstat -v

xiaoj
August 13th, 2009, 10:40
how to know the the exact name of mudules in MODULES_OVERRIDE line?

is src.conf in /etc directory?
as to WITHOUT_* how to know the exact value about "*"


sorry for my pool english.

what i mean is that how to write MODULES_OVERRIDE line in /etc/make.conf, how to write the exact module name followed MODULES_OVERRIDE, where to refer the module names.

for instance:
MODULES_OVERRIDE=AAA,BBB,CCC
how to write the AAA,BBB,CCC, there are too many modules, i can not know all the name. where to refer the module names.

the question about WITHOUT_* is the same meaning.

may be an example can solve the problem, but i don't know.
Thanks.

graudeejs
August 13th, 2009, 10:45
run

$ ls /boot/kernel/*.ko | xargs basename -s .ko | less


probably most (if not all) of these can be set WITHOUT_*

xiaoj
August 13th, 2009, 10:51
# ls /boot/kernel/*.ko | sed s/.ko$// | xargs basename
Illegal variable name.


it does not work.

graudeejs
August 13th, 2009, 10:56
It does work

what shell are you using? try sh

EDIT:
yup, on csh it doesn't work, but on sh it does. That's why I use shells/mksh as my default shell it's 100% sh compatible + features

btw I edit last post after you already read it

xiaoj
August 13th, 2009, 10:59
i am using tcsh

vermaden
August 13th, 2009, 12:13
is src.conf in /etc directory?
as to WITHOUT_* how to know the exact value about "*"

In /etc/src.conf file.
Check man src.conf for details.

zeiz
August 13th, 2009, 16:44
Originally Posted by killasmurf86
did you try $ kldstat -v

well...no:r Thanks a lot.
If I'm not mistaken all the modules required are already included in kernel (and usb!). Only the few modules are to build?
If yes then _OVERRIDE... makes sense.

So, in my case I may want to add to make.conf:
NO_MODULES=true
MODULES_OVERRIDE=sound/sound sound/driver/emu10k1 ext2fs ntfs zfs zlib
and that's it? Is this right format btw, that's what xioaj seems is asking?
Or just
MODULES_OVERRIDE=sound/sound sound/driver/emu10k1 ext2fs ntfs zfs zlib?




# kldstat -v
Id Refs Address Size Name
1 9 0xc0400000 630f08 kernel (/boot/kernel/kernel)
Contains modules:
Id Name
182 freebsd7_msgctl
190 semsys
189 freebsd7___semctl
183 msgsys
188 msgctl
187 msgget
201 shmsys
200 freebsd7_shmctl
199 shmat
198 shmctl
197 shmdt
196 shmget
186 msgsnd
185 msgrcv
194 __semctl
193 semget
192 semop
206 loop
177 elf32
178 shell
162 pseudofs
208 igmp
205 if_gif
207 if_tun
204 if_faith
147 uether
184 sysvmsg
202 sem
191 sysvsem
195 sysvshm
209 ufs
160 msdosfs
176 cd9660
159 devfs
161 procfs
40 ata
5 cam
169 g_part_ebr
168 g_part_bsd
9 cd
14 sa
13 pass
8 probe
11 ada
7 aprobe
12 da
10 ch
6 xpt
15 ses
171 g_part_mbr
170 g_part_gpt
55 pci/ata_ite
54 pci/ata_intel
53 pci/ata_highpoint
52 pci/ata_cyrix
143 uhub/usb_linux
142 uhub/umass
51 pci/ata_cypress
141 ohci/usbus
140 uhci/usbus
139 ehci/usbus
138 at91_udp/usbus
137 uss820/usbus
136 pci/uhci
135 pci/ohci
134 pci/ehci
50 pci/ata_cenatek
133 pci/uart
132 isa/uart
131 acpi/uart
49 pci/ata_ati
48 pci/ata_amd
130 random
129 pci/ppc
128 isa/ppc
269 isa/vga
127 acpi/ppc
268 isa/sc
267 isa/atrtc
266 acpi/atrtc
126 ppbus/ppi
47 pci/ata_adaptec
125 ppc/ppbus
265 legacy/pir
124 ppbus/lpt
46 pci/ata_ali
264 legacy/pcib
263 isa/pcibus_pnp
262 pci/pcibios_pcib
261 isa/pmtimer
260 nexus/npx
259 isa/npxisa
258 acpi/npxisa
257 isa/atdma
256 acpi/atdma
255 legacy/isa
123 ppbus/plip
254 isa/attimer
253 acpi/attimer
122 pci/vgapci
252 isa/atpic
251 acpi/atpic
121 pci/pcib
120 pcib/pci
45 pci/ata_acard
250 root/nexus
249 nexus/ram
248 isa/sysresource
44 pci/ata_ahci
247 legacy/mptable_pcib
246 pci/mptable_pcib
23 acpi/acpi_isab
43 pci/atapci
42 atapci/ata
41 isa/ata
29 cpu/acpi_perf
119 pci/isab
118 pci/ignore_pci
117 pci/hostb
116 pci/fixup_pci
115 pci/eisab
114 null
113 miibus/xmphy
112 miibus/ukphy
111 miibus/truephy
245 nexus/legacy
244 legacy/cpu
110 miibus/tlphy
109 miibus/tdkphy
108 miibus/smcphy
243 pci/ioapic
242 nexus/apic
107 miibus/ruephy
106 miibus/rlphy
105 miibus/rgephy
104 miibus/qsphy
103 miibus/pnaphy
102 miibus/nsphyter
101 miibus/nsphy
100 miibus/nsgphy
241 isa/pnpbios
240 cpu/smist
239 cpu/powernow
238 cpu/p4tcc
237 cpu/hwpstate
99 miibus/mlphy
236 cpu/est
98 miibus/lxtphy
97 miibus/jmphy
96 miibus/ip1000phy
95 miibus/inphy
94 miibus/icsphy
93 miibus/gentbi
92 miibus/xlphy
235 root/nexus_acpi
234 scrndr-vga
233 scterm-scteken
91 miibus/e1000phy
90 miibus/ciphy
89 miibus/brgphy
232 pci/nfe
231 nfe/miibus
230 io
229 isa/fdc
228 acpi/fdc
227 fdc/fd
88 miibus/bmtphy
87 miibus/axphy
86 miibus/atphy
226 atkbdc/psm
225 isa/psmcpnp
224 acpi/psmcpnp
85 miibus/amphy
223 isa/atkbdc
222 acpi/atkbdc
221 atkbdc/atkbd
220 isa/aic
219 hostb/agp_via
218 hostb/agp_sis
217 hostb/agp_nvidia
216 hostb/agp_intel
215 vgapci/agp_i810
214 hostb/agp_ati
213 hostb/agp_amd64
212 hostb/agp_amd
211 hostb/agp_ali
84 miibus/acphy
83 mem
179 cpu/cpufreq
18 acpi/acpi_button
28 pci/acpi_pcib
27 acpi/acpi_pcib
22 acpi/acpi_hpet
20 acpi/cpu
16 nexus/acpi
17 acpi/acpi_acad
39 ahc
38 pci/ahc_pci
37 isa/ahc_isa
36 eisa/ahc_eisa
35 isa/aha
81 firewire/sbp
80 pci/fwohci
26 acpi/acpi_pci_link
175 isa/pnp
174 isa/orm
34 acpi/acpi_timer
173 isab/isa
172 eisab/isa
33 cpu/acpi_throttle
32 acpi/acpi_tz
79 fwohci/firewire
19 acpi/acpi_cmbat
78 eisa/mainboard
77 eisab/eisa
76 legacy/eisa
75 pci/de
74 isa/cs
25 pcib/acpi_pci
31 acpi/acpi_smbat
73 cpu/ichss
72 pci/bt
71 isa/bt
70 eisa/bt
30 acpi/acpi_sysresource
69 ata/afd
21 acpi/acpi_ec
68 ata/acd
24 acpi/acpi_lid
67 ata/ad
66 pci/ata_via
65 pci/ata_sis
64 pci/ata_sii
63 pci/ata_serverworks
62 pci/ata_promise
61 pci/ata_nvidia
60 pci/ata_netcell
59 pci/ata_national
58 pci/ata_micron
158 pci/xl
157 xl/miibus
156 watchdog
57 pci/ata_marvell
155 uhub/ums
154 uhub/ukbd
153 uhub/uhid
56 pci/ata_jmicron
152 uhub/ulpt
151 uhub/uftdi
150 uhub/ubsa
149 uhub/uark
148 uhub/u3g
146 uhub/cdce
145 usbus/uhub
144 uhub/uhub
163 g_dev
167 g_part
82 g_md
166 g_label
180 rootbus
210 g_class
165 g_vfs
181 firmware
164 g_disk
203 ether
2 1 0xc0a31000 89d8 snd_emu10k1.ko (/boot/kernel/snd_emu10k1.ko)
Contains modules:
Id Name
4 pci/snd_emu10k1
3 pci/emujoy
3 3 0xc0a3a000 566c0 sound.ko (/boot/kernel/sound.ko)
Contains modules:
Id Name
2 midi
1 sound
4 1 0xc624d000 10000 ext2fs.ko (/boot/kernel/ext2fs.ko)
Contains modules:
Id Name
270 ext2fs
#

Originally Posted by vermaden
In /etc/src.conf file.
Check man src.conf for details.

I have WITHOUT_WIRELESS=yes for example in src.conf but all the wireless modules were built anyway. ?

dennylin93
August 14th, 2009, 05:50
There isn't an option called WITHOUT_WIRELESS in /etc/src.conf.

zeiz
August 14th, 2009, 06:42
man src.conf

WITHOUT_WIRELESS
Set to not build programs used for 802.11 wireless networks;
especially wpa_supplicant(8) and hostapd(8). When set, it also
enforces the following options:

dennylin93
August 14th, 2009, 11:00
Oh, that's on -CURRENT. I was using 7.2-RELEASE. No wonder the man page showed different results.

I don't think that the wireless modules were built though. You'd see stuff like wlan, wlan_wep, wlan_ccmp, etc if they were built.

zeiz
August 14th, 2009, 16:14
Thanks. I do see wlan, wlan_wep etc otherwise why I wrote the modules were buit?
I just tried NO_MODULES=yes option. No modules indeed were built but I have those loaded in kldstat -v :wlan, wlan_wep... also ata_raid that I all commented out in kernel config...
I have to open new thread about this.

UPDATE. My mistake: I forgot specify KERNCONG=CUSTOM and so built GENERIC without modules:)

john_doe
August 16th, 2009, 05:22
how to know the the exact name of mudules in MODULES_OVERRIDE line?Look into sys/modules directory, eg. if you want to build only green_saver.ko you specify syscons/green and buildkernel only descends into /usr/src/sys/modules/syscons/green.