# A nice 2.6.6 kernel configuration that everyone can use

## nick_downing

Hi all,

I'm pretty chuffed at the moment because I've finally got my 2.6.6 kernel working.  It's based on development-sources, using a kernel-config-2.6 file provided by myself.  I have also hacked away on the genkernel script and data files to get everything just the way I like it.  I'll explain, please bear with me while I tell the story from the beginning:

My preferred setup is to have everything compiled as modules and then put any modules needed for booting, into an initrd.  This way you can support a lot of very different x86 machines, like some SCSI machines, some IDE, some 586, 686, laptops, desktops all with the same config file.  I have a lot of random machines so this is helpful.

However when I look at the configs that are normally supplied as standard (Gentoo, Red Hat and others) I can see that the principle of "everything as modules" has become somewhat corrupted.  For example we normally compile keyboard, serial port, parallel port and floppy disk support, into the kernel, without making them modules.

I decided I don't like this, because it's not generic enough.  So eventually I started looking into making a kernel where EVERYTHING is modules.  Some might say this is inconvenient, but I like the idea because it's more consistent and it avoids any tricky decisions at kernel config time.  I hate making value judgements and having to reconfigure later.

I opted for a 586 baseline, as I still have some old machines around that use K6-2 chips, et cetera.  In accordance with my philosophy I didn't include IDE support directly in the kernel, it's only modules.  I have a 586 where IDE is not used, only SCSI, so the idea is attractive to a purist like me.  This machine is now working nicely with no IDE drivers at all.

I've now rolled out the new kernel successfully to a great many different machines.  If you use the configuration supplied here, it should work on just about any desktop or notebook that you are likely to encounter (kind of like the LiveCD).  If you want to customize, you just rerun the "genkernel initrd" step, which is very fast, since no recompiling is needed.

I made a few small exceptions to the "modules only" rule.  For example I compiled in support for the PC keyboard as it was helpful in the development stage where the machine often failed to boot.  I also included an 8x16 font and SVGA support.  Note: The Gentoo splash screen is not working yet.. I wonder why?  Can someone help with this?

The kernel is very easy to use, in practice the only difference that the end-user is likely to notice, between this and a stock Gentoo kernel, is that you have to specify "doide" on the Grub / Lilo command line.  Otherwise the thing won't boot on a normal IDE-equipped PC.  You also have to fill out the "/etc/modules.autoload" file according to my example.

DETAILED INSTRUCTIONS FOR BUILDING THE KERNEL:

1.  Patch your /usr/src/linux/scripts/kconfig/conf.c as follows:

```
--- conf.c!   2004-06-16 15:24:05.000000000 +1000

+++ conf.c   2004-06-23 17:38:50.574919792 +1000

@@ -126,12 +126,17 @@

             break;

          }

       } else {

+#if 1 /* Nick */

+         printf("%s\n", def);

+         return;

+#else

          if (sym_tristate_within_range(sym, yes)) {

             line[0] = 'y';

             line[1] = '\n';

             line[2] = 0;

             break;

          }

+#endif

       }

    case set_no:

       if (sym_tristate_within_range(sym, no)) {

@@ -226,7 +231,14 @@

       if (sym->help)

          printf("/?");

       printf("] ");

+#if 1 /* Nick */

+      conf_askvalue(sym, (input_mode == set_mod && menu->list &&

+            sym_tristate_within_range(sym, yes)) ?

+            "y" : sym_get_string_value(sym));

+

+#else

       conf_askvalue(sym, sym_get_string_value(sym));

+#endif

       strip(line);

 

       switch (line[0]) {

@@ -249,7 +261,13 @@

             break;

          continue;

       case 0:

+#if 1 /* Nick */

+         newval = (input_mode == set_mod && menu->list &&

+            sym_tristate_within_range(sym, yes)) ?

+            yes : oldval;

+#else

          newval = oldval;

+#endif

          break;

       case '?':

          goto help;

```

This is a small enhancement to the "make allmodconfig" command, which seems a bit broken as shipped.  With this modification, any configuration questions that result in a submenu will be answered "y".  Thus, any questions inside will be asked, and answered with "m" for module if possible.  Otherwise defaults are used.

2.  Change to the kernel source directory and configure the kernel, like this:

```
cd /usr/src/linux

make allmodconfig

```

Note:  When you downloaded the kernel source you should also have done this:

```
cd /usr/src

rm linux

ln -s linux-2.6.6 linux

cd /usr/include

rm asm

ln -s /usr/src/linux/include/asm asm

rm asm-generic

ln -s /usr/src/linux/include/asm-generic asm-generic

rm linux

ln -s /usr/src/linux/include/linux linux

```

But you already knew that, right?   :Wink: 

3.  The resulting .config file must be patched as follows:  (This was derived experimentally)

```
--- .config   2004-06-24 04:04:59.376367032 +1000

+++ kernel-config   2004-06-24 04:04:53.126317184 +1000

@@ -17,15 +17,16 @@

 # General setup

 #

 CONFIG_SWAP=y

-# CONFIG_SYSVIPC is not set

+CONFIG_SYSVIPC=y

 # CONFIG_POSIX_MQUEUE is not set

 # CONFIG_BSD_PROCESS_ACCT is not set

-# CONFIG_SYSCTL is not set

+CONFIG_SYSCTL=y

 CONFIG_AUDIT=y

 # CONFIG_AUDITSYSCALL is not set

 CONFIG_LOG_BUF_SHIFT=15

 # CONFIG_HOTPLUG is not set

 CONFIG_IKCONFIG=y

+# CONFIG_IKCONFIG_PROC is not set

 CONFIG_EMBEDDED=y

 CONFIG_KALLSYMS=y

 CONFIG_FUTEX=y

@@ -61,10 +62,10 @@

 # CONFIG_X86_ES7000 is not set

 # CONFIG_M386 is not set

 # CONFIG_M486 is not set

-# CONFIG_M586 is not set

+CONFIG_M586=y

 # CONFIG_M586TSC is not set

 # CONFIG_M586MMX is not set

-CONFIG_M686=y

+# CONFIG_M686 is not set

 # CONFIG_MPENTIUMII is not set

 # CONFIG_MPENTIUMIII is not set

 # CONFIG_MPENTIUMM is not set

@@ -84,12 +85,12 @@

 CONFIG_X86_L1_CACHE_SHIFT=5

 CONFIG_RWSEM_XCHGADD_ALGORITHM=y

 CONFIG_X86_PPRO_FENCE=y

+CONFIG_X86_F00F_BUG=y

 CONFIG_X86_WP_WORKS_OK=y

 CONFIG_X86_INVLPG=y

 CONFIG_X86_BSWAP=y

 CONFIG_X86_POPAD_OK=y

-CONFIG_X86_GOOD_APIC=y

-CONFIG_X86_USE_PPRO_CHECKSUM=y

+CONFIG_X86_ALIGNMENT_16=y

 # CONFIG_HPET_TIMER is not set

 # CONFIG_HPET_EMULATE_RTC is not set

 CONFIG_SMP=y

@@ -97,7 +98,6 @@

 # CONFIG_PREEMPT is not set

 CONFIG_X86_LOCAL_APIC=y

 CONFIG_X86_IO_APIC=y

-CONFIG_X86_TSC=y

 CONFIG_X86_MCE=y

 CONFIG_X86_MCE_NONFATAL=m

 # CONFIG_X86_MCE_P4THERMAL is not set

@@ -136,6 +136,7 @@

 CONFIG_ACPI_BOOT=y

 CONFIG_ACPI_INTERPRETER=y

 CONFIG_ACPI_SLEEP=y

+CONFIG_ACPI_SLEEP_PROC_FS=y

 CONFIG_ACPI_AC=m

 CONFIG_ACPI_BATTERY=m

 CONFIG_ACPI_BUTTON=m

@@ -168,17 +169,20 @@

 # CPU Frequency scaling

 #

 CONFIG_CPU_FREQ=y

+CONFIG_CPU_FREQ_PROC_INTF=m

 CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y

 # CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set

 CONFIG_CPU_FREQ_GOV_PERFORMANCE=y

 CONFIG_CPU_FREQ_GOV_POWERSAVE=m

 CONFIG_CPU_FREQ_GOV_USERSPACE=m

+# CONFIG_CPU_FREQ_24_API is not set

 CONFIG_CPU_FREQ_TABLE=m

 

 #

 # CPUFreq processor drivers

 #

 CONFIG_X86_ACPI_CPUFREQ=m

+# CONFIG_X86_ACPI_CPUFREQ_PROC_INTF is not set

 CONFIG_X86_POWERNOW_K6=m

 CONFIG_X86_POWERNOW_K7=m

 CONFIG_X86_POWERNOW_K8=m

@@ -269,8 +273,8 @@

 # CONFIG_MTD_CFI_B1 is not set

 # CONFIG_MTD_CFI_B2 is not set

 # CONFIG_MTD_CFI_B4 is not set

-# CONFIG_MTD_CFI_B8 is not set

-# CONFIG_MTD_CFI_I1 is not set

+CONFIG_MTD_CFI_B8=y

+CONFIG_MTD_CFI_I1=y

 # CONFIG_MTD_CFI_I2 is not set

 # CONFIG_MTD_CFI_I4 is not set

 # CONFIG_MTD_CFI_I8 is not set

@@ -358,6 +362,7 @@

 #

 # CONFIG_ISAPNP is not set

 CONFIG_PNPBIOS=y

+# CONFIG_PNPBIOS_PROC_FS is not set

 

 #

 # Block devices

@@ -404,8 +409,9 @@

 CONFIG_BLK_DEV_CRYPTOLOOP=m

 CONFIG_BLK_DEV_NBD=m

 CONFIG_BLK_DEV_CARMEL=m

-CONFIG_BLK_DEV_RAM=m

-CONFIG_BLK_DEV_RAM_SIZE=4096

+CONFIG_BLK_DEV_RAM=y

+CONFIG_BLK_DEV_RAM_SIZE=8192

+CONFIG_BLK_DEV_INITRD=y

 # CONFIG_LBD is not set

 

 #

@@ -493,6 +499,7 @@

 # SCSI device support

 #

 CONFIG_SCSI=m

+CONFIG_SCSI_PROC_FS=y

 

 #

 # SCSI support type (disk, tape, CD-ROM)

@@ -700,7 +707,7 @@

 CONFIG_PACKET=m

 # CONFIG_PACKET_MMAP is not set

 CONFIG_NETLINK_DEV=m

-CONFIG_UNIX=m

+CONFIG_UNIX=y

 CONFIG_NET_KEY=m

 CONFIG_INET=y

 # CONFIG_IP_MULTICAST is not set

@@ -957,6 +964,7 @@

 #

 # Network testing

 #

+CONFIG_NET_PKTGEN=m

 CONFIG_NETPOLL=y

 # CONFIG_NETPOLL_RX is not set

 # CONFIG_NETPOLL_TRAP is not set

@@ -1478,6 +1486,12 @@

 # Active Eicon DIVA Server cards

 #

 CONFIG_CAPI_EICON=y

+CONFIG_ISDN_DIVAS=m

+# CONFIG_ISDN_DIVAS_BRIPCI is not set

+# CONFIG_ISDN_DIVAS_PRIPCI is not set

+CONFIG_ISDN_DIVAS_DIVACAPI=m

+CONFIG_ISDN_DIVAS_USERIDI=m

+CONFIG_ISDN_DIVAS_MAINT=m

 

 #

 # Telephony Support

@@ -1515,8 +1529,8 @@

 CONFIG_GAMEPORT_VORTEX=m

 CONFIG_GAMEPORT_FM801=m

 CONFIG_GAMEPORT_CS461x=m

-CONFIG_SERIO=m

-CONFIG_SERIO_I8042=m

+CONFIG_SERIO=y

+CONFIG_SERIO_I8042=y

 CONFIG_SERIO_SERPORT=m

 CONFIG_SERIO_CT82C710=m

 CONFIG_SERIO_PARKBD=m

@@ -1526,7 +1540,7 @@

 # Input Device Drivers

 #

 CONFIG_INPUT_KEYBOARD=y

-CONFIG_KEYBOARD_ATKBD=m

+CONFIG_KEYBOARD_ATKBD=y

 CONFIG_KEYBOARD_SUNKBD=m

 CONFIG_KEYBOARD_LKKBD=m

 CONFIG_KEYBOARD_XTKBD=m

@@ -1851,6 +1865,7 @@

 CONFIG_RADIO_TERRATEC=m

 CONFIG_RADIO_TRUST=m

 CONFIG_RADIO_TYPHOON=m

+# CONFIG_RADIO_TYPHOON_PROC_FS is not set

 CONFIG_RADIO_ZOLTRIX=m

 

 #

@@ -1959,11 +1974,11 @@

 CONFIG_VGA_CONSOLE=y

 CONFIG_MDA_CONSOLE=m

 CONFIG_DUMMY_CONSOLE=y

-CONFIG_FRAMEBUFFER_CONSOLE=m

+CONFIG_FRAMEBUFFER_CONSOLE=y

 CONFIG_PCI_CONSOLE=y

 CONFIG_FONTS=y

 # CONFIG_FONT_8x8 is not set

-# CONFIG_FONT_8x16 is not set

+CONFIG_FONT_8x16=y

 # CONFIG_FONT_6x11 is not set

 # CONFIG_FONT_PEARL_8x8 is not set

 # CONFIG_FONT_ACORN_8x8 is not set

@@ -2373,7 +2388,7 @@

 #

 # File systems

 #

-CONFIG_EXT2_FS=m

+CONFIG_EXT2_FS=y

 CONFIG_EXT2_FS_XATTR=y

 # CONFIG_EXT2_FS_POSIX_ACL is not set

 # CONFIG_EXT2_FS_SECURITY is not set

@@ -2383,7 +2398,7 @@

 # CONFIG_EXT3_FS_SECURITY is not set

 CONFIG_JBD=m

 # CONFIG_JBD_DEBUG is not set

-CONFIG_FS_MBCACHE=m

+CONFIG_FS_MBCACHE=y

 CONFIG_REISERFS_FS=m

 # CONFIG_REISERFS_CHECK is not set

 # CONFIG_REISERFS_PROC_INFO is not set

@@ -2427,7 +2442,7 @@

 #

 # Pseudo filesystems

 #

-# CONFIG_PROC_FS is not set

+CONFIG_PROC_FS=y

 CONFIG_PROC_KCORE=y

 CONFIG_SYSFS=y

 CONFIG_DEVFS_FS=y

@@ -2435,7 +2450,7 @@

 # CONFIG_DEVFS_DEBUG is not set

 CONFIG_DEVPTS_FS_XATTR=y

 # CONFIG_DEVPTS_FS_SECURITY is not set

-# CONFIG_TMPFS is not set

+CONFIG_TMPFS=y

 # CONFIG_HUGETLBFS is not set

 # CONFIG_HUGETLB_PAGE is not set

 CONFIG_RAMFS=y

```

This should in fact be simpler than it is, but unfortunately there is a small amount of breakage in the linux configuration defaults.  The above changes will work around the problems.

4.  You're now ready to emerge the latest genkernel.  This is a brilliant piece of engineering, it's significantly better than the beta versions that I tried earlier in the year.  Do this:

```
ACCEPT_KEYWORDS='~x86' emerge genkernel

```

You then need to hack away in the /usr/share/genkernel directory as I'll explain:

5.  Copy your /usr/src/linux/.config file to /usr/share/genkernel/x86/kernel-config-2.6 and also delete /etc/kernels/kernel-config-x86-2.6.6 if it exists.  This ensures the new default will be used.

6.  Completely replace the /usr/share/genkernel/x86/modules_load file with the following:  (Note, I'm open to suggestions here, I don't have RAID/USB support but I can add if needed)

```
MODULES_IDE="ide-cd ide-disk"

MODULES_SCSI="sd_mod sr_mod 3w-xxxx BusLogic NCR53c406a advansys aha1542 \

cpqfc dmx3191d dtc eata eata_pio fdomain g_NCR5380 g_NCR5380_mmio gdth \

in2000 ips pas16 psi240i qlogicfas qlogicfc qlogicisp sym53c416 t128 tmscsim \

u14-34f ultrastor wd7000 aic79xx aic7xxx"

MODULES_FS="ext3 reiserfs"

```

Note:  If you have for example an ALi 15x3 IDE controller on your motherboard, the first line can read:  MODULES_IDE="ide-cd ide-disk alim15x3"   BUT:  This needs to be customized to the destination PC, since modprobe isn't smart enough to reject the "alim15x3" module on other PCs.  Similar logic applies if you want to use, say, an "nsp32" SCSI card.  The modules I listed, seem to check the hardware is really present, and thus can always be modprobe'd.

7.  Apply the following small patch to /usr/share/genkernel/generic/initrd.defaults:

```
--- initrd.defaults!   2004-06-27 03:21:55.000000000 +1000

+++ initrd.defaults   2004-06-27 08:52:26.000000000 +1000

@@ -17,8 +17,8 @@

 # Only sections that are in by default or those that

 # are not module groups need to be defined here...

 

-HWOPTS="usb firewire keymap cache lvm2"

-MY_HWOPTS="usb firewire lvm2"

+HWOPTS="cache keymap lvm2"

+MY_HWOPTS="fs lvm2"

 

 QUIET=1

 ROOT_LINKS='bin sbin lib lib64 boot usr opt'

```

Note that we could add "ide" into MY_HWOPTS so that a normal IDE system doesn't require the "doide" parameter to be passed in.  Then on a SCSI system we could use "noide" to skip the installation of IDE drivers.  But this doesn't work, for some reason.  Can anyone help?  For now, I think it's acceptable to make "doide" a required parameter.

8.  Ready to rock and roll.  Do the following:

```
genkernel all

```

9.  Later on, if you're preparing a bootstrap for some other machine, modify the /usr/share/genkernel/x86/modules_load file as required, and then run the following:

```
genkernel initrd

```

10.  Customize your /etc/modules.autoload file, the following is a good starting point:

```
af_packet

capability

floppy

loop

8250

parport_pc

ntfs

vfat

ipt_REJECT

ipt_state

iptable_filter

ipt_multiport

ipt_LOG

ip_nat_irc

ip_nat_ftp

iptable_nat

ip_conntrack_irc

ip_conntrack_ftp

ip_conntrack

ip_tables

8139too

tun

mousedev

psmouse

snd

snd-pcm-oss

snd-rawmidi

snd-cmipci

```

Remove "ip*" if you don't want iptables.  My ethernet card is "8139too", so you can replace that with "tulip", etc, whatever.  You probably want the mouse driver.  If you use ALSA then change "snd-cmipci" to reflect your actual soundcard.  In fact, "af_packet" and "capability" are the only absolutely required modules (Gentoo will not boot without them).  The "loop" module is a requirement if you plan to run genkernel later on.  I installed "ntfs" and "vfat" here, rather than in the initrd, because I'm never planning on booting linux from an ntfs or vfat partition.

Please reply in this forum and let me know if you found the technique useful!!

cheers,

NickLast edited by nick_downing on Sun Jun 27, 2004 3:33 pm; edited 5 times in total

----------

## spb

 *nick_downing wrote:*   

> Do this:
> 
> ```
> ACCEPT_KEYWORDS='~x86' emerge genkernel
> 
> ...

 No, don't do that. Do this: 

```
mkdir -p /etc/portage

echo "sys-kernel/genkernel ~x86" >>/etc/portage/package.keywords

emerge genkernel
```

As for building everything as modules, it seems to me a singularly pointless exercise (no offence meant, of course  :Wink: ). I switch kernels more often than I switch hardware, so it saves more time to have a config file that enables only the drivers that I actually need If it weren't for nvidia, I'd disable module support entirely. But, if that's the way you like it, go ahead.  :Wink: 

----------

## nick_downing

Ah, thanks, you're right, that means you won't downgrade genkernel when you do "emerge --update world".  I didn't know how to do this.  But actually, it would probably be better to "inject" the package so that you won't unexpectedly lose your changes in modules_load et cetera.  Unfortunately I don't know how to do this (n00b's of the world unite), so I just kept a copy under /root that I can refer to later.  As for the all-modules idea, it's good if you have multiple machines to administer, especially if some machines are too slow to compile a kernel themselves.  You can also use kudzu, which might in theory be handy (I don't bother with it myself).

cheers,

Nick

----------

