Compiled my first kernel - it was easy.

Write tutorials for Linux Mint here
More tutorials on https://github.com/orgs/linuxmint/discu ... /tutorials and (archive) on https://community.linuxmint.com/tutorial
Forum rules
Don't add support questions to tutorials; start your own topic in the appropriate sub-forum instead. Before you post read forum rules
Post Reply
User avatar
Flemur
Level 20
Level 20
Posts: 10096
Joined: Mon Aug 20, 2012 9:41 pm
Location: Potemkin Village

Compiled my first kernel - it was easy.

Post by Flemur »

I'd done a lot of C/unix programming the in the past but no system/kernel stuff, so most of this was new to me.

I put this here because most descriptions make compiling a kernel sound harder than it is:

1: Download: http://www.kernel.org/pub/linux/kernel/ ... .5.tar.bz2 (or the version you want, of course).

2: uncompress/untar, and cd into "linux-3.5.0"

3: $ make mrproper
(This "cleans" the code - whatever tht means?)

4: Plug in all your gizmos - sd cards, camera, USB drives - and turn them on, mount, etc.

5: $ make localmodconfig
(This'll see what drivers and such are needed for your devices, and make the config. There's a zillion obscure options on the "menuconfig" method, so I didn't do it that way.)
Edit: Now I'm making another: after localmodconfig run "$ make gconfig", which is MUCH better than menuconfig but requires gtk-dev, etc.

6: $ make -j2 ( -j2 = use 2 processors)
(This takes a long time - half hour or more, typically)

I backed up /boot and /lib/modules, then:
7: $ sudo make modules_install (creates files in /lib/modules/version-name)

8: $ sudo make install (creates files in /boot)
(I had some errors on vbox stuff - which probably shouldn't even be there - and ignored them. This step took several minutes).

9: $ cd /boot

10: $ sudo mkinitramfs -o initrd.img-3.5.0 3.5.0 (make the initrd file).

9: Run update-grub or edit the grub file (grub.cfg or menu.lst).

Much to my amazement it booted on the first try and all gizmos seem to work :D
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?
User avatar
Oscar799
Level 20
Level 20
Posts: 10419
Joined: Tue Aug 11, 2009 9:21 am
Location: United Kingdom

Re: Compiled my first kernel - it was easy.

Post by Oscar799 »

Moved here by moderator
Image
atari800

Re: Compiled my first kernel - it was easy.

Post by atari800 »

Good deal!!!
User avatar
Flemur
Level 20
Level 20
Posts: 10096
Joined: Mon Aug 20, 2012 9:41 pm
Location: Potemkin Village

Re: Compiled my first kernel - it was easy.

Post by Flemur »

Beginners' luck, apparently!

I did another with kernel 3.6.0-rc7, trying to get the disk drivers into the kernel so it wouldn't need initrd.img (never got that to work), and it took 40 seconds to boot vs about 20 seconds (w/autologin to fluxbox GUI) with the generic kernel.

Then kernel 3.5.4, using the config for 3.2.0-31-generic, and couldn't get it to boot; the "make install" ran forever and made a /lib/modules directory that was several times as big as the others. ??

Also, the process of making the kernels (each one) used close to 10GB of disk space...yikes.

My conclusion is: the tricky part is the configuration (.config file). And everything else.
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?
Post Reply

Return to “Tutorials”