Punto informatico Network
Login Esegui login | Non sei registrato? Iscriviti ora (è gratuito!)
Username: Password:
  • Annuncio Pubblicitario

Editare GRUB2 per eliminare voci

Il forum riservato agli amici del Pinguino e al software libero.

Re: Editare GRUB2 per eliminare voci

Messaggioda Matilda12 » mer apr 28, 2010 3:45 pm

Grazie per i chiarimenti Doc! [^]
Da profano con approccio Windows-oriented ( [:D] ), visto che Mezzodemone vuole solo "non vedere" quella menuentry, non sarebbe sufficiente tacitarla con un bel cancelletto? ... senza interferire più pesantemente con gli altri file, intendo. Una sorta di "@echo off" (bella forzatura ho fatto, eh?).
Porta pazienza ... ma sono i miei primi approcci! [:D]
[ciao]
Matilda12
Dove c'è molta luce l'ombra è più nera.
Avatar utente
Matilda12
Utente inattivo
 
Messaggi: 1319
Iscritto il: mer feb 07, 2007 11:15 pm
Località: Marche - Italia

Re: Editare GRUB2 per eliminare voci

Messaggioda The Doctor » mer apr 28, 2010 4:17 pm

Purtroppo non basta il #, però se ad esempio non vuoi che compaia la voce relativa a memtest è sufficiente togliere l'attributo di esecuzione al file /etc/grub.d/20_memtest86+ e non lo vedrai più tra le opzioni di avvio [;)]
Ciao Nonno
Avatar utente
The Doctor
MLI Hero
MLI Hero
 
Messaggi: 5553
Iscritto il: mer mar 24, 2010 9:10 am
Località: Fiumicino (Roma)

Re: Editare GRUB2 per eliminare voci

Messaggioda Al3x » mer apr 28, 2010 4:27 pm

confermo che Ubuntu durante l'installazione rileva le partizioni di recovery identificandole con il loader del sistema operativo. Con Vista e Seven l'identificazione è di Vista loader.
Togliere però quella voce ti impedirebbe in futuro di avviare il recovery visto che l'mbr del disco è stato sostituito da quello di Linux. Se hai però i dischi di ripristino di Vista allora non hai problemi.
è primavera finalmente! [:)]
Avatar utente
Al3x
Membro Ufficiale (Gold)
Membro Ufficiale (Gold)
 
Messaggi: 7418
Iscritto il: sab gen 10, 2009 12:51 pm
Località: http://127.0.0.1/


Re: Editare GRUB2 per eliminare voci

Messaggioda The Doctor » mer apr 28, 2010 4:53 pm

Per rendere GRUB2 "più amichevole" c'è un trucco, ovvero costruire un menu di avvio totalmente personalizzato con solo le voci che vogliamo. Per quanto riguarda le necessità di mezzodemone gli è sufficiente rendere ineseguibile il file /etc/grub.d/30_os-prober con il comando

Codice: Seleziona tutto
sudo chmod -x /etc/grub.d/30_os-prober


Aprire il file /boot/grub/grub.cfg e copiare la parte desiderata che si trova tra

### BEGIN /etc/grub.d/30_os-prober ###

### END /etc/grub.d/30_os-prober ###

ad esempio io ho solo la seguente menuentry ma mezzodemone anche quella relativa a Vista che non deve copiare

menuentry "Windows 7 (loader) (on /dev/sda1)" {
insmod ntfs
set root='(hd0,1)'
search --no-floppy --fs-uuid --set 1e86d85986d8334f
chainloader +1
}

all'interno del file /etc/grub.d/40_custom e dare

Codice: Seleziona tutto
sudo update-grub


In tal modo il file 30_os-prober verrebbe saltato poichè non eseguibile ed il file 40_custom caricato nel menu con le voci che vogliamo [;)]
Ciao Nonno
Avatar utente
The Doctor
MLI Hero
MLI Hero
 
Messaggi: 5553
Iscritto il: mer mar 24, 2010 9:10 am
Località: Fiumicino (Roma)

Re: Editare GRUB2 per eliminare voci

Messaggioda Matilda12 » mer apr 28, 2010 6:10 pm

Urka! ... da brivido!!!
Credo che dovrò studiare proprio molto ... [uhm]
[ciao]
Matilda12
Dove c'è molta luce l'ombra è più nera.
Avatar utente
Matilda12
Utente inattivo
 
Messaggi: 1319
Iscritto il: mer feb 07, 2007 11:15 pm
Località: Marche - Italia

Re: Editare GRUB2 per eliminare voci

Messaggioda mezzodemone » gio apr 29, 2010 5:34 pm

Ragà grazie della disponibilità...sono un po' incasinato, appena ho 5 minuti metto la lista delle voce richiesta...grazie
Avatar utente
mezzodemone
Aficionado
Aficionado
 
Messaggi: 139
Iscritto il: dom mar 15, 2009 9:25 pm

Re: Editare GRUB2 per eliminare voci

Messaggioda mezzodemone » dom mag 02, 2010 9:40 am

Ecco il contenuto del file grub.d del 30 os prober e del 40 custom

voci grub.d

00_header
05 debian theme
10 linux
20 memtest 86+
30 os prober
40 custom
readme



40 custom file -----------------------------------------
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.


30 os prober file---------------------------------------

#! /bin/sh -e

# grub-mkconfig helper script.
# Copyright (C) 2006,2007,2008,2009 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}
libdir=${exec_prefix}/lib

. ${libdir}/grub/grub-mkconfig_lib

found_other_os=

adjust_timeout () {
if [ "x${found_other_os}" = "x" ] ; then
if [ "x${GRUB_HIDDEN_TIMEOUT}" != "x" ] ; then
if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then
verbose=
else
verbose=" --verbose"
fi

if [ "x${GRUB_HIDDEN_TIMEOUT}" = "x0" ] ; then
cat <<EOF
if [ \${timeout} != -1 ]; then
if keystatus; then
if keystatus --shift; then
set timeout=-1
else
set timeout=0
fi
else
if sleep$verbose --interruptible 3 ; then
set timeout=0
fi
fi
fi
EOF
else
cat << EOF
if [ \${timeout} != -1 ]; then
if sleep$verbose --interruptible ${GRUB_HIDDEN_TIMEOUT} ; then
set timeout=0
fi
fi
EOF
fi
fi
fi
}

if [ "x${GRUB_DISABLE_OS_PROBER}" = "xtrue" ]; then
adjust_timeout
exit 0
fi

if [ -z "`which os-prober 2> /dev/null`" -o -z "`which linux-boot-prober 2> /dev/null`" ] ; then
# missing os-prober and/or linux-boot-prober
adjust_timeout
exit 0
fi

OSPROBED="`os-prober | tr ' ' '^' | paste -s -d ' '`"
if [ -z "${OSPROBED}" ] ; then
# empty os-prober output, nothing doing
adjust_timeout
exit 0
fi

for OS in ${OSPROBED} ; do
DEVICE="`echo ${OS} | cut -d ':' -f 1`"
LONGNAME="`echo ${OS} | cut -d ':' -f 2 | tr '^' ' '`"
LABEL="`echo ${OS} | cut -d ':' -f 3 | tr '^' ' '`"
BOOT="`echo ${OS} | cut -d ':' -f 4`"

if [ -z "${LONGNAME}" ] ; then
LONGNAME="${LABEL}"
fi

echo "Found ${LONGNAME} on ${DEVICE}" >&2
found_other_os=1

case ${BOOT} in
chain)

cat << EOF
menuentry "${LONGNAME} (on ${DEVICE})" {
EOF
save_default_entry | sed -e "s/^/\t/"
prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"

case ${LONGNAME} in
Windows\ Vista*|Windows\ 7*)
;;
*)
cat << EOF
drivemap -s (hd0) \${root}
EOF
;;
esac

cat <<EOF
chainloader +1
}
EOF
;;
linux)
LINUXPROBED="`linux-boot-prober ${DEVICE} 2> /dev/null | tr ' ' '^' | paste -s -d ' '`"

for LINUX in ${LINUXPROBED} ; do
LROOT="`echo ${LINUX} | cut -d ':' -f 1`"
LBOOT="`echo ${LINUX} | cut -d ':' -f 2`"
LLABEL="`echo ${LINUX} | cut -d ':' -f 3 | tr '^' ' '`"
LKERNEL="`echo ${LINUX} | cut -d ':' -f 4`"
LINITRD="`echo ${LINUX} | cut -d ':' -f 5`"
LPARAMS="`echo ${LINUX} | cut -d ':' -f 6- | tr '^' ' '`"

if [ -z "${LLABEL}" ] ; then
LLABEL="${LONGNAME}"
fi

cat << EOF
menuentry "${LLABEL} (on ${DEVICE})" {
EOF
save_default_entry | sed -e "s/^/\t/"
prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
cat << EOF
linux ${LKERNEL} ${LPARAMS}
EOF
if [ -n "${LINITRD}" ] ; then
cat << EOF
initrd ${LINITRD}
EOF
fi
cat << EOF
}
EOF
done
;;
macosx)
OSXUUID="`grub-probe --target=fs_uuid --device ${DEVICE} 2> /dev/null`"
cat << EOF
menuentry "${LONGNAME} (on ${DEVICE})" {
EOF
save_default_entry | sed -e "s/^/\t/"
prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
cat << EOF
insmod vbe
do_resume=0
if [ /var/vm/sleepimage -nt10 / ]; then
if xnu_resume /var/vm/sleepimage; then
do_resume=1
fi
fi
if [ \$do_resume == 0 ]; then
xnu_uuid ${OSXUUID} uuid
if [ -f /Extra/DSDT.aml ]; then
acpi -e /Extra/DSDT.aml
fi
xnu_kernel /mach_kernel boot-uuid=\${uuid} rd=*uuid
if [ /System/Library/Extensions.mkext -nt /System/Library/Extensions ]; then
xnu_mkext /System/Library/Extensions.mkext
else
xnu_kextdir /System/Library/Extensions
fi
if [ -f /Extra/Extensions.mkext ]; then
xnu_mkext /Extra/Extensions.mkext
fi
if [ -d /Extra/Extensions ]; then
xnu_kextdir /Extra/Extensions
fi
if [ -f /Extra/devtree.txt ]; then
xnu_devtree /Extra/devtree.txt
fi
if [ -f /Extra/splash.jpg ]; then
insmod jpeg
xnu_splash /Extra/splash.jpg
fi
if [ -f /Extra/splash.png ]; then
insmod png
xnu_splash /Extra/splash.png
fi
if [ -f /Extra/splash.tga ]; then
insmod tga
xnu_splash /Extra/splash.tga
fi
fi
}
EOF
;;
hurd|*)
echo " ${LONGNAME} is not yet supported by grub-mkconfig." >&2
;;
esac
done

adjust_timeout
Avatar utente
mezzodemone
Aficionado
Aficionado
 
Messaggi: 139
Iscritto il: dom mar 15, 2009 9:25 pm

Re: Editare GRUB2 per eliminare voci

Messaggioda The Doctor » dom mag 02, 2010 5:40 pm

OK. Segui il mio post precedente. Rendi ineseguibile il file 30_os-prober e copia le menuentry del file /boot/grub/grub.cfg che ti interessano nel file 40_custom (solo quelle non linux ovviamente).

Devi prendere tutto il codice che va da
menuentry
.
.
.
}

compresa la graffa mi raccomando e poi dai

Codice: Seleziona tutto
sudo update-grub


Riavvia e vedi se tutto è ok [;)]

Nota: le righe di codice presenti nel file 40_custom non vanno toccate e le menuentry vanno dalla fine di tale codice in poi
Ciao Nonno
Avatar utente
The Doctor
MLI Hero
MLI Hero
 
Messaggi: 5553
Iscritto il: mer mar 24, 2010 9:10 am
Località: Fiumicino (Roma)

Precedente

Torna a Distribuzioni, Kernel e Software Applicativo

Chi c’è in linea

Visitano il forum: Nessuno e 3 ospiti

Powered by phpBB © 2002, 2005, 2007, 2008 phpBB Group
Traduzione Italiana phpBB.it

megalab.it: testata telematica quotidiana registrata al Tribunale di Cosenza n. 22/09 del 13.08.2009, editore Master New Media S.r.l.; © Copyright 2008 Master New Media S.r.l. a socio unico - P.I. 02947530784. GRUPPO EDIZIONI MASTER Spa Tutti i diritti sono riservati. Per la pubblicità: Master Advertising