1

I'm trying to compile linux kernel 3.14 on ubuntu 14.04. Before anyone points out, I know newer stable versions of the kernel are available but I have been asked to install 3.14 itself. So, I wrote a script which unpacks the source tar and starts building the kernel. But it stops mid way without generating any errors. I've tried to fiddle with the code and it still gives the same error every-time.

Snippet of the script:

# Prepare for compilation
make -j1 mrproper
# Set default configuration
make -j1 defconfig
# Compile the kernel image and modules
make -j1
# Install the modules
make -j1 modules_install
# Install the firmware
make -j1 firmware_install

# Install the kernel
cp -v arch/x86_64/boot/bzImage /boot/vm_linuz-3-14-systemd
# Install the map file
cp -v System.map /boot/system-map-3-14-systemd
# Backup kernel configuration file
cp -v .config /boot/config-backup-3-14

Last few lines of the log:

 LD [M]  net/ipv4/netfilter/iptable_nat.ko
 LD [M]  net/ipv4/netfilter/nf_nat_ipv4.ko
 LD [M]  net/netfilter/nf_nat.ko
 LD [M]  net/netfilter/nf_nat_ftp.ko
 LD [M]  net/netfilter/nf_nat_irc.ko
 LD [M]  net/netfilter/nf_nat_sip.ko
 LD [M]  net/netfilter/xt_LOG.ko
 LD [M]  net/netfilter/xt_mark.ko
 LD [M]  net/netfilter/xt_nat.ko
 HOSTCC  arch/x86/boot/tools/build
 CPUSTR  arch/x86/boot/cpustr.h
 CC      arch/x86/boot/cpu.o
 MKPIGGY arch/x86/boot/compressed/piggy.S
 AS      arch/x86/boot/compressed/piggy.o
 LD      arch/x86/boot/compressed/vmlinux
 ZOFFSET arch/x86/boot/zoffset.h
 OBJCOPY arch/x86/boot/vmlinux.bin
 AS      arch/x86/boot/header.o
 LD      arch/x86/boot/setup.elf
 OBJCOPY arch/x86/boot/setup.bin
 BUILD   arch/x86/boot/bzImage
 Setup is 15232 bytes (padded to 15360 bytes).
 System is 5433 kB
 CRC 62b609cb
 Kernel: arch/x86/boot/bzImage is ready  (#1)

 Building modules, stage 2.
   MODPOST 11 modules
   CC      drivers/thermal/x86_pkg_temp_thermal.mod.o
   LD [M]  drivers/thermal/x86_pkg_temp_thermal.ko
   CC      net/ipv4/netfilter/ipt_MASQUERADE.mod.o
   LD [M]  net/ipv4/netfilter/ipt_MASQUERADE.ko
   CC      net/ipv4/netfilter/iptable_nat.mod.o
   LD [M]  net/ipv4/netfilter/iptable_nat.ko
   CC      net/ipv4/netfilter/nf_nat_ipv4.mod.o
   LD [M]  net/ipv4/netfilter/nf_nat_ipv4.ko
   CC      net/netfilter/nf_nat.mod.o
   LD [M]  net/netfilter/nf_nat.ko
   CC      net/netfilter/nf_nat_ftp.mod.o
   LD [M]  net/netfilter/nf_nat_ftp.ko
   CC      net/netfilter/nf_nat_irc.mod.o
   LD [M]  net/netfilter/nf_nat_irc.ko
   CC      net/netfilter/nf_nat_sip.mod.o
   LD [M]  net/netfilter/nf_nat_sip.ko
   CC      net/netfilter/xt_LOG.mod.o
   LD [M]  net/netfilter/xt_LOG.ko
   CC      net/netfilter/xt_mark.mod.o
   LD [M]  net/netfilter/xt_mark.ko
   CC      net/netfilter/xt_nat.mod.o
   LD [M]  net/netfilter/xt_nat.ko
 sh /finalize-system/linux-kernel/linux-3.14/arch/x86/boot/install.sh      3.14.21 arch/x86/boot/bzImage \
    System.map "/boot"
 Cannot find LILO.

Update

I have updated my build log. This time it is showing an error Cannot find LILO. But I have installed Grub 2 on my system. Then why is it asking for LILO? Probably this was the error from the start and this time it showed it on the screen.

  • I don't see any errors in your output there been a while since I used Gentoo where I did kernel compiles but that looks to me like a completed kernel build check srcdir/arch/x86/boot/bzImage exists that will be the actual kernel image. – MttJocy May 26 '16 at 2:16
  • The image is there but why doesn't the script continues after make -j1? There are no errors and still it doesn't execute the rest of the commands. I'm unable to find the problem. – Abhimanyu Saharan May 26 '16 at 2:19
  • Not sure but I would just execute the remaining commands myself but then that would have been my preference in the first place allowing me to check the output from each stage before moving on to the next one. Havn't tried messing with trying to script the operation sorry. – MttJocy May 26 '16 at 2:23
  • 1
    3.14 kernel packages for Trusty are available here: kernel.ubuntu.com/~kernel-ppa/mainline/v3.14-trusty – fkraiem May 26 '16 at 3:17
  • @fkraiem I don't want the debian packages. I want to compile my own kernel. If I wanted the deb files, I could have used apt-get to download the files. – Abhimanyu Saharan May 27 '16 at 7:38
1

After adding ARCH=x86_64 flag to all the make commands, everything worked like a charm.

0

The problem is, LILO is the Legacy Boot Loader which almost no Linux distribution use it anymore due to it's lack of features. In modern distribution, GRUB is widely used.

So, if you want to use the new compiled Linux Kernel in GRUB, You should manually Copy it to /boot directory, because the official Linux Kernel Makefile won't do it for you.

Following commands would do it for you :

sudo make headers_install INSTALL_HDR_PATH=/usr/src/linux-5.0.2
sudo cp arch/x86_64/boot/bzImage /boot/vmlinuz-5.0.2
sudo cp System.map /boot/System-5.0.2.map
sudo mkinitcpio -k 5.0.2 -c /etc/mkinitcpio.conf -g /boot/initramfs-5.0.2.img

PS : You should remove the old vmlinuz and initramfs in /boot directory by using rm command , before using mkinitcpio.

PS : This instruction works on Linux Arch as i test it.

Could anyone move this question to Linux and Unix stack which is more appropriate there.

  • Although grub is indeed widespread Slackware has been using Lilo for longer than any distro has even been in existence and still uses it quite successfully. Its supposed 'lack of features' is something of an urban legend... – andrew.46 Mar 28 at 1:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.