Walka z GRUB-em 2?

Tematy związane z oprogramowaniem, instalacją, konfiguracją
Awatar użytkownika
Bastian
Member
Posty: 1424
Rejestracja: 30 marca 2008, 16:09
Lokalizacja: Poznañ

Post autor: Bastian »

Witam.
Nie mogę poradzić sobie ze zmuszeniem GRUB2 do wyświetlania ekranu powitalnego podczas ładowania systemu. Obrazek pojawia się podczas wyświetlania menu gruba, a potem już tylko wyświetlają się wyniki ładowania skryptów. Z tego co widzę to wszystko jest dobrze i powinno działać.

/etc/grub.d/05_debian_theme:

Kod: Zaznacz cały

#!/bin/bash -e                                       

source /usr/lib/grub/grub-mkconfig_lib

# this allows desktop-base to override our settings
f=/usr/share/desktop-base/grub_background.sh       
if test -e ${f} ; then                             
  source ${f}                                      
else                                               
  WALLPAPER="/usr/share/images/desktop-base/moreblue-orbit-grub.png"
  COLOR_NORMAL="black/black"                                        
  COLOR_HIGHLIGHT="magenta/black"                                   
fi                                                                  

set_blue_theme()
{               
  cat << EOF    
set menu_color_normal=cyan/blue
set menu_color_highlight=white/blue
EOF
}

# check for usable backgrounds
use_bg=false
if [ "$GRUB_TERMINAL_OUTPUT" = "gfxterm" ] ; then
  for i in /boot/grub/`basename ${WALLPAPER}` ${WALLPAPER} ; do
    if is_path_readable_by_grub $i ; then
      bg=$i
      case ${bg} in
        *.png)          reader=png ;;
        *.tga)          reader=tga ;;
        *.jpg|*.jpeg)   reader=jpeg ;;
      esac
      if test -e /boot/grub/${reader}.mod ; then
        echo "Found background image: `basename ${bg}`" >&2
        use_bg=true
        break
      fi
    fi
  done
fi

# set the background if possible
if ${use_bg} ; then
  prepare_grub_to_access_device `${grub_probe} --target=device ${bg}`
  cat << EOF
insmod ${reader}
if background_image `make_system_path_relative_to_its_root ${bg}` ; then
  set color_normal=${COLOR_NORMAL}
  set color_highlight=${COLOR_HIGHLIGHT}
else
EOF
fi

# otherwise, set the traditional Debian blue theme
if ${use_bg} ; then
  set_blue_theme | sed -e "s/^/  /g"
  echo "fi"
else
  set_blue_them
fi
etc/default/grub:

Kod: Zaznacz cały

# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.

GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_LINUX_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"
Początkowo miałem wartość:

Kod: Zaznacz cały

GRUB_CMDLINE_LINUX_DEFAULT="quiet"
i myślałem ze to dopisanie "splash" rozwiąże problem ale nic to nie dało. Również odkomentowałem:

Kod: Zaznacz cały

GRUB_GFXMODE=640x480
Ale to tez nie pomogło. Oczywiście za każdym razem robię:

Kod: Zaznacz cały

update-grub
Mój Debian do wersja testowa.

Czy ktoś ma pomysł o co chodzi?

Dodane:
Jeszcze mi na myśl jedna rzecz przyszła. Czy może ktoś sprawdzić, czy po starcie systemu macie wgrany moduł glxterm? Wydaje mi się, że powinien on być wgrany wraz ze startem systemu i od niego zależy wyświetlanie obrazka. U mnie nie ma.

Dodane:
Temat rozwiązany.

Po pierwsze GRUB2 nie obsługuje wyświetlania grafiki podczas startu systemu i nie wiem skąd mi się wzięło przekonanie, że jest inaczej.

Tak więc powróciłem do splashy. Jednak wymagało to trochę pracy gdyż, GRUB2 nie używa już poleceń bufora ramki vga=791. Żeby na Debianie cieszyć się poprawnym splashy należy:

1. w /etc/default/grub:

Kod: Zaznacz cały

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
2. W skrypcie uruchamiającym splasha /etc/init.d/splash dopisać:

Kod: Zaznacz cały

#!/bin/sh                                         
### BEGIN INIT INFO                               
# Provides:          splashy                      
# Required-Start:    mountkernfs                  
# Required-Stop:                                  
# Default-Start:     S                            
# Default-Stop:      0 6                          
# Short-Description: A script to calculate the progress percentage for init scripts
# Description:       This calculates the progress percentage for the scripts in    
#                    /etc/rcS.d and /etc/rc$CURRENT_RUNLEVEL.d. This will also     
#                    start Splashy at boot (if not already started from initramfs),
#                    and at shutdown (yes, when "stop" argument is given,          
#                    which is really counter-intuitive).                           
### END INIT INFO                                                                  

# Author: Tim Dijkstra <tim@famdijkstra.org>, 
#         Luis Mondesi <lemsx1@gmail.com>     
#         Luca Capello <luca@pca.it>          
#                                             
# If called in the rc[06].d runlevels with the stop target it will start 
# splashy in 'shutdown' mode. In the rcS.d runlevel it will try          
# to start splashy if it didn't start yet from initramfs.                
#                                                                        
# When it decides to start splashy it will first calculate the           
# progress percentage which will be used by the calls to splashy_update  
# in the log_end_msg functions.                                          
# This is really simple. We just count them and put them                 
# in alpha-numeric order. Their percentage is then just                  
# int( their number on the list * ( 100 / total number on list) )        
#                                                                        
# Of course not all packages use log_end_msg yet, but that               
# doesn't matter. The packages that do, will trigger the update                                                                                                     
# anyway. This may result in big jumps in the percentage.                                                                                                           
# The more scripts start using it, the more granular it will become.                                                                                                
#                                                                                                                                                                   
#                                                                                                                                                                   
# This script also needs to detect if Splashy is running and if not                                                                                                 
# start it. It's assumed that this will only be run while halt/reboot                                                                                               
# and at RUNLEVEL S.                                                                                                                                                
#                                                                                                                                                                   
                                                                                                                                                                    
PATH="/sbin:/bin:/usr/sbin:/usr/bin"                                                                                                                                
NAME="splashy"                                                                                                                                                      
DESC="Boot splash manager"                                                                                                                                          
STEPS_DIR="/lib/init/rw/$NAME"                                                                                                                                      
DEBUG=0                                                                                                                                                             

[ -r "/etc/default/$NAME" ] && . "/etc/default/$NAME"

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
if [ -r "/lib/lsb/init-functions" ]; then                           
    . "/lib/lsb/init-functions"                                     
else                                                                
    echo "Could not read file /lib/lsb/init-functions. Please install lsb-base"
    exit 1                                                                     
fi                                                                             

set -e


[ "$ENABLE" = "1" ] && log_warning_msg "To enable $NAME add 'splash' to the kernel command line. Use of ENABLE in /etc/default/$NAME is deprecated.";

check_to_enable () {
        ENABLE=0    
        SINGLE=false
        SPLASH=false
        FBMODESET=false

        for x in $(cat /proc/cmdline); do
            case $x in                   
                single)                  
                    SINGLE="true"        
                ;;                       
                splash)                  
                    SPLASH="true"        
                ;;                       
                nosplash)                
                    SPLASH="false"       
                ;;                       
                vga=*|video=*)           
                    FBMODESET="true"     
                ;;                       
            esac                         
        done                             
        [B]# grub2 gfxmode?                 
        [ "$FBMODESET" != "true" ] && [ -f /boot/grub/grub.cfg ] && \
        grep -q "^[[:space:]]*set[[:space:]]*gfxmode=" /boot/grub/grub.cfg && \
                FBMODESET="true" [/B]                                              

        [ "$SPLASH" = "true" -a "$FBMODESET" = "true" ] && ENABLE=1
        [ "$SINGLE" = "true" ] && ENABLE=0                         

        if [ "$ENABLE" = "0" ]; then
            log_warning_msg "To enable $NAME on multiuser runlevel add 'splash' and a valid framebuffer videomode to the kernel command line"
            exit 0                                                                                                                           
        fi                                                                                                                                   
}                                                                                                                                            

calculate_steps () {
        log_daemon_msg "(Re)generating splash steps for"

        [ -f /etc/inittab ] &&  RLVL=`sed -n 's/id:\([2345]\):initdefault:/\1/ p' /etc/inittab`

        [ ! -d $STEPS_DIR ] && mkdir -p $STEPS_DIR
        #                                         
        # Mount a tmpfs on $STEPS_DIR             
        #                                         
        # on Ubuntu our Steps dir gets umounted if using /dev/shm/splashy
        # we will always use /lib/init/rw/splashy and mount a tmpfs there
        SHM_OPT=                                                         
        [ "${SHM_SIZE:=$TMPFS_SIZE}" ] && SHM_OPT="-osize=$SHM_SIZE"     
        mount -n -t tmpfs shmfs $STEPS_DIR                               

        TMP=`mktemp -p $STEPS_DIR`

        # While booting rcS will also be executed
        # we only care about the scripts that actually call log_end_msg
        # if not we could end up never completing our progressbar!     
        grep -l log_end_msg /etc/rcS.d/S* > $TMP 2> /dev/null || true  

        for ILVL in ${RLVL:=2} 0 6; do
            # in debian rc.local runs log_end_msg conditionally. we simply skip that
            grep -l log_end_msg /etc/rc$ILVL.d/[KS]* 2> /dev/null | grep -v rc.local >> $TMP  || true
                                                                                                     
            NR=`sed -n -e '$=' $TMP`                                                                 
            I=1                                                                                      
            for SCR in `cat $TMP`; do                                                                
                echo "$SCR $(($I*100/$NR))"                                                          
                I=$(($I+1))                                                                          
            done > "$STEPS_DIR/$ILVL-progress"                                                       

            # Truncate $TMP file
            echo -n > $TMP      
            log_action_cont_msg " rc$ILVL.d"
        done                                

        # In the first stage of booting RUNLEVEL will be S
        ln -sf "$STEPS_DIR/${RLVL:=2}-progress" "$STEPS_DIR/S-progress"
        rm -f $TMP                                                     

        log_action_end_msg 0
}                           

# Bug #400598,#401999
if [ -z "${RUNLEVEL:-}" ]; then
    # we need only the current level
    RUNLEVEL=`runlevel | sed 's/^. //'`
fi                                     

case "$1" in
    start)  
        check_to_enable

        # We start splashy in rcS.d if we haven't already in initramfs
        [ "x$RUNLEVEL" = "xN S" -o "x$RUNLEVEL" = "xS" ] || exit 0    
        calculate_steps                                               

        log_daemon_msg "Starting $DESC" $NAME
        if [ "$DEBUG" = "1" ]; then          
            pidof $NAME > /dev/null || \     
            echo "$0: Splashy not running?" >> $STEPS_DIR/splashy.log
        fi                                                           
        if (pidof $NAME > /dev/null); then                           
            # as suggested by John Hughes <john@calva.com> Bug# 462626
            # Splashy is running and we want to avoid our TTY to be corrupted
            stty -icanon -clocal                                             
        else                                                                 
            /sbin/$NAME boot                                                 
            sleep 0.2                                                        
        fi                                                                   
        # Before X starts we need to turn off the cursor to avoid artifacts: 
        for i in 7 8 9 10 11 12; do                                          
            if [ -c /dev/tty$i ]; then                                       
                setterm -cursor off > /dev/tty$i || true                     
            fi                                                               
        done                                                                 
        log_end_msg $?                                                       
    ;;                                                                       
    stop)                                                                    
        check_to_enable                                                      
                                                                             
        # avoid displaying ugly text at shutdown                             
        clear >/dev/tty8                                                     
        clear >/dev/tty1                                                     
        # wait for all gdm servers to exit (DBTS# 504389)                    
        COUNTER=0                                                            
        ATTEMPTS=10                                                          
        set +e                                                               
        while [ $COUNTER -lt $ATTEMPTS ]; do                                 
            ps -C "gdm"                                                      
            if [ $? -eq 0 ]; then                                            
                sleep 0.5                                                    
                COUNTER=`expr $COUNTER + 1` #works in dash
            else
                break
            fi
        done
        set -e
        if [ $COUNTER -eq $ATTEMPTS ]; then
            echo "$NAME stopping because gdm is still active"
            exit
        fi

        /sbin/splashy_chvt 8

        calculate_steps

        # sanity check, kill Splashy if running (old bug)
        pidof $NAME > /dev/null && splashy_update "exit" && pkill -9 splashy

        log_daemon_msg "Starting $DESC" $NAME
        /sbin/$NAME shutdown
        sleep 0.2
        # tell killall5 to not kill us too early at shutdown/restart:
        pidof $NAME >> /var/run/sendsigs.omit
        RET=$?
        [ -d /lib/init/rw/sendsigs.omit.d ] || mkdir -p /lib/init/rw/sendsigs.omit.d
        cat /var/run/sendsigs.omit >> /lib/init/rw/sendsigs.omit.d/splashy
        # log_end_msg calls splashy_update, so we need to allow Splashy to start
        sleep 0.5
        log_end_msg $RET

    ;;

    restart|force-reload)
        calculate_steps $RUNLEVEL
        ;;

    *)
        N=/etc/init.d/$NAME
        echo "Usage: $N {start|stop|restart|force-reload}" >&2
        exit 1
        ;;
esac

exit 0
źródło: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=539239

3. W /etc/grub.d/00_header wpisać:

Kod: Zaznacz cały

set gfxpayload=keep
pomiędzy:

Kod: Zaznacz cały

set gfxmode=${GRUB_GFXMODE}                                               
  set gfxpayload=keep                                                       
  insmod gfxterm 
Dzięki temu rozdzielczość początkowa (standardowo 640x480 ale można zmieniać parametrem GRUB_GFXMODE=) będzie utrzymana dla konsoli.

Na koniec

Kod: Zaznacz cały

sudo update-grub
i działa.

Przydatne linki:

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=539239
http://harrison3001.blogspot.com/2009/0 ... o-set.html
http://linuxers.org/howto/how-change-gr ... ash-images
http://blogs.koolwal.net/2008/12/16/how ... sh-images/
KrzySie
Posty: 25
Rejestracja: 24 maja 2009, 15:06
Lokalizacja: Kielce

Post autor: KrzySie »

Wszystko ok. oprócz tego, że w repozytorium wersji stabilnej jest przestarzała wersja i nie działa SAVEDEFAULT?
Czy próbował ktoś wersję testową GRUB2 zainstalować na wersji stabilnej systemu?

Edycja:
Działa w opisanej konfiguracji!
Awatar użytkownika
Bastian
Member
Posty: 1424
Rejestracja: 30 marca 2008, 16:09
Lokalizacja: Poznañ

Post autor: Bastian »

Witam.
Mam znów problem z GRUB2 po aktualizacji systemu. GRUB2 wyświetla mi się w rozdzielczości 640x480 bez grafiki, czyli w standardowych ustawieniach, przy czym wszystkie ustawienia są poprawne i powinien wyświetlać wyższą rozdzielczość.

Czy ktoś używający Squeeze może wkleić wynik polecenia:

Kod: Zaznacz cały

dpkg -l | grep grub
Dodane:
Nadal mam ten problem, postanowiłem znów do tego przysiąść ale skończyły mi się pomysły. Przypomnę: grub2 wyświetla mi się w standardowych ustawieniach (niebieska ramka, czarne tło, niska rozdzielczość) i nie mogę na powrót tego ustawić aby ładował mi się motyw graficzny. Wcześniej działało, skopało się prawdopodobnie podczas którejś aktualizacji systemu. Podam zawartość kluczowych plików, gdyby ktoś mógł sprawdzić w swoim Debianie Squeeze, czy ma podobnie, czy nie.

/etc/default/grub

Kod: Zaznacz cały

# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.

GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT=
GRUB_CMDLINE_LINUX=""

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_LINUX_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"
/usr/share/desktop-base/grub_background.sh

Kod: Zaznacz cały

WALLPAPER=/usr/share/images/desktop-base/moreblue-orbit-grub.png
COLOR_NORMAL=light-gray/black
COLOR_HIGHLIGHT=white/black
/etc/grub.d/05

Kod: Zaznacz cały

#!/bin/sh                                                                                                                                                           
set -e                                                                                                                                                              
                                                                                                                                                                    
# grub-mkconfig helper script.                                                                                                                                      
# Copyright (C) 2010  Alexander Kurtz <kurtz.alex@googlemail.com>                                                                                                   
#                                                                                                                                                                   
# 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/>.

# Include the GRUB helper library for grub-mkconfig.
. /usr/lib/grub/grub-mkconfig_lib

# We want to work in /boot/grub/ only.
test -d "${GRUB_PREFIX}"; cd "${GRUB_PREFIX}"

# Set the location of a possibly necessary cache file for the background image.
# NOTE: This MUST BE A DOTFILE to avoid confusing it with user-defined images.
BACKGROUND_CACHE=".background_cache"

set_default_theme(){
        # Set the traditional Debian blue theme.
        echo "${1}set menu_color_normal=cyan/blue"
        echo "${1}set menu_color_highlight=white/blue"
}

set_background_image(){
        # Step #1: Search all available output modes ...
        local output
        for output in ${GRUB_TERMINAL_OUTPUT}; do
                if [ "x$output" = "xgfxterm" ]; then
                        break
                fi
        done

        # ... and check if we are able to display a background image at all.
        if ! [ "x${output}" = "xgfxterm" ]; then
                return 1
        fi

        # Step #2: Check if the specified background image exists.
        if ! [ -f "${1}" ]; then
                return 2
        fi

        # Step #3: Search the correct GRUB module for our background image.
        local reader
        case "${1}" in
                *.jpg|*.JPG|*.jpeg|*.JPEG) reader="jpeg";;
                *.png|*.PNG) reader="png";;
                *.tga|*.TGA) reader="tga";;
                *) return 3;; # Unknown image type.
        esac

        # Step #4: Check if the necessary GRUB module is available.
        if ! [ -f "${reader}.mod" ]; then
                return 4
        fi

        # Step #5: Check if GRUB can read the background image directly.
        # If so, we can remove the cache file (if any). Otherwise the backgound
        # image needs to be cached under /boot/grub/.
        if is_path_readable_by_grub "${1}"; then
                rm --force "${BACKGROUND_CACHE}.jpeg" \
                        "${BACKGROUND_CACHE}.png" "${BACKGROUND_CACHE}.tga"
        elif cp "${1}" "${BACKGROUND_CACHE}.${reader}"; then
                set -- "${BACKGROUND_CACHE}.${reader}" "${2}" "${3}"
        else
                return 5
        fi

        # Step #6: Prepare GRUB to read the background image.
        if ! prepare_grub_to_access_device "`${grub_probe} --target=device "${1}"`"; then
                return 6
        fi

        # Step #7: Everything went fine, print out a message to stderr ...
        echo "Found background image: ${1}" >&2

        # ... and write our configuration snippet to stdout. Use the colors
        # desktop-base specified. If we're using a user-defined background, use
        # the default colors since we've got no idea how the image looks like.
        # If loading the background image fails, use the default theme.
        echo "insmod ${reader}"
        echo "if background_image `make_system_path_relative_to_its_root "${1}"`; then"
        echo "  set color_normal=${2:-black/black}"
        echo "  set color_highlight=${3:-magenta/black}"
        echo "else"
        set_default_theme "  "
        echo "fi"
}

# Earlier versions of grub-pc copied the default background image to /boot/grub
# during postinst. Remove those obsolete images if they haven't been touched by
# the user. They are still available under /usr/share/images/desktop-base/ if
# desktop-base is installed.
while read checksum background; do
        if [ -f "${background}" ] && [ "x`sha1sum "${background}"`" = "x${checksum}  ${background}" ]; then
                echo "Removing old background image: ${background}" >&2
                rm "${background}"
        fi
done <<EOF
648ee65dd0c157a69b019a5372cbcfea4fc754a5  debian-blueish-wallpaper-640x480.png
0431e97a6c661084c59676c4baeeb8c2f602edb8  debian-blueish-wallpaper-640x480.png
968ecf6696c5638cfe80e8e70aba239526270864  debian-blueish-wallpaper-640x480.tga
11143e8c92a073401de0b0fd42d0c052af4ccd9b  moreblue-orbit-grub.png
d00d5e505ab63f2d53fa880bfac447e2d3bb197c  moreblue-orbit-grub.png
f5b12c1009ec0a3b029185f6b66cd0d7e5611019  moreblue-orbit-grub.png
EOF

# Include the configuration of desktop-base if available.
if [ -f "/usr/share/desktop-base/grub_background.sh" ]; then
        . "/usr/share/desktop-base/grub_background.sh"
fi

# First check whether the user has specified a background image explicitly.
# Next search for pictures the user put into /boot/grub/ and use the first one.
# Next try to use the background image and colors specified by desktop-base.
# If we haven't found a background image yet, use the default from desktop-base.
# Finally, if all of the above fails, use the default theme.
set_background_image "${GRUB_BACKGROUND}" ||
set_background_image "`ls -1 *.jpg *.JPG *.jpeg *.JPEG *.png *.PNG *.tga *.TGA 2>/dev/null | head -1`" ||
set_background_image "${WALLPAPER}" "${COLOR_NORMAL}" "${COLOR_HIGHLIGHT}" ||
set_background_image "/usr/share/images/desktop-base/desktop-grub.png" ||
set_default_theme
/etc/grub.d/00_header

Kod: Zaznacz cały

#! /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/>.

transform="s,x,x,"

prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
grub_prefix=`echo /boot/grub | sed ${transform}`
locale_dir=`echo /boot/grub/locale | sed ${transform}`
grub_lang=`echo $LANG | cut -d _ -f 1`

. ${libdir}/grub/grub-mkconfig_lib

# Do this as early as possible, since other commands might depend on it.
# (e.g. the `loadfont' command might need lvm or raid modules)
for i in ${GRUB_PRELOAD_MODULES} ; do
  echo "insmod $i"
done

if [ "x${GRUB_DEFAULT}" = "x" ] ; then GRUB_DEFAULT=0 ; fi
if [ "x${GRUB_DEFAULT}" = "xsaved" ] ; then GRUB_DEFAULT='${saved_entry}' ; fi
if [ "x${GRUB_TIMEOUT}" = "x" ] ; then GRUB_TIMEOUT=5 ; fi
if [ "x${GRUB_GFXMODE}" = "x" ] ; then GRUB_GFXMODE=640x480 ; fi

cat << EOF
if [ -s \$prefix/grubenv ]; then
  load_env
fi
set default="${GRUB_DEFAULT}"
if [ \${prev_saved_entry} ]; then
  set saved_entry=\${prev_saved_entry}
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi

function savedefault {
  if [ -z \${boot_once} ]; then
    saved_entry=\${chosen}
    save_env saved_entry
  fi
}
EOF

case ${GRUB_TERMINAL_INPUT}:${GRUB_TERMINAL_OUTPUT} in
  serial:* | *:serial)
    if ! test -e ${grub_prefix}/serial.mod ; then
      echo "Serial terminal not available on this platform." >&2 ; exit 1
    fi

    if [ "x${GRUB_SERIAL_COMMAND}" = "x" ] ; then
      grub_warn "Requested serial terminal but GRUB_SERIAL_COMMAND is unspecified. Default parameters will be used."
      GRUB_SERIAL_COMMAND=serial
    fi
    echo "${GRUB_SERIAL_COMMAND}"
  ;;
esac

case x${GRUB_TERMINAL_INPUT} in
  x)
    # Just use the native terminal
  ;;
  x*)
    cat << EOF
if terminal_input ${GRUB_TERMINAL_INPUT} ; then true ; else
  # For backward compatibility with versions of terminal.mod that don't
  # understand terminal_input
  terminal ${GRUB_TERMINAL_INPUT}
fi
EOF
  ;;
esac

case x${GRUB_TERMINAL_OUTPUT} in
 xgfxterm)
    # Make the font accessible
    prepare_grub_to_access_device `${grub_probe} --target=device ${GRUB_FONT_PATH}`

    cat << EOF
if loadfont `make_system_path_relative_to_its_root ${GRUB_FONT_PATH}` ; then
  set gfxmode=${GRUB_GFXMODE}
#  set gfxpayload=keep
  insmod gfxterm
  insmod ${GRUB_VIDEO_BACKEND}
  if terminal_output gfxterm ; then true ; else
    # For backward compatibility with versions of terminal.mod that don't
    # understand terminal_output
    terminal gfxterm
  fi
EOF
if [ x$GRUB_THEME != x ] && [ -f $GRUB_THEME ] \
        && is_path_readable_by_grub $GRUB_THEME; then
    echo "Found theme: $GRUB_THEME" >&2
    prepare_grub_to_access_device `${grub_probe} --target=device $GRUB_THEME` | sed -e "s/^/  /"
    cat << EOF
  insmod gfxmenu
  set theme=(\$root)`make_system_path_relative_to_its_root $GRUB_THEME`
  set menuviewer=gfxmenu
EOF
fi
    cat << EOF
fi
EOF
  ;;
  x)
    # Just use the native terminal
  ;;
  x*)
    cat << EOF
if terminal_output ${GRUB_TERMINAL_OUTPUT} ; then true ; else
  # For backward compatibility with versions of terminal.mod that don't
  # understand terminal_output
  terminal ${GRUB_TERMINAL_OUTPUT}
fi
EOF
  ;;
esac

# Gettext variables and module
if [ "x${LANG}" != "xC" ] ; then
    prepare_grub_to_access_device $(${grub_probe} --target=device ${locale_dir})
  cat << EOF
set locale_dir=(\$root)$(make_system_path_relative_to_its_root ${locale_dir})
set lang=${grub_lang}
insmod gettext
EOF
fi

if [ "x${GRUB_HIDDEN_TIMEOUT}" != "x" ] ; then
  if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then
    verbose=
  else
    verbose=" --verbose"
  fi
  cat << EOF
if sleep$verbose --interruptible ${GRUB_HIDDEN_TIMEOUT} ; then
  set timeout=${GRUB_TIMEOUT}
fi
EOF
else
  cat << EOF
set timeout=${GRUB_TIMEOUT}
EOF
fi

# Play an initial tune
if [ "x${GRUB_INIT_TUNE}" != "x" ] ; then
  cat << EOF
insmod play
play ${GRUB_INIT_TUNE}
EOF
fi

Dodane: Problem rozwiązany. KLIK
ODPOWIEDZ