Re: Grub 2 Title Tweaks Thread
If you want to to figure out what LONGNAME is for changing a menu entry, and if it's being changed try something like this:
edit /etc/grub.d/30_os-prober like this, probably around line 139 ish
Code:
#/etc/grub.d/30_os-prober
#http://ubuntuforums.org/showthread.php?t=1287602
# if [ -z "${LONGNAME}" ] ; then
# LONGNAME="${LABEL}"
# fi
#see /boot/grub/grub.cfg for the output of these lines after a sudo update-grub2, if not commented out
#the '#' in the echo is so that this doesn't give an error if you accidentally(or decide to) leave it
echo '#${LONGNAME} was'
echo "#${LONGNAME}"
if [ "${LONGNAME}" = "LONGNAME text to be replaced" ] ; then
LONGNAME="LONGNAME replacement text"
elif [ -z "${LONGNAME}" ] ; then
LONGNAME="${LABEL}"
fi
echo '#${LONGNAME} is now'
echo "#${LONGNAME}"
then run sudo update-grub2 and see the output in /boot/grub/grub.cfg
Re: Grub 2 Title Tweaks Thread
Since I often try to provide solutions in this thread and use the "cut" command, I like to know the format of the basic variables in 10_linux and 30_os-prober. Here is a list I keep of the standard output formats:
VARIABLES:
10_linux:
linux: /boot/vmlinuz-2.6.32-22-generic
basename: vmlinuz-2.6.32-22-generic
dirname: /boot
version: 2.6.32-22-generic
alt_version: 2.6.32-22-generic
linux_root_device_thisversion: UUID=c5163c70-4f7-4034-a218-5dae03b07eed
30_os-prober:
DEVICE: /dev/sda9
LONGNAME: Ubuntu 8.10 (8.10)
OS: /dev/sda9:Ubuntu^8.10^(8.10):Ubuntu:linux
LABEL: Ubuntu
BOOT: linux
LROOT: /dev/sda9
LINUX: /dev/sda9:/dev/sda9:Ubuntu^8.10,^kernel^2.6.27-9-generic:/boot/vmlinuz-2.6.27-9-generic:/boot/initrd.img-2.6.27-9-generic:root=UUID=ba83d184-705e-4115-9d42-0823c698a77^ro^splash^quiet
LLABEL: Ubuntu 8.10, kernel 2.6.27-9-generic
LKERNEL: /boot/vmlinuz-2.6.27-9-generic
LINITRD: /boot/initrd.img-2.6.27-9-generic
LPARAMS: root=UUID=ba83d184-705e-4115-9d42-0823c698a77 ro splash quiet
Re: Grub 2 Title Tweaks Thread
Quote:
Originally Posted by
CharlesA
Yeah, you should remove "false"
It should looks like this:
Code:
linux_entry "${OS} ${version_no_generic}" \
The problem I had was if I updated the variable with the name I wanted, it would leave off "recovery mode" so I did a quick and dirty workaround:
I had to edit /boot/grub/menu.lst on the BT4 install and then running "update-grub" from Ubuntu 9.10.
Original menu.lst:
Code:
title Ubuntu 8.10, kernel 2.6.30.9
uuid a76c7835-eb6f-459f-a891-496f16bc00eb
kernel /boot/vmlinuz-2.6.30.9 root=UUID=a76c7835-eb6f-459f-a891-496f16bc00eb ro vga=0x317
initrd /boot/initrd.img-2.6.30.9
quiet
title Ubuntu 8.10, kernel 2.6.30.9 (recovery mode)
uuid a76c7835-eb6f-459f-a891-496f16bc00eb
kernel /boot/vmlinuz-2.6.30.9 root=UUID=a76c7835-eb6f-459f-a891-496f16bc00eb ro single
initrd /boot/initrd.img-2.6.30.9
title Ubuntu 8.10, memtest86+
uuid a76c7835-eb6f-459f-a891-496f16bc00eb
kernel /boot/memtest86+.bin
quiet
Edited menu.lst:
Code:
title Backtrack 4 Final (2.6.30.9)
uuid 8ce79a61-7653-4799-950e-bca17e0b5b77
kernel /boot/vmlinuz-2.6.30.9 root=UUID=8ce79a61-7653-4799-950e-bca17e0b5b77 ro quiet splash
initrd /boot/initrd.img-2.6.30.9
quiet
title Backtrack 4 Final (.6.30.92) (recovery mode)
uuid 8ce79a61-7653-4799-950e-bca17e0b5b77
kernel /boot/vmlinuz-2.6.30.9 root=UUID=8ce79a61-7653-4799-950e-bca17e0b5b77 ro single
initrd /boot/initrd.img-2.6.30.9
#title Ubuntu 8.10, memtest86+
#uuid 8ce79a61-7653-4799-950e-bca17e0b5b77
kernel /boot/memtest86+.bin
quiet
Here is what my Grub2 menu looks like now:
Code:
Karmic (2.6.31-20)
Karmic (2.6.31-20) (recovery mode)
Karmic (2.6.31-14)
Karmic (2.6.31-14) (recovery mode)
Windows 7 Professional
Backtrack 4 Final (2.6.30.9)
Backtrack 4 Final (2.6.30.9) (recovery mode)
Much, much cleaner.
Thank you so much for sharing that!
I was able to rename BT4 through that simple edit. No needing to miss with Grub 2 files on Ubuntu ;).
Re: Grub 2 Title Tweaks Thread
Works great, and the link to a custom menu is great too! Thanks
:guitar:
Re: Grub 2 Title Tweaks Thread
help, I got a huge problem with this tweaking.
I was following the instruction in post 112. However, I think I've missed some lines so I'm encountering a huge problem. After restarting to see the result, I didnt see the Ubuntu entry anymore, only the recovery mode and the windows left. Now I couldn't log on to Ubuntu.
How can I log on to ubuntu in recovery mode to change back the files I just edited? Or should I reinstall Ubuntu ?
Re: Grub 2 Title Tweaks Thread
Quote:
Originally Posted by
alababi
help, I got a huge problem with this tweaking.
I was following the instruction in post 112. However, I think I've missed some lines so I'm encountering a huge problem. After restarting to see the result, I didnt see the Ubuntu entry anymore, only the recovery mode and the windows left. Now I couldn't log on to Ubuntu.
How can I log on to ubuntu in recovery mode to change back the files I just edited? Or should I reinstall Ubuntu ?
You could boot in recovery mode and edit the grub file using nano. It has a very friendly interface and it is one of the easiest command line text editing programs out there. Or, if you had made a backup of your grub configuration before you started editing it, you can restore it from recovery mode. You don't have to go to the trouble of reinstalling Ubuntu, it's probably just a small error and easily fixable. Just post the contents of your configuration file here so we could see what went wrong (use a usb stick to copy the contents of the grub configuration file, then boot into Windows to post it here).
Re: Grub 2 Title Tweaks Thread
Quote:
Originally Posted by
Agent.Logic_
You could boot in recovery mode and edit the grub file using nano. It has a very friendly interface and it is one of the easiest command line text editing programs out there. Or, if you had made a backup of your grub configuration before you started editing it, you can restore it from recovery mode. You don't have to go to the trouble of reinstalling Ubuntu, it's probably just a small error and easily fixable. Just post the contents of your configuration file here so we could see what went wrong (use a usb stick to copy the contents of the grub configuration file, then boot into Windows to post it here).
Please elucidate the nano stuff for me. As you can see, I'm just a newbie to ubuntu. When I chose the recovery mode entry, all I saw was black screen with commands, similar to a full screen size terminal.
I just need to be able to log on to Ubuntu to set everything as default, I saved the original commands which I changed as comments.
Re: Grub 2 Title Tweaks Thread
Quote:
Originally Posted by
alababi
Please elucidate the nano stuff for me. As you can see, I'm just a newbie to ubuntu. When I chose the recovery mode entry, all I saw was black screen with commands, similar to a full screen size terminal.
I just need to be able to log on to Ubuntu to set everything as default, I saved the original commands which I changed as comments.
Okay, I'll walk you through.
When you boot into recovery mode, a lot of lines will fly by you (don't get bogged down, it is impossible to keep up with and most of it is just information about what is loading currently, ignorable warnings etc.) After everything has finished loading, you will be a few options, just scroll down with your down arrow key and choose "drop to root shell prompt."
- Type
Code:
nano /etc/grub.d/10_linux
seeing that you edited that file according to post #112. Please do tell if you edited any other grub related configuration file.
- Just remove the edits on post #112 and uncomment the lines you commented out originally.
- Save it by pressing ctrl + O (Write Out) and exit by pressing ctrl + X.
- Type in and when it is done, type in
Code:
update-initramfs -u
- Reboot by typing
Hopefully, this should fix it. If you are not sure anymore that the 10_linux file was restored to its original self, here is the untouched version of the 10_linux file:
Code:
#! /bin/sh -e
# grub-mkconfig helper script.
# Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc.
#
# GRUB is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# GRUB is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GRUB. If not, see <http://www.gnu.org/licenses/>.
prefix=/usr
exec_prefix=${prefix}
bindir=${exec_prefix}/bin
libdir=${exec_prefix}/lib
. ${libdir}/grub/grub-mkconfig_lib
export TEXTDOMAIN=grub
export TEXTDOMAINDIR=@LOCALEDIR@
CLASS="--class gnu-linux --class gnu --class os"
if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
OS=GNU/Linux
else
OS="${GRUB_DISTRIBUTOR}"
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]' | cut -d' ' -f1) ${CLASS}"
fi
# loop-AES arranges things so that /dev/loop/X can be our root device, but
# the initrds that Linux uses don't like that.
case ${GRUB_DEVICE} in
/dev/loop/*|/dev/loop[0-9])
GRUB_DEVICE=`losetup ${GRUB_DEVICE} | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"`
# We can't cope with devices loop-mounted from files here.
case ${GRUB_DEVICE} in
/dev/*) ;;
*) exit 0 ;;
esac
;;
esac
if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \
|| ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \
|| [ "`grub-probe -t abstraction --device ${GRUB_DEVICE} | sed -e 's,.*\(lvm\).*,\1,'`" = "lvm" ] ; then
LINUX_ROOT_DEVICE=${GRUB_DEVICE}
else
LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
fi
# add crashkernel option if we have the required tools
if [ -x "/usr/bin/makedumpfile" ] && [ -x "/sbin/kexec" ]; then
GRUB_CMDLINE_EXTRA="$GRUB_CMDLINE_EXTRA crashkernel=384M-2G:64M,2G-:128M"
fi
linux_entry ()
{
os="$1"
version="$2"
recovery="$3"
args="$4"
if ${recovery} ; then
title="$(gettext_quoted "%s, with Linux %s (recovery mode)")"
else
title="$(gettext_quoted "%s, with Linux %s")"
fi
printf "menuentry '${title}' ${CLASS} {\n" "${os}" "${version}"
cat << EOF
recordfail
EOF
save_default_entry | sed -e "s/^/\t/"
if [ "x$GRUB_GFXPAYLOAD_LINUX" != x ]; then
cat << EOF
set gfxpayload=$GRUB_GFXPAYLOAD_LINUX
EOF
fi
if [ -z "${prepare_boot_cache}" ]; then
prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
fi
printf '%s\n' "${prepare_boot_cache}"
if [ "x$5" != "xquiet" ]; then
cat << EOF
echo '$(printf "$(gettext_quoted "Loading Linux %s ...")" ${version})'
EOF
fi
cat << EOF
linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args}
EOF
if [ "x$5" != "xquiet" ]; then
cat << EOF
echo '$(gettext_quoted "Loading initial ramdisk ...")'
EOF
fi
if test -n "${initrd}" ; then
cat << EOF
initrd ${rel_dirname}/${initrd}
EOF
fi
cat << EOF
}
EOF
}
list=`for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* ; do
if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
done`
prepare_boot_cache=
while [ "x$list" != "x" ] ; do
linux=`version_find_latest $list`
echo "Found linux image: $linux" >&2
basename=`basename $linux`
dirname=`dirname $linux`
rel_dirname=`make_system_path_relative_to_its_root $dirname`
version=`echo $basename | sed -e "s,^[^0-9]*-,,g"`
alt_version=`echo $version | sed -e "s,\.old$,,g"`
linux_root_device_thisversion="${LINUX_ROOT_DEVICE}"
initrd=
for i in "initrd.img-${version}" "initrd-${version}.img" \
"initrd-${version}" "initrd.img-${alt_version}" \
"initrd-${alt_version}.img" "initrd-${alt_version}"; do
if test -e "${dirname}/${i}" ; then
initrd="$i"
break
fi
done
if test -n "${initrd}" ; then
echo "Found initrd image: ${dirname}/${initrd}" >&2
else
# "UUID=" magic is parsed by initrds. Since there's no initrd, it can't work here.
linux_root_device_thisversion=${GRUB_DEVICE}
fi
linux_entry "${OS}" "${version}" false \
"${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_EXTRA} ${GRUB_CMDLINE_LINUX_DEFAULT}" \
quiet
if [ "x${GRUB_DISABLE_LINUX_RECOVERY}" != "xtrue" ]; then
linux_entry "${OS}" "${version}" true \
"single ${GRUB_CMDLINE_LINUX}"
fi
list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
done
Re: Grub 2 Title Tweaks Thread
@Agent Logic:
I just did as what you wrote but I stuck in step 3. After I changed the code, it didnt allow me to save the file. How can I overcome this ?
Re: Grub 2 Title Tweaks Thread
That's strange... you are logged in as root and that means you have complete access to the system. Nothing should stop you. Does it give you any error messages? When you press ctrl + O, a little dialog appears in the bottom of the screen asking "File name to write:" and you just have to press enter (to save it in the current file). Is this where you are stuck?