嘗試在ubuntu 14.04上編譯並啟動linux-2.6.32內核
[環境]
$ cat /etc/issue
Ubuntu 14.04.5 LTS \n \l
$ uname -a
Linux Ui386 4.4.0-31-generic #50~14.04.1-Ubuntu SMP Wed Jul 13 01:06:37 UTC 2016 i686 i686 i686 GNU/Linux
[把gcc-4.8改成gcc-4.4,否則會有一些編譯錯誤]
$ gcc -v
$ cat /proc/version
Linux version 4.4.0-31-generic (buildd@lgw01-01) (gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3) ) #50~14.04.1-Ubuntu SMP Wed Jul 13 01:06:37 UTC 2016
$ ls -l /usr/bin/ | grep gcc
$ sudo add-apt-repository ppa:ubuntu-toolchain-r/test
$ sudo apt-get update
$ sudo apt-get install gcc-4.4
$ sudo apt-get install g++-4.4
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.4 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.4
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8
$ sudo update-alternatives --config gcc
$ sudo apt-get install build-essential kernel-package libncurses5-dev
$ wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.32.tar.bz2
$ tar jxvf linux-2.6.32.tar.bz2
$ cd linux-2.6.32
$ sudo make mrproper
$ make menuconfig // 默認配置即可
$ make bzImage
Kernel: arch/x86/boot/bzImage is ready (#2)
$ make modules
WARNING: modpost: Found 1 section mismatch(es).
To see full details build your kernel with:
‘make CONFIG_DEBUG_SECTION_MISMATCH=y‘
$ sudo make modules_install
DEPMOD 2.6.32
depmod: WARNING: could not open /lib/modules/2.6.32/modules.builtin: No such file or directory
$ ls /lib/modules
2.6.32 4.4.0-31-generic
$ ls -l /boot/ | grep -i "2.6.32"
-rw-r--r-- 1 root root 93547 9月 5 14:31 config-2.6.32
-rw-r--r-- 1 root root 2688277 9月 5 14:31 initrd.img-2.6.32
-rw-r--r-- 1 root root 1744261 9月 5 14:31 System.map-2.6.32
-rw-r--r-- 1 root root 3932352 9月 5 14:31 vmlinuz-2.6.32
// 已經生成了 initrd.img-2.6.32, 不需要執行mkinitramfs命令。
fnie@Ui386:~/workspace/ldd3/linux-2.6.32-v1$ grub-install --version
grub-install (GRUB) 2.02~beta2-9ubuntu1.12
fnie@Ui386:~/workspace/ldd3/linux-2.6.32-v1$ sudo update-grub
[sudo] password for fnie:
Generating grub configuration file ...
Warning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.
Found linux image: /boot/vmlinuz-4.4.0-31-generic
Found initrd image: /boot/initrd.img-4.4.0-31-generic
Found linux image: /boot/vmlinuz-2.6.32
Found initrd image: /boot/initrd.img-2.6.32
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin
done
// 關機重啟,長按Shift鍵,進入recovery模式,選擇啟動2.6.32,
Loading Linux 2.6.32 ...
Loading initial ramdisk ...
無法啟動。
只好尋找其他方法:使用 make-kpkg。
$ sudo apt-get install kernel-package
$ sudo make-kpkg clean
// 編譯,結束後會在父目錄生成兩個文件:linux-image-xxx.deb和linux-head-xxx.deb
$ sudo make-kpkg --initrd --append-to-version=linux-2.6.10-1 kernel-image kernel-headers
fnie@Ui386:~/workspace/ldd3/linux-2.6.32$ ls ../
linux-2.6.10 linux-headers-2.6.32linux-2.6.10-1_2.6.32linux-2.6.10-1-10.00.Custom_i386.deb package
linux-2.6.32 linux-image-2.6.32linux-2.6.10-1_2.6.32linux-2.6.10-1-10.00.Custom_i386.deb
linux-2.6.32-v1 log
// 安裝內核
$ cd ..
$ sudo dpkg -i linux-image-2.6.32linux-2.6.10-1_2.6.32linux-2.6.10-1-10.00.Custom_i386.deb
$ sudo dpkg -i linux-headers-2.6.32linux-2.6.10-1_2.6.32linux-2.6.10-1-10.00.Custom_i386.deb
//檢測是否正確安裝了內核
$ ls -l /boot
// 關機重啟,長按Shift鍵,進入recovery模式,選擇啟動2.6.32linux-2.6.10-1,
Loading Linux 2.6.32linux-2.6.10-1 ...
Loading initial ramdisk ...
都不行,只好祭出大招了:安裝 ubuntu-6.06.1-desktop-i386.iso ,它的內核版本是2.6.15.
一切都重歸平靜...
嘗試在ubuntu 14.04上編譯並啟動linux-2.6.32內核