Help with linux kernel compilation script
i wrote a script to compile the kernel:
cd /usr/src/linux-2.4.18-14custom
make bzImage
make modules
make modules_install
cd arch/i386/boot
yes|cp bzImage /boot/vmlinuz-2.4.18-14custom
cd /boot
yes|mv 2.4.18-14custom.img 2.4.18-14custom.img.back
mkinitrd 2.4.18-14custom.img 2.4.18-14custom
reboot
if i execute every line in the console it works, but when I put all of them in the script it executes only this 2 lines and ends:
make bzImage
make modules
any ideas to mak开发者_开发技巧e it work?
kernel building
make -C /usr/src/linux help
shows the options for building and installing a kernel.
initramfs allows for a built-in initrd equivalent that requires no post-build effort. I don't know if that's been backported to linux-2.4; but why 2.4?
Use
make all install modules_install
to install everything. Maybe 2.4 Makefiles require a separate "modules" target too.
After switching to initramfs, it's likely everything can be accomplished with one make command:
make -C /usr/src/linux all install modules_install
Scripts
For an example install script see arch/i386/boot/install.sh. Also, seen the Makefile in that same directory to see how it all works. If a system-wide installkernel script exists (/sbin/installkernel in Gentoo), or a user one $HOME/bin/installkernel, that'll be used.
The script originally posted with this question will work under the right conditions. I ran it; but faked mkinitrd, and skipped reboot.
- The script does not check for failure. It should stop if make fails, and not fail if the old fies for mv or cp don't exist.
- cosmetic:
yes|mv
andyes|cp
should be replaced withcp -f
andmv -f
. See the man pages (ormv --help
,cp --help
).
精彩评论