GRUB (Italiano)

From ArchWiki

Jump to: navigation, search


Article summary
Copre vari aspetti del bootloader di default di Arch Linux, il GRand Unified Bootloader (GRUB).
Linguaggi disponibili
English
עברית
简体中文
Русский
Español
Italiano
Articoli collegati
Reinstalling GRUB (Italiano)
Grub configure examples
Grub-gfx
Image:Tango-preferences-desktop-locale.png This page was marked to be translated.
If you understand both "original" and "target" languages of this page, please help complete the translation.


Contents

Installare il pacchetto GRUB

Innanzitutto, andrà installato il pacchetto grub

pacman -Sy grub

Sarà necessario modificare poi il file menu.lst con le vostre impostazioni

nano /boot/grub/menu.lst

Nota: usare hd[a-z] per i dischi ide e sd[a-z] per i dischi scsi e sata

Eccone uno come esempio:

# Config file for GRUB - The GNU GRand Unified Bootloader
# /boot/grub/menu.lst

# DEVICE NAME CONVERSIONS 
#
#  Linux           Grub
# -------------------------
#  /dev/fd0        (fd0)
#  /dev/hda        (hd0)
#  /dev/hdb2       (hd1,1)
#  /dev/hda3       (hd0,2)
#

#  FRAMEBUFFER RESOLUTION SETTINGS
#     +-------------------------------------------------+
#          | 640x480    800x600    1024x768   1280x1024
#      ----+--------------------------------------------
#      256 | 0x301=769  0x303=771  0x305=773   0x307=775
#      32K | 0x310=784  0x313=787  0x316=790   0x319=793
#      64K | 0x311=785  0x314=788  0x317=791   0x31A=794
#      16M | 0x312=786  0x315=789  0x318=792   0x31B=795
#     +-------------------------------------------------+

# general configuration:
timeout   5
default   1
color light-blue/black light-cyan/blue
 
# boot sections follow
# each is implicitly numbered from 1 in the order of appearance below
#
# TIP: If you want a 1024x768 framebuffer, add "vga=773" to your kernel line.
#
#-*

# (0) Arch Linux
title  Arch Linux  [cpio]
root   (hd0,0)
kernel /boot/vmlinuz26 root=/dev/sda6 ro vga=773
initrd /boot/kernel26.img

title  Arch Linux  [thinkpad]
root   (hd0,0)
kernel /boot/vmlinuz26thinkpad root=/dev/sda6 ro video=vesafb:off acpi_sleep=s3_bios
resume=swap:/dev/sda5
initrd /boot/kernel26thinkpad.img

Copiate infine i mounts nell'mtab

grep -v rootfs /proc/mounts > /etc/mtab

Installare o ripristinare GRUB nel Master Boot Record

GRUB può essere installato direttamente dal sistema Arch in uso, oppure da un ambiente live.

In entrambi i casi, a sistema avviato digitare come root:

# grub

Si aprirà il prompt dei comandi di GRUB.

Specificare la partizione in cui si trova la directory /boot (solitamente la partizione contenente la directory radice del sistema, a meno che non si usi una partizione separata per /boot):

grub> root (hdx,y)

Per sapere in quale partizione si trova /boot è possibile usare il comando find.

Se /boot si trova nella stessa partizione di /, usare:

grub> find /boot/grub/stage1

Se /boot si trova in una partizione separata, usare:

grub> find /grub/stage1

Il risultato sarà simile al seguente:

(hd1,0)

Usare questo risultato con il comando root sopraindicato.

Infine, (re)installare GRUB in un boot sector del disco. Il seguente esempio installa GRUB nel MBR (Master Boot Record) del disco contenente /boot:

grub> setup (hd1)

Il prossimo esempio installa invece GRUB nel VBR (Volume Boot Record) della prima partizione (invece che nel MBR dell'intero disco):

grub> setup (hd1,0)

Per esempio è possibile avere un disco diviso in 4 partizioni, ognuna con un sistema operativo installato, e avere tre installazioni di GRUB in tre VBR diversi, con il quarto installato nel MBR. All'avvio del computer verrà caricato il quarto GRUB, che si trova nel MBR, e da questo si può avviare direttamente ognuno dei quattro sistemi operativi, oppure si può richiamare un altro GRUB fra i rimanenti tre installati nei VBR, grazie al cosiddetto chain loading.

Usare il comando quit per uscire dal prompt dei comandi di GRUB:

grub> quit

Configurazione del bootloader

La configurazione di grub è fatta mediante questo file:

/boot/grub/menu.lst
  • (hdn,m) indica la partizione m sul disco n, iniziando a numerare da 0
  • splashimage (hdn,m)/grub/Name.xpm.gz è il file immagine di splash
  • default n è la voce di boot predefinita, scelta al termine del tempo per la selezione da parte dell'utente
  • timeout m tempo m in secondi per effettuare una selezione, prima che sia lanciata la predefinita
  • password -md5 str password cifrata di boot 'str'
  • title str stringa di titolo 'str' per una voce di boot
  • root (hdn,m) partizione basilare, dove è alloggiato il kernel
  • kernel /path ro root=/dev/device initrd /initrd.img usare l'opzione root se il kernel non si trova in /
  • makeactive
    chainloader +1
    marca come attivo il root e da le procedure di caricamento al suo bootloader (ad es. Windows)
  • map (hd0) (hd1)
    map (hd1) (hd0)
    cambia dischi primari e secondari per il boot, necessario per lanciare Windows da un disco secondario
  • root (hdn,m,z)
    kernel /boot/loader
    lancia la partizione Free-BSD x
  • default saved ricorda ogni corrente selezione di boot e la rende la nuova predefinita. Mettere "savedefault" alla fine di ogni sezione di boot per le caratteristiche che si vogliono usare.

Per abbellire il tutto esiste anche Graphical GRUB.


Dual booting

Ci sono due modi molto diffusi di configurare il file menu.lst. Per usi più complessi vedasi qui.

Dual booting con Windows

Aggiungere questo alla fine di /boot/grub/menu.lst, assumendo che la partizione di Windows sia /dev/sda2.

# (2) Windows XP
title Windows XP
rootnoverify (hd0,1)
makeactive
chainloader +1

Da notare che, nonostante l'opinione comune, Windows 2000 e versioni successive non necessitano diessere le prime partizioni da caricare. Se la partizione di Windows cambia di numero (ad es. se è stata aggiunta una partizione prima di quella di Windows), sarà necessario modificare il file boot.ini di Windows per applicare le modifiche (vedasi questo articolo per i dettagli su come farlo).

Dual booting con Windows su un altro hard disk

Aggiungere questo alla fine di /boot/grub/menu.lst assumendo che la partizione di Windows sia /dev/sdb1.

# (2) Windows XP
title Windows XP
map (hd0) (hd1)
map (hd1) (hd0)
rootnoverify (hd1,0)
makeactive
chainloader +1

La funzione map inganna Windows facendogli credere che l'hard disk secondario sia il primario.

Dual booting con altre distribuzioni linux

Ciò è fatto allo stesso modo in cui Arch è caricato. Assumendo che l'altra distribuzione sia nella partizione /dev/sda3.

title Other Linux
root (hd0,2)
kernel /boot/vmlinuz (add other options here as required)
initrd /boot/initrd.img (if the other kernel uses/needs one)

Dual booting con un altra distribuzione linux (Chainloading)

Per evitare incubi di manutenzione, potreste voler sfruttare la funzione di chainload (caricamento a catena) nel GRUB installato nell'MBR per caricare un altro bootloader che potreste aver installato nel bootrecord di una partizione [(hd0,2) nell'esempio] invece che nell'MBR. Questo metodo permette eventualmente ad un altra distribuzione di gestire il "suo" GRUB tramite il menu.lst della propria partizione (sempre se si stia utilizzando GRUB) così da poterla caricare con tutte le opzioni necessarie (ad esempio, con il kernel più recente) senza dover andare a modificare il menu.lst "principale" copiando e incollando dei pezzi da quello secondario. Nell'esempio [1], GRUB è nell' MBR e un altro bootloader (BL) (che sia grub oppure lilo) è nel Boot Record della partizione (hd0,2).

-------------------------------------------------
|   |           |           |    %   (hd0,2)     |
| M |           |           | B  %               |
| B |  (hd0,0)  |  (hd0,1)  | L  %  Other        |
| R |           |           |    %  Distro       |
|   |           |           |    %               |
-------------------------------------------------
  |                            ^
  |     chainloading           |
  -----------------------------

Quindi, nel vostro menu.lst potreste semplicemente mettere una cosa tipo:

title Altra Distro Linux
root (hd0,2)
chainloader +1


Questo funziona anche al contrario: ad esempio se la root di Arch è (hd0,2)/sda2 e scegliete di installare il GRUB di Arch li dentro, invece che nell'MBR, poichè per voi Arch è la seconda distro che installate, il codice precedente andrà inserito nel menu.lst della distro principale che avete già sul sistema.

Tips and tricks

Restart with named boot choice

If you realize that you need to switch to some other non-default OS, e.g. Windows, having to reboot and wait for the GRUB menu to appear is tedious. GRUB offers a simple way to record your OS choice when restarting instead of waiting for the menu, simply by designating a temporary new default which will be reset (to the 'default default') as soon as it has been used.

Supposing a simple menu.lst setup like this:

# general configuration:
timeout   10
default 0
color light-blue/black light-cyan/blue

# (0) Arch
title  Arch Linux
root   (hd0,1)
kernel /boot/vmlinuz26 root=/dev/disk/by-uuid/a29113d7-2204-49e9-be69-d94699eba466 ro
initrd /boot/kernel26.img

# (1) Windows
title Microsoft Windows XP Pro
rootnoverify (hd0,0)
makeactive
chainloader +1

Arch is the default (0). We want to restart in to Windows. Change default to saved ("default saved") - this will record the current default in a 'default' file in the grub directory whenever the 'savedefault' grub command is used. Now add the line "savedefault 0" to the bottom of the Windows entry. Whenever Windows is booted, it will reset the default to Arch, thus making changing the default to Windows temporary.

Now all that is needed is a way to easily change the default 'manually'. This can be accomplsihed using the command 'grub-set-default [number of entry (starting with 0)]. So to reboot into Windows, enter the following command:

 sudo grub-set-default 1 && sudo shutdown -r now

For ease of use, you might to wish to implement the "Allow users to shutdown fix" (including /sbin/grub-set-default amongst the commands the user is allowed to issue without supplying a password).

Interazioni tra GRUB e LiLO

Se stavate usando lilo ricordatevi di rimuoverlo dando da terminale

pacman -R lilo

dato che alcune operazioni (ad es. compilazione kernel usando make all) chiameranno lilo, sovrascrivendolo su grub. Va notato che questo comando non rimuove lilo dallo MBR, esso sarà sovrascritto quando verrà installato un altro bootloader.

Framebuffer Resolution

One can use the resolution given in the menu.lst of grub. But you might want to use your LCD wide-screen at its full native resolution. Here is what you can do to achieve this.

On wikipedia, there is a list of extended framebuffer resolution (i.e beyond the ones in the VBE standard). But, for example, the one i want to use is 1440x900 and the vga=867 does not work. May be because those resolution are outside of the standard and every graphic card manufacturer use the code they like.

So instead of using that table, i suggest using this method:

How to find the correct code to use for the resolution you want to use

  1. install lrmi package from [community] repository
  2. run vbetest as root and in a console already running on framebuffer. It will not work in a terminal in X.
  3. then note the number in [ ] corresponding to your desired resolution
  4. Press 'q' to quit vbetest interactive prompt. If you want to test the resolution you have just picked up, you can run vbetest -m yournumberhere to test the resolution. You will see a checked colored image on your console. It will return to black after some second. If the text of your console is not restored you will have to switch to another console and switch back to have your text restored. (minor glitch)
  5. add 512 to the previous number and use the total as code to use in vga= kernel option in menu.lst.
  6. reboot and voilà !

For example, what i got with vbetest is :

[356] 1440x900 (256 color palette)
[357] 1440x900 (8:8:8)

so here the number i want is 357. then, 357 + 512 = 869, so i will use vga=869.

Now, you will have a console at the full native resolution of your screen. The next step is to use another font in console at a correct size. In my case i use terminus font named ter-120b

Note:

  • (8:8:8) is for 24-bit color (or 32-bit ?)
  • (5:6:5) is for 16-bit color
  • (5:5:5) is for 15-bit color

Troubleshooting

GRUB error 15

Assicuratevi che la linea del kernel abbia ro in menu.lst.

Reboot pulldown menu in KDE does not have any effect

If you've opened a submenu with the list of all operating system configured in grub, selected one and upon restart you still got your default OS, then you might want to check if you have line

default   saved

in file /boot/grub/menu.lst.

External Resources

Personal tools