Showing posts with label compile kernel. Show all posts
Showing posts with label compile kernel. Show all posts

26 April 2013

397. Briefly: compiling ck (Con Kolivas) kernel 3.8.9 in arch linux


mkdir ~/tmp
cd ~/tmp 
wget http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.8.9.tar.bz2
tar xvf linux-3.8.9.tar.bz2
cd linux-3.8.9/
wget http://ck.kolivas.org/patches/3.0/3.8/3.8-ck1/patch-3.8-ck1.bz2
bunzip2 patch-3.8-ck1.bz2
patch -p1 < patch-3.8-ck1
cp /proc/config.gz .
gunzip config.gz
mv config .config
make oldconfig
make -j2
make -j2 modules
sudo make modules_install
sudo make headers_install INSTALL_HDR_PATH=/usr/src/linux-3.8.9-ck1-ARCH
sudo cp arch/x86_64/boot/bzImage /boot/vmlinuz-3.8.9-ck1-ARCH
sudo cp System.map /boot/System-3.8.9-ck1-ARCH.map
sudo mkinitcpio -k 3.8.9-ck1-ARCH -c /etc/mkinitcpio.conf -g /boot/initramfs-3.8.9-ck1-ARCH.img
sudo grub-mkconfig -o /boot/grub/grub.cfg

05 March 2013

355. Compiling kernel 3.8.2 on Arch linux -- exploration

Edit: remove the sudo make install line -- it shouldn't be necessary and it triggers an error: 'cannot find LILO'

You can generate a good starting .config with make localconfig which creates a .config which prepares the modules which are in use by your system at that point. You can also get the old kernel config from /proc/config.gz which is probably a better approach.

I would guess that the approach described here is pretty much distro-agnostic.

Anyway, compiling the kernel:

mkdir ~/tmp
cd ~/tmp
wget http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.8.2.tar.bz2
tar xvf linux-3.8.2.tar.bz2
cd linux-3.8.2/
cp /proc/config.gz .
gunzip config.gz
mv config .config
make oldconfig
make -j2
make -j2 modules
sudo make modules_install
sudo make headers_install INSTALL_HDR_PATH=/usr/src/linux-3.8.2
sudo cp arch/x86_64/boot/bzImage /boot/vmlinuz-3.8.2
sudo cp System.map /boot/System-3.8.2.map
sudo mkinitcpio -k 3.8.2-ARCH -c /etc/mkinitcpio.conf -g /boot/initramfs-3.8.2.img

NOTE: the naming isn't random. In order for grub-mkconfig to discover both the vmlinuz and initramfs files they need to be named vmlinuz-IDENTIFIER and initramfs-IDENTIFIER.img. The identifier can be anything.

Generate your grub.cfg:
sudo grub-mkconfig -o /boot/grub/grub.cfg

Reboot, and do
uname -a
Linux titanium 3.8.2 #1 SMP Mon Mar 4 20:17:17 EST 2013 x86_64 GNU/Linux

24 February 2013

344. Compile a kernel (3.8) without using kpkg

Note: There is a much better and easier way: http://verahill.blogspot.com.au/2013/02/342-compiling-kernel-38-on-debian.html . What follows is just done for the sake of exploration.

Post begins:
It is incredibly easy to compile your own kernel on Debian using kernel-package. See e.g. http://verahill.blogspot.com.au/2013/02/342-compiling-kernel-38-on-debian.html

In the interest of learning how to compile a kernel in a more generic way which is applicable to non-debian systems (arch, red hat etc.), here's a method which doesn't rely on kpkg (kernel-package).

The downside is that this method does not produce a set of .deb files, and that you can't uninstall it using apt.

I'll be brief since most things are covered e.g. here.  I looked at this post when writing this.

sudo apt-get install build-essential ncurses-bin
mkdir ~/tmp
cd ~/tmp
wget http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.8.tar.bz2
tar xvf linux-3.8.tar.bz2
cd linux-3.8/
cat /boot/config-`uname -r`>.config
make oldconfig

Once you're done answering the questions, do

time make -j3

This takes 29 minutes (AMD Athlon II X3).

time make -j3 modules

This takes 4 minutes. Finish by running

sudo make modules_install
sudo make headers_install INSTALL_HDR_PATH=/usr/src/linux-3.8.0
sudo make install

Note that the default path for the headers is /usr/include, which doesn't play well with most programs that check for the presence of headers before installation, so use INSTALL_HDR_PATH to specify the destination (at least on debian).

make install takes care of initramfs and grub-update as well and generates
/boot/config-3.8.0
/boot/initrd.img-3.8.0
/boot/System.map-3.8.0
/boot/vmlinuz-3.8.0
And that's really it -- compiling a kernel even without kernel-packages is pretty easy. Reboot and everything should be in working order.

16 January 2013

321. Compiling Kernel 3.7.3 (and 3.7.2) on Debian Testing/Wheezy. More data on make -jN.

Updated for 3.7.3

Since post '319. Collection of errors when compiling kernel 3.7.x on AMD FX 8150' is getting traffic from people wanting to compile kernel 3.7.2, and because I didn't know whether the azx_runtime_suspend bug had been fixed, I had to try it out. So here's how to compile kernel 3.7.2 and 3.7.3 -- for 3.7.2 simply replace all instances of 3.7.3..

Looking at the code changes here: http://lists-archives.com/linux-kernel/27763782-alsa-hda-move-runtime-pm-check-to-runtime_idle-callback.html and comparing with what I'm actually seeing in sound/pci/hda/hda_intel.c it seems that 3.7.2 and 3.7.3 have been fixed and no patches need to be applied.

Testing the kernel bears that out.


Compiling the kernel
sudo apt-get install kernel-package fakeroot build-essential ncurses-bin ncurses-dev
mkdir ~/tmp
cd ~/tmp
wget http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.7.3.tar.bz2
tar xvf linux-3.7.3.tar.bz2
cd linux-3.7.3/
cat /boot/config-`uname -r`>.config
make oldconfig
make-kpkg clean

If you want to add specific drivers etc to the kernel, run
make menuconfig

Note that if you're transitioning from kernel 3.5 to 3.7 you will needto specifically and explicitly include a lot of the graphics (pci tv cards, usb web cams) drivers that used to be automatically included before. Then continue:

time fakeroot make-kpkg -j6 --initrd kernel_image kernel_headers
sudo dpkg -i ../linux-image-3.7.3_3.7.3-10.00.Custom_amd64.deb ../linux-headers-3.7.3_3.7.3-10.00.Custom_amd64.deb

And you're done. Keep reading to learn more about -j6.


Optimal -jN
See here for another post on -jN: http://verahill.blogspot.com.au/2013/01/305-make-jn-should-n-equal-number-of.html. In short, it's not always clear whether N should equal the number of cores, or be larger than the number of cores. In that post, N+1 was the optimal configuration, but that was a very short compilation where i/o likely played a large role.

More data is needed, so here it is. Seems like N=number of cores is the best option for long builds (as was pointed out to me in a comment). This was done with kernel 3.7.2.

On a four-core Intel i5-2400 with 16 Gb memory
N Time ------------- 2 30m 58s 3 22m 36s 4 19m 49s 5 22m 2s 6 23m 13s

Acquired using sar/sysstat
Here's what's happening with -j4:
Basically, the first 15 minutes things are running in parallel, with t i/o slowing things down during the last 5 minutes.

On a six-core AMD Phenom II 1055T with 8 Gb memory
N Time (s) ------------- 4 34m 16s 5 27m 19s 6 24m 60s 7 30m 18s 8 31m 47s


Hardware profiles:
Intel machine:
00:00.0 0600: 8086:0100 (rev 09) 00:02.0 0300: 8086:0102 (rev 09) 00:16.0 0780: 8086:1c3a (rev 04) 00:16.3 0700: 8086:1c3d (rev 04) 00:19.0 0200: 8086:1502 (rev 04) 00:1a.0 0c03: 8086:1c2d (rev 04) 00:1b.0 0403: 8086:1c20 (rev 04) 00:1c.0 0604: 8086:1c10 (rev b4) 00:1c.2 0604: 8086:1c14 (rev b4) 00:1d.0 0c03: 8086:1c26 (rev 04) 00:1e.0 0604: 8086:244e (rev a4) 00:1f.0 0601: 8086:1c4e (rev 04) 00:1f.2 0104: 8086:2822 (rev 04) 00:1f.3 0c05: 8086:1c22 (rev 04)

AMD machine:
00:00.0 0600: 1022:9601 00:01.0 0604: 1022:9602 00:07.0 0604: 1022:9607 00:11.0 0106: 1002:4390 00:12.0 0c03: 1002:4397 00:12.1 0c03: 1002:4398 00:12.2 0c03: 1002:4396 00:13.0 0c03: 1002:4397 00:13.1 0c03: 1002:4398 00:13.2 0c03: 1002:4396 00:14.0 0c05: 1002:4385 (rev 3c) 00:14.1 0101: 1002:439c 00:14.2 0403: 1002:4383 00:14.3 0601: 1002:439d 00:14.4 0604: 1002:4384 00:14.5 0c03: 1002:4399 00:18.0 0600: 1022:1200 00:18.1 0600: 1022:1201 00:18.2 0600: 1022:1202 00:18.3 0600: 1022:1203 00:18.4 0600: 1022:1204 01:05.0 0300: 1002:9715 01:05.1 0403: 1002:970f 02:00.0 0200: 10ec:8168 (rev 03) 03:05.0 0200: 10ec:8169 (rev 10