[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How to change the kernel title in /boot/grub/menu.lst?



Hi Surreal,

You can do changes to the final binary by putting a hook in config/binary_local-hooks/. Those hooks will be executed after the binary is built, but before the final binary image is created (iso or img file).

I use syslinux/extlinux, not grub, so the following have to be adapted to grub and to your case.

#!/bin/sh

echo "BINARY HOOK: syslinux changes."

# check if menu was already changed
CHANGED=`grep -i '#EDITED' *`
if [ -n "$CHANGED" ]; then
# It was. Skip further changes."
echo "Menu was already edited, skip it."
exit 0
fi

LIVECFG=`find binary -type f -name live.cfg`
# lenny syslinux is different from the latest one.
# The menu file has a different name (menu.cfg/live.cfg).
if [ -n "${LIVECFG}" ]; then
echo "Found live.cfg."
else
echo "live.cfg not found, searching for menu.cfg."
LIVECFG=`find binary -type f -name menu.cfg`
fi

echo $LIVECFG

# mark the menu as edited/changed so its not edited again.
echo "#EDITED" >> ${LIVECFG}

# get the first option as template file
head -n 5 ${LIVECFG} > menu_template

# add some boot options to syslinux (reverse)
# A - encrypted home
# B - persistent
# C - integrity-check

# C - integrity-check, verifies against md5sum.txt
cp menu_template menu_check
sed -i 's/label live/label livecheck/' menu_check
sed -i 's/Start Debian Live/Integrity Check/' menu_check
sed -i 's/union=aufs/union=aufs integrity-check/' menu_check

# copy the new menu after the default first one
sed '5r menu_check' < ${LIVECFG} > new_menu
mv new_menu ${LIVECFG}

# B - persistent
cp menu_template menu_persist
sed -i 's/label live/label livepersistent/' menu_persist
sed -i 's/Start Debian Live/Start Debian Live Persistent/' menu_persist
sed -i 's/username=live hostname=cruzador/username=my_name hostname=my_hostname/' menu_persist
sed -i 's/union=aufs/union=aufs persistent=nofiles/' menu_persist

# copy the new menu after the default first one
sed '5r menu_persist' < ${LIVECFG} > new_menu
mv new_menu ${LIVECFG}

# A - encrypted home
cp menu_template menu_lukshome
sed -i 's/label live/label livelukshome/' menu_lukshome
sed -i 's/Start Debian Live/Start Debian Live LUKS home/' menu_lukshome
sed -i 's/username=live hostname=cruzador/username=my_name hostname=my_hostname/' menu_lukshome
sed -i 's/union=aufs/union=aufs lukshome/' menu_lukshome

# copy the new menu after the default first one
sed '5r menu_lukshome' < ${LIVECFG} > new_menu
mv new_menu ${LIVECFG}

# delete template files
rm menu_check
rm menu_persist
rm menu_lukshome
rm menu_template

# create extlinux.conf
SYSLINUXCFG=`find binary -type f -name syslinux.cfg`

# if not found, search in isolinux
if [ -z $SYSLINUXCFG ]; then
# check for isolinux
SYSLINUXCFG=`find binary -type f -name isolinux.cfg`
fi

# if still empty, no syslinux or isolinux, maybe using grub(?) or extlinux, so skip it.
if [ -z $SYSLINUXCFG ]; then
echo "No syslinux or isolinux... skipping."
exit 0
fi

# copy to extlinux.conf
SYSPATH="$(dirname ${SYSLINUXCFG})"
/bin/cp ${SYSLINUXCFG} ${SYSPATH}/extlinux.conf

# NOTE: to install extlinux, mount the partition as /mnt and
# run "extlinux --install /mnt/live/syslinux". This will overwrite the MBR!!!
# If you use grub in the MBR, then re-install it with "update-grub /dev/sdX"
# EOF

Don't forget to make the hook executable.

Have fun.

Rui M. P. Bernardo

On Oct 2, 2009 1:14 p.m., "surreal" <firewalrus@gmail.com> wrote:

I installed linux-source-2.6.26 in /usr/src, modified some configurations,  and used make-kpkg command to generate a kernel deb file.

On installing the kernel on my local machine, I found that the kernel was entered as title        Debian GNU/Linux, kernel 2.6.26 (single-user mode) in /boot/grub/menu.lst

I installed this kernel image on my live cd, and then installed it to my hdd.

Inspite of me making modifications to the kernel, its still showing title Debian GNU/Linux, kernel 2.6.26 (single-user mode) in the grub bootup.

Then I installed the same very linux image deb file in Ubuntu 8.10, and even there the kernel was listed as that of Ubuntu..!!!

How do I change this title to that of my own?

How to customize the kernel title in /boot/grub/menu.lst automatically without user interven?

Its a fair thing that if i customize a kernel according to my need, I should be able to use a name for it too..!!

Any idea of how to do this??

The uname of my live cd and machine is

Linux indiaforce 2.6.26 #1 SMP Thu Oct 1 09:03:37 IST 2009 i686 GNU/Linux

Now how to enable indiaforce ie hostname to appear in kernel name?

Please help.

 



--
Harshad Joshi


Reply to: