Sie sind auf Seite 1von 37

1/11/14

GRUB - ArchWiki

GRUB
From ArchWiki GRUB (https://www.gnu.org/software/grub/) - not to be confused with GRUB Related articles Legacy - is the next generation of the GRand Unified Bootloader. GRUB is derived from PUPA (http://www.nongnu.org/pupa/) which was a research project to develop Arch Boot Process the next generation of what is now GRUB Legacy. GRUB has been rewritten from Boot Loaders scratch to clean up everything and provide modularity and portability [1] (https://www.gnu.org/software/grub/grub-faq.html#q1). Master Boot Record In brief, the bootloader is the first software program that runs when a computer starts. It is responsible for loading and transferring control to the Linux kernel. The kernel, in turn, initializes the rest of the operating system. GUID Partition Table Unified Extensible Firmware Interface GRUB EFI Examples

Contents
1 Preface 1.1 Notes for GRUB Legacy users 1.1.1 Backup important data 1.2 Preliminary requirements 1.2.1 BIOS systems 1.2.1.1 GUID Partition Table (GPT) specific instructions 1.2.1.2 Master Boot Record (MBR) specific instructions 1.2.2 UEFI systems 1.2.2.1 Check if you have GPT and an ESP 1.2.2.2 Create an ESP 2 Installation 2.1 BIOS systems 2.1.1 Install boot files 2.1.1.1 Install to disk 2.1.1.2 Install to partition or partitionless disk 2.1.1.3 Generate core.img alone 2.2 UEFI systems 2.2.1 Install boot files 2.2.1.1 Recommended method 2.2.1.2 Alternative method 2.2.2 Create a GRUB entry in the firmware boot manager 2.2.3 GRUB Standalone 2.2.3.1 GRUB Standalone - Technical Info 3 Generating main configuration file 3.1 Converting GRUB Legacy's config file to the new format 4 Basic configuration 4.1 Additional arguments

https://wiki.archlinux.org/index.php/GRUB

1/37

1/11/14

GRUB - ArchWiki

4.2 Visual configuration 4.2.1 Setting the framebuffer resolution 4.2.2 915resolution hack 4.2.3 Background image and bitmap fonts 4.2.4 Theme 4.2.5 Menu colors 4.2.6 Hidden menu 4.2.7 Disable framebuffer 4.3 Persistent block device naming 4.4 Recall previous entry 4.5 Changing the default menu entry 4.6 Root encryption 4.7 Boot non-default entry only once 5 Advanced configuration 5.1 Manually creating grub.cfg 5.2 Dual-booting 5.2.1 Automatically generating using /etc/grub.d/40_custom and grub-mkconfig 5.2.1.1 GNU/Linux menu entry 5.2.1.2 FreeBSD menu entry 5.2.1.3 Windows XP menu entry 5.2.1.4 Windows Installed in UEFI-GPT Mode menu entry 5.2.1.5 "Shutdown" menu entry 5.2.1.6 "Restart" menu entry 5.2.1.7 Windows installed in BIOS-MBR mode 5.2.2 With Windows via EasyBCD and NeoGRUB 5.3 Booting an ISO directly from GRUB 5.3.1 Arch ISO 5.3.1.1 x86_64 5.3.1.2 i686 5.3.2 Ubuntu ISO 5.3.3 Other ISOs 5.4 LVM 5.5 RAID 5.6 Using labels 5.7 Password protection of GRUB menu 5.8 Hide GRUB unless the Shift key is held down 5.9 Combining the use of UUIDs and basic scripting 6 Using the command shell 6.1 Pager support 6.2 Using the command shell environment to boot operating systems 6.2.1 Chainloading a partition 6.2.2 Chainloading a disk/drive 6.2.3 Normal loading 7 GUI configuration tools 8 parttool for hide/unhide 9 Using the rescue console 10 Troubleshooting 10.1 Intel BIOS not booting GPT

https://wiki.archlinux.org/index.php/GRUB

2/37

1/11/14

GRUB - ArchWiki

10.2 Enable debug messages 10.3 "No suitable mode found" error 10.4 msdos-style error message 10.5 GRUB UEFI drops to shell 10.6 GRUB UEFI not loaded 10.7 Invalid signature 10.8 Boot freezes 10.9 Restore GRUB Legacy 10.10 Arch not found from other OS 10.11 Out of memory/Syntax error running grub-mkconfig 11 See also

Preface
The name GRUB officially refers to version 2 of the software, see [2] (https://www.gnu.org/software/grub/). If you are looking for the article on the legacy version, see GRUB Legacy. GRUB supports Btrfs as root (without a separate / b o o t filesystem) compressed with either zlib or LZO GRUB does not support F2fs as root so you will need a separate / b o o t with a supported filesystem.

Notes for GRUB Legacy users


Upgrading from GRUB Legacy to GRUB is much the same as freshly installing GRUB. This topic is covered here. There are differences in the commands of GRUB Legacy and GRUB. Familiarize yourself with GRUB commands (https://www.gnu.org/software/grub/manual/grub.html#Commands) before proceeding (e.g. "find" has been replaced with "search"). GRUB is now modular and no longer requires "stage 1.5". As a result, the bootloader itself is limited -modules are loaded from the hard drive as needed to expand functionality (e.g. for LVM or RAID support). Device naming has changed between GRUB Legacy and GRUB. Partitions are numbered from 1 instead of 0 while drives are still numbered from 0, and prefixed with partition-table type. For example, / d e v / s d a 1 would be referred to as ( h d 0 , m s d o s 1 ) (for MBR) or ( h d 0 , g p t 1 ) (for GPT). GRUB is noticeably bigger than GRUB legacy (occupies ~13 MB in / b o o t). If you are booting from a separate / b o o t partition, and this partition is smaller than 32 MB, you will run into disk space issues, and pacman will refuse to install new kernels. Backup important data Although a GRUB installation should run smoothly, it is strongly recommended to keep the GRUB Legacy files before upgrading to GRUB v2.
#m v/ b o o t / g r u b/ b o o t / g r u b l e g a c y

Backup the MBR which contains the boot code and partition table (replace / d e v / s d X with your actual disk path):

https://wiki.archlinux.org/index.php/GRUB

3/37

1/11/14

GRUB - ArchWiki

#d di f = / d e v / s d Xo f = / p a t h / t o / b a c k u p / m b r _ b a c k u pb s = 5 1 2c o u n t = 1

Only 446 bytes of the MBR contain boot code, the next 64 contain the partition table. If you do not want to overwrite your partition table when restoring, it is strongly advised to backup only the MBR boot code:
#d di f = / d e v / s d Xo f = / p a t h / t o / b a c k u p / b o o t c o d e _ b a c k u pb s = 4 4 6c o u n t = 1

If unable to install GRUB2 correctly, see Restore GRUB Legacy.

Preliminary requirements
BIOS systems
GUID Partition Table (GPT) specific instructions

GRUB in BIOS-GPT configuration requires a BIOS boot partition (http://www.gnu.org/software/grub/manual/html_node/BIOS-installation.html) to embed its c o r e . i m g in the absence of post-MBR gap in GPT partitioned systems (which is taken over by the GPT Primary Header and Primary Partition table). This partition is used by GRUB only in BIOS-GPT setups. No such partition type exists in case of MBR partitioning (at least not for GRUB). This partition is also not required if the system is UEFI based, as no embedding of bootsectors takes place in that case. For a BIOS-GPT configuration, create a 1007 KiB partition at the beginning of the disk using gdisk, cgdisk or GNU Parted with no filesystem. The size of 1007 KiB, plus the size of the preceding GPT of 17 KiB, will allow for the following partition to be correctly aligned at 1024 KiB. If needed, the partition can also be located somewhere else on the disk, but it should be within the first 2 TiB region. Set the partition type to e f 0 2 in (c)gdisk or s e tB O O T _ P A R T _ N U Mb i o s _ g r u bo n in GNU Parted. The GPT partition also creates a protective MBR partition to stop unsupported tools from modifying it. You may need to set a bootable flag on this protective MBR e.g., using cfdisk, or some BIOSes/EFIs will refuse to boot. Note: You will probably need to explicitly set the g r u b i n s t a l l target to i 3 8 6 p c using t a r g e t = i 3 8 6 p c. Otherwise g r u b i n s t a l l sometimes guesses that your configuration is EFIGPT. This partition should be created before g r u b i n s t a l l or g r u b s e t u p is run gdisk will only allow you to create this partition on the position which will waste the least amount of space (sector 34-2047) if you create it last, after all the other partitions. This is because gdisk will auto-align partitions to 2048-sector boundaries if possible

Master Boot Record (MBR) specific instructions

https://wiki.archlinux.org/index.php/GRUB

4/37

1/11/14

GRUB - ArchWiki

Usually the post-MBR gap (after the 512 byte MBR region and before the start of the 1st partition) in many MBR (or msdos disklabel) partitioned systems is 31 KiB when DOS compatibility cylinder alignment issues are satisfied in the partition table. However a post-MBR gap of about 1 to 2 MiB is recommended to provide sufficient room for embedding GRUB's c o r e . i m g (FS#24103 (https://bugs.archlinux.org/task/24103)). It is advisable to use a partitioner which supports 1 MiB partition alignment to obtain this space as well as satisfy other non-512 byte sector issues (which are unrelated to embedding of c o r e . i m g). UEFI systems Note: It is recommended to read and understand the UEFI, GPT and UEFI Bootloaders pages.
Check if you have GPT and an ESP

An EFI System Partition (ESP) is needed on every disc you wan to boot using EFI. GPT is not strictly necessary, but it is highly recommended and is the only method currently supported in this article. If you are installing Archlinux on an EFI-capable computer with an already-working operating system, like Windows 8 for example, it is very likely that you already have an ESP. To check for GPT and for an ESP, use p a r t e d as root to print the partition table of the disk you want to boot from. (We are calling it /dev/sda.)
#p a r t e d/ d e v / s d ap r i n t

For GPT, you are looking for "Partition Table: GPT". For EFI, you are looking for a small (512 MiB or less) partition with a vfat filesystem and the 'boot' flag enabled. On it, there should be a folder called "EFI". If these criteria are met, this is your ESP. Make note of the partition number. You will need to know which one it is so you can mount it later on while installing GRUB to it.
Create an ESP

If you do not have an ESP, you will need to create it. Follow UEFI#EFI System Partition for instructions on creating an ESP.

Installation
Note: If you are performing an initial installation from the Arch live CD, make sure you have chrooted into the installed system before installing grub. Using the CD's own grub installation scripts may result in an invalid g r u b . c f g, or other problems that will prevent the system from booting.

BIOS systems
GRUB can be installed with the g r u b( h t t p s : / / w w w . a r c h l i n u x . o r g / p a c k a g e s / ? n a m e = g r u b )package from the official repositories. It will replace g r u b l e g a c y( h t t p s : / / a u r . a r c h l i n u x . o r g / p a c k a g e s / g r u b l e g a c y / ), if it is installed.

https://wiki.archlinux.org/index.php/GRUB

5/37

1/11/14

GRUB - ArchWiki

Note: Simply installing the package will not update the / b o o t / g r u b / i 3 8 6 p c / c o r e . i m g file and the GRUB modules in / b o o t / g r u b / i 3 8 6 p c. You need to update them manually using g r u b i n s t a l l as explained below. Install boot files There are 3 ways to install GRUB boot files in BIOS booting: Install to disk (recommended) Install to partition or partitionless disk (not recommended) Generate core.img alone (safest method, but requires another BIOS bootloader like Syslinux to be installed to chainload / b o o t / g r u b / i 3 8 6 p c / c o r e . i m g) Note: See http://www.gnu.org/software/grub/manual/html_node/BIOS-installation.html for additional documentation.
Install to disk

Note: The method is specific to installing GRUB to a partitioned (MBR or GPT) disk, with GRUB files installed to / b o o t / g r u b and its first stage code installed to the 440-byte MBR boot code region (not to be confused with MBR partition table). For partitionless disk (super-floppy) please refer to #Install to partition or partitionless disk To setup g r u b in the 440-byte Master Boot Record boot code region, populate the / b o o t / g r u b directory, generate the / b o o t / g r u b / i 3 8 6 p c / c o r e . i m g file, and embed it in the 31 KiB (minimum size - varies depending on partition alignment) post-MBR gap in case of MBR partitioned disk (or BIOS Boot Partition in case of GPT partitioned disk, denoted by b i o s _ g r u b flag in parted and EF02 type code in gdisk), run:
#g r u b i n s t a l lt a r g e t = i 3 8 6 p cr e c h e c kd e b u g/ d e v / s d a

Note: install for BIOS systems only. It is recommended to always use this option to remove ambiguity in grub-install. If you use LVM for your / b o o t, you can install GRUB on multiple physical disks.
Install to partition or partitionless disk
/ d e v / s d a used for example only. t a r g e t = i 3 8 6 p c instructs g r u b i n s t a l l to

Note: GRUB does not encourage installation to a partition boot sector or a partitionless disk like GRUB Legacy or Syslinux does. This kind of setup is prone to breakage, especially during updates, and is not supported by Arch devs.

https://wiki.archlinux.org/index.php/GRUB

6/37

1/11/14

GRUB - ArchWiki

To set up grub to a partition boot sector, to a partitionless disk (also called superfloppy) or to a floppy disk, run (using for example / d e v / s d a X as the / b o o t partition):
#c h a t t ri/ b o o t / g r u b / i 3 8 6 p c / c o r e . i m g #g r u b i n s t a l lt a r g e t = i 3 8 6 p cr e c h e c kd e b u gf o r c e/ d e v / s d a X #c h a t t r+ i/ b o o t / g r u b / i 3 8 6 p c / c o r e . i m g

Note: install for BIOS systems only. It is recommended to always use this option to remove ambiguity in grub-install. You need to use the f o r c e option to allow usage of blocklists and should not use g r u b s e t u p = / b i n / t r u e (which is similar to simply generating c o r e . i m g).
g r u b i n s t a l l will give out warnings like which should / d e v / s d a X used for example only. t a r g e t = i 3 8 6 p c instructs g r u b i n s t a l l to

give you the idea of what might go wrong with this

approach:

/ s b i n / g r u b s e t u p :w a r n :A t t e m p t i n gt oi n s t a l lG R U Bt oap a r t i t i o n l e s sd i s ko rt oap a r t i t i o n .T h i si sa / s b i n / g r u b s e t u p :w a r n :E m b e d d i n gi sn o tp o s s i b l e .G R U Bc a no n l yb ei n s t a l l e di nt h i ss e t u pb yu s i n gb l o H o w e v e r ,b l o c k l i s t sa r eU N R E L I A B L Ea n dt h e i ru s ei sd i s c o u r a g e d .

Without f o r c e you may get the below error and g r u b s e t u p will not setup its boot code in the partition boot sector:
/ s b i n / g r u b s e t u p :e r r o r :w i l ln o tp r o c e e dw i t hb l o c k l i s t s

With f o r c e you should get:


I n s t a l l a t i o nf i n i s h e d .N oe r r o rr e p o r t e d .

The reason why g r u b s e t u p does not by default allow this is because in case of partition or a partitionless disk is that g r u b relies on embedded blocklists in the partition bootsector to locate the / b o o t / g r u b / i 3 8 6 p c / c o r e . i m g file and the prefix dir / b o o t / g r u b. The sector locations of c o r e . i m g may change whenever the filesystem in the partition is being altered (files copied, deleted etc.). For more info see https://bugzilla.redhat.com/show_bug.cgi?id=728742 and https://bugzilla.redhat.com/show_bug.cgi?id=730915. The workaround for this is to set the immutable flag on / b o o t / g r u b / i 3 8 6 p c / c o r e . i m g (using chattr command as mentioned above) so that the sector locations of the c o r e . i m g file in the disk is not altered. The immutable flag on / b o o t / g r u b / i 3 8 6 p c / c o r e . i m g needs to be set only if g r u b is installed to a partition boot

https://wiki.archlinux.org/index.php/GRUB

7/37

1/11/14

GRUB - ArchWiki

o r e . i m g without sector or a partitionless disk, not in case of installation to MBR or simple generation of c embedding any bootsector (mentioned above).

Generate core.img alone

To populate the / b o o t / g r u b directory and generate a / b o o t / g r u b / i 3 8 6 p c / c o r e . i m g file without embedding any g r u b bootsector code in the MBR, post-MBR region, or the partition bootsector, add g r u b s e t u p = / b i n / t r u e to g r u b i n s t a l l:
#g r u b i n s t a l lt a r g e t = i 3 8 6 p cg r u b s e t u p = / b i n / t r u er e c h e c kd e b u g/ d e v / s d a

Note: install for BIOS systems only. It is recommended to always use this option to remove ambiguity in grub-install. You can then chainload GRUB's c o r e . i m g from GRUB Legacy or syslinux as a Linux kernel or as a multiboot kernel.
/ d e v / s d a used for example only. t a r g e t = i 3 8 6 p c instructs g r u b i n s t a l l to

UEFI systems
Note: It is well known that different motherboard manufactures implement UEFI differently. Users experiencing problems getting GRUB or EFI to work properly are encouraged to share detailed steps for hardware-specific cases where UEFI booting does not work as described below. In an effort to keep the parent GRUB article neat and tidy, see the GRUB EFI Examples page for these special cases. First install the g r u b( h t t p s : / / w w w . a r c h l i n u x . o r g / p a c k a g e s / ? n a m e = g r u b ) ,d o s f s t o o l s ( h t t p s : / / w w w . a r c h l i n u x . o r g / p a c k a g e s / ? n a m e = d o s f s t o o l s ) , and e f i b o o t m g r ( h t t p s : / / w w w . a r c h l i n u x . o r g / p a c k a g e s / ? n a m e = e f i b o o t m g r )packages, then follow the instructions below. (The last two packages are required for EFI support in grub.) Note: Simply installing the package will not update the c o r e . e f i file and the GRUB modules in the ESP. You need to do this manually using g r u b i n s t a l l as explained below. Install boot files
Recommended method

Note: The below commands assume you are using installing GRUB for x 8 6 _ 6 4 e f i (for I A 3 2 e f i replace x 8 6 _ 6 4 e f i with i 3 8 6 e f i in the below commands)

https://wiki.archlinux.org/index.php/GRUB

8/37

1/11/14

GRUB - ArchWiki

To do this, you need to be booted using UEFI and not BIOS, or grub-install will show errors. First, mount the ESP at your preferred mountpoint (usually / b o o t / e f i, hereafter referred to as $esp). On a first install, you will need to mkdir /boot/efi, if that's where you want to mount it. Now, install the GRUB UEFI application to $ e s p / E F I / g r u b and its modules to / b o o t / g r u b / x 8 6 _ 6 4 e f i:
#g r u b i n s t a l lt a r g e t = x 8 6 _ 6 4 e f ie f i d i r e c t o r y = $ e s pb o o t l o a d e r i d = g r u br e c h e c kd e b u g

Note: If you have a problem when running grub-install with sysfs or procfs and it says you have to "modprobe efivars", try Unified_Extensible_Firmware_Interface#Switch_to_efivarfs. Without t a r g e t or d i r e c t o r y option, grub-install cannot determine for which firmware to install. In such cases g r u b i n s t a l l will print s o u r c e _ d i rd o e sn o te x i s t .P l e a s es p e c i f yt a r g e to rd i r e c t o r y. e f i d i r e c t o r y and b o o t l o a d e r i d are specific to GRUB UEFI. e f i d i r e c t o r y specifies the mountpoint of the ESP. It replaces r o o t d i r e c t o r y, which is deprecated. b o o t l o a d e r i d specifies the name of the directory used to store the g r u b x 6 4 . e f i file. If you notice carefully, there is no <device_path> option (Eg: / d e v / s d a) at the end of the g r u b i n s t a l l command unlike the case of setting up GRUB for BIOS systems. Any <device_path> provided will be ignored by the install script, as UEFI bootloaders do not use MBR or Partition boot sectors at all. GRUB is now installed.
Alternative method

If you want to keep all of the GRUB boot files inside the EFI System Partition itself, add b o o t d i r e c t o r y = $ e s p / E F I to the grub-install command:

#g r u b i n s t a l lt a r g e t = x 8 6 _ 6 4 e f ie f i d i r e c t o r y = $ e s pb o o t l o a d e r i d = g r u bb o o t d i r e c t o r y = $ e s p / E F I-

This puts the GRUB modules in $ e s p / E F I / g r u b. ('/grub' is hard coded onto the end of this path.) Using this method, grub.cfg is kept on the EFI System Partition as well, so make sure you point grub-mkconfig to the right place in the configuration phase:
#g r u b m k c o n f i go$ e s p / E F I / g r u b / g r u b . c f g

Configuration is otherwise the same. Create a GRUB entry in the firmware boot manager

https://wiki.archlinux.org/index.php/GRUB

9/37

1/11/14

GRUB - ArchWiki

create a menu entry in the boot manager. If it does not, then see Beginners' Guide#GRUB for instructions to use e f i b o o t m g r to create a menu entry. However, the problem is likely to be that you have not booted your CD/USB in UEFI mode, as in UEFI#Create UEFI bootable USB from ISO. GRUB Standalone Note: Use g r u b g i t( h t t p s : / / a u r . a r c h l i n u x . o r g / p a c k a g e s / g r u b g i t / )pkg for standalone GRUB EFI image as the g r u b( h t t p s : / / w w w . a r c h l i n u x . o r g / p a c k a g e s / ? n a m e = g r u b )pkg does not contain various grub-mkstandalone specific fixes (specifically $ { c m d p a t h } support, which is necessary). It is possible to create a g r u b x 6 4 _ s t a n d a l o n e . e f i application which has all the modules embedded in a tar archive within the UEFI application, thus removing the need for having a separate directory populated with all the GRUB UEFI modules and other related files. This is done using the g r u b m k s t a n d a l o n e command (included in g r u b( h t t p s : / / w w w . a r c h l i n u x . o r g / p a c k a g e s / ? n a m e = g r u b ) ) as follows"

g r u b i n s t a l l automatically tries to

#e c h o' c o n f i g f i l e$ { c m d p a t h } / g r u b . c f g '>/ t m p / g r u b . c f g # #u s es i n g l eq u o #g r u b m k s t a n d a l o n ed/ u s r / l i b / g r u b / x 8 6 _ 6 4 e f i /Ox 8 6 _ 6 4 e f im o d u l e s = " p a r t _ g p tp a r t _ m s d o s "f o n t s = "

Note: The option m o d u l e s = " p a r t _ g p tp a r t _ m s d o s " (with the quotes) is necessary for $ { c m d p a t h } feature to work properly. Then copy the GRUB config file to $ e s p / E F I / g r u b / g r u b . c f g and create a UEFI Boot Manager entry for $ e s p / E F I / g r u b / g r u b x 6 4 _ s t a n d a l o n e . e f i using efibootmgr.
GRUB Standalone - Technical Info

The GRUB EFI file always expects its config file to be at $ { p r e f i x } / g r u b . c f g. However in the standalone GRUB EFI file, the $ { p r e f i x } is located inside a tar archive and embedded inside the standalone GRUB EFI file itself (inside grub env it is denoted by " ( m e m d i s k ) ", without quotes). This tar archive contains all the files that would be stored normally at / b o o t / g r u b in case of a normal GRUB EFI install. Due to this embedding of / b o o t / g r u b contents inside the standalone image itself, it does not rely on actual (external) / b o o t / g r u b for anything. Thus in case of standalone GRUB EFI file $ { p r e f i x } = = ( m e m d i s k ) / b o o t / g r u b and the standalone GRUB EFI file reads expects the config file to be at $ { p r e f i x } / g r u b . c f g = = ( m e m d i s k ) / b o o t / g r u b / g r u b . c f g. Hence to make sure the standalone GRUB EFI file reads the external g r u b . c f g located in the same dir as the EFI file (inside grub env it is denoted by $ { c m d p a t h }), we create a simple / t m p / g r u b . c f g which instructs GRUB to use $ { c m d p a t h } / g r u b . c f g as its config ( c o n f i g f i l e$ { c m d p a t h } / g r u b . c f g command in ( m e m d i s k ) / b o o t / g r u b / g r u b . c f g). We then instruct grub-mkstandalone to copy this / t m p / g r u b . c f g file to $ { p r e f i x } / g r u b . c f g (which is actually ( m e m d i s k ) / b o o t / g r u b / g r u b . c f g) using the option " / b o o t / g r u b / g r u b . c f g = / t m p / g r u b . c f g ".

https://wiki.archlinux.org/index.php/GRUB

10/37

1/11/14

GRUB - ArchWiki

This way the standalone GRUB EFI file and actual g r u b . c f g can be stored in any dir inside the EFI System Partition (as long as they are in the same dir), thus making them portable.

Generating main configuration file


After the installation, the main configuration file g r u b . c f g needs to be generated. The generation process can be influenced by a variety of options in / e t c / d e f a u l t / g r u b and scripts in / e t c / g r u b . d /, this is covered in the #Basic configuration and #Advanced configuration sections. Note: Remember that g r u b . c f g has to be re-generated after any change to / e t c / d e f a u l t / g r u b or / e t c / g r u b . d / *. Use the grub-mkconfig tool to generate g r u b . c f g:
#g r u b m k c o n f i go/ b o o t / g r u b / g r u b . c f g

Note: The file path for BIOS systems is / b o o t / g r u b / g r u b . c f g, NOT / b o o t / g r u b / i 3 8 6 p c / g r u b . c f g. For EFI systems, if GRUB was installed with the b o o t d i r e c t o r y = $ e s p / E F I option set, the g r u b . c f g file must be placed in the same directory as g r u b x 6 4 . e f i. Otherwise, the g r u b . c f g file goes in / b o o t / g r u b /, just like in BIOS systems. If you are trying to run grub-mkconfig in a chroot or systemd-nspawn container, you might notice that it does not work, complaining that grub-probe cannot get the "canonical path of /dev/sdaX". In this case, try using arch-chroot as described here (https://bbs.archlinux.org/viewtopic.php?pid=1225067#p1225067). By default the generation scripts automatically add menu entries for Arch Linux to any generated configuration. However, entries for other operating systems do not work out of the box. On BIOS systems, you may want to install o s p r o b e r( h t t p s : / / w w w . a r c h l i n u x . o r g / p a c k a g e s / ? n a m e = o s p r o b e r ) , which detects other operating systems installed on your machine and adds entries for them into g r u b . c f g. If installed, it will be executed when running grub-mkconfig. See #Dual-booting for advanced configuration.

Converting GRUB Legacy's config file to the new format


If g r u b m k c o n f i g fails, convert your / b o o t / g r u b / m e n u . l s t file to / b o o t / g r u b / g r u b . c f g using:
#g r u b m e n u l s t 2 c f g/ b o o t / g r u b / m e n u . l s t/ b o o t / g r u b / g r u b . c f g

Note: This option works only in BIOS systems, not in UEFI systems. For example:

https://wiki.archlinux.org/index.php/GRUB

11/37

1/11/14

GRUB - ArchWiki

/ b o o t / g r u b / m e n u . l s t d e f a u l t = 0 t i m e o u t = 5 t i t l e r o o t k e r n e l i n i t r d t i t l e r o o t k e r n e l i n i t r d A r c hL i n u xS t o c kK e r n e l ( h d 0 , 0 ) / v m l i n u z l i n u xr o o t = / d e v / s d a 2r o / i n i t r a m f s l i n u x . i m g A r c hL i n u xS t o c kK e r n e lF a l l b a c k ( h d 0 , 0 ) / v m l i n u z l i n u xr o o t = / d e v / s d a 2r o / i n i t r a m f s l i n u x f a l l b a c k . i m g

/ b o o t / g r u b / g r u b . c f g s e td e f a u l t = ' 0 ' ;i f[x " $ d e f a u l t "=x s a v e d] ;t h e nl o a d _ e n v ;s e td e f a u l t = " $ s a v e d _ e n t r y " ;f i s e tt i m e o u t = 5 m e n u e n t r y' A r c hL i n u xS t o c kK e r n e l '{ s e tr o o t = ' ( h d 0 , 1 ) ' ;s e tl e g a c y _ h d b i a s = ' 0 ' l e g a c y _ k e r n e l ' / v m l i n u z l i n u x '' / v m l i n u z l i n u x '' r o o t = / d e v / s d a 2 '' r o ' l e g a c y _ i n i t r d' / i n i t r a m f s l i n u x . i m g '' / i n i t r a m f s l i n u x . i m g ' } m e n u e n t r y' A r c hL i n u xS t o c kK e r n e lF a l l b a c k '{ s e tr o o t = ' ( h d 0 , 1 ) ' ;s e tl e g a c y _ h d b i a s = ' 0 ' l e g a c y _ k e r n e l ' / v m l i n u z l i n u x '' / v m l i n u z l i n u x '' r o o t = / d e v / s d a 2 '' r o ' l e g a c y _ i n i t r d' / i n i t r a m f s l i n u x f a l l b a c k . i m g '' / i n i t r a m f s l i n u x f a l l b a c k . i m g ' }

If you forgot to create a GRUB / b o o t / g r u b / g r u b . c f g config file and simply rebooted into GRUB Command Shell, type:
s h : g r u b >i n s m o dl e g a c y c f g s h : g r u b >l e g a c y _ c o n f i g f i l e$ { p r e f i x } / m e n u . l s t

Boot into Arch and re-create the proper GRUB / b o o t / g r u b / g r u b . c f g config file.

Basic configuration
This section covers only editing the / e t c / d e f a u l t / g r u b configuration file. See #Advanced configuration if you need more. Note: Remember to always re-generate the main configuration file after you make changes to / e t c / d e f a u l t / g r u b. Additional arguments

https://wiki.archlinux.org/index.php/GRUB

12/37

1/11/14

GRUB - ArchWiki

To pass custom additional arguments to the Linux image, you can set the G R U B _ C M D L I N E _ L I N U X+ G R U B _ C M D L I N E _ L I N U X _ D E F A U L T variables in / e t c / d e f a u l t / g r u b. The two are appended to each other and passed to kernel when generating regular boot entries. For the recovery boot entry, only G R U B _ C M D L I N E _ L I N U X is used in the generation. It is not necessary to use both, but can be useful. For example, you could use G R U B _ C M D L I N E _ L I N U X _ D E F A U L T = " r e s u m e = / d e v / s d a Xq u i e t " where s d a X is your swap partition to enable resume after hibernation. This would generate a recovery boot entry without the resume and without quiet suppressing kernel messages during a boot from that menu entry. Though, the other (regular) menu entries would have them as options. For generating the GRUB recovery entry you also have to comment out # G R U B _ D I S A B L E _ R E C O V E R Y = t r u e in / e t c / d e f a u l t / g r u b. You can also use G R U B _ C M D L I N E _ L I N U X = " r e s u m e = / d e v / d i s k / b y u u i d / $ { s w a p _ u u i d } ", where $ { s w a p _ u u i d } is the UUID of your swap partition. Multiple entries are separated by spaces within the double quotes. So, for users who want both resume and systemd it would look like this:
G R U B _ C M D L I N E _ L I N U X = " r e s u m e = / d e v / s d a Xi n i t = / u s r / l i b / s y s t e m d / s y s t e m d "

See Kernel parameters for more info.

Visual configuration
In GRUB it is possible, by default, to change the look of the menu. Make sure to initialize, if not done already, GRUB graphical terminal, gfxterm, with proper video mode, gfxmode, in GRUB. This can be seen in the section #"No suitable mode found" error. This video mode is passed by GRUB to the linux kernel via 'gfxpayload' so any visual configurations need this mode in order to be in effect. Setting the framebuffer resolution GRUB can set the framebuffer for both GRUB itself and the kernel. The old v g a = way is deprecated. The preferred method is editing / e t c / d e f a u l t / g r u b as the following sample:
G R U B _ G F X M O D E = 1 0 2 4 x 7 6 8 x 3 2 G R U B _ G F X P A Y L O A D _ L I N U X = k e e p

To generate the changes, run:


#g r u b m k c o n f i go/ b o o t / g r u b / g r u b . c f g

The g f x p a y l o a d property will make sure the kernel keeps the resolution.

https://wiki.archlinux.org/index.php/GRUB

13/37

1/11/14

GRUB - ArchWiki

Note: If this example does not work for you try to replace g f x m o d e = " 1 0 2 4 x 7 6 8 x 3 2 " by v b e m o d e = " 0 x 1 0 5 " . Remember to replace the specified resolution with one suitable for your screen To show all the modes you can use # h w i n f of r a m e b u f f e r (hwinfo is available in [community]), while at GRUB prompt you can use the v b e i n f o command If this method does not work for you, the deprecated v g a = method will still work. Just add it next to the " G R U B _ C M D L I N E _ L I N U X _ D E F A U L T = " line in / e t c / d e f a u l t / g r u b for eg: " G R U B _ C M D L I N E _ L I N U X _ D E F A U L T = " q u i e ts p l a s hv g a = 7 9 2 " will give you a 1 0 2 4 x 7 6 8 resolution. You can choose one of these resolutions: 6 4 0 4 8 0, 8 0 0 6 0 0, 1 0 2 4 7 6 8, 1 2 8 0 1 0 2 4, 1 6 0 0 1 2 0 0,
1 9 2 0 1 2 0 0

915resolution hack Some times for Intel graphic adapters neither # h w i n f of r a m e b u f f e r nor v b e i n f o will show you the desired resolution. In this case you can use 9 1 5 r e s o l u t i o n hack. This hack will temporarily modify video BIOS and add needed resolution. See 915resolution's home page (http://915resolution.mango-lang.org/) First you need to find a video mode which will be modified later. For that we need the GRUB command shell:
s h : g r u b >9 1 5 r e s o l u t i o nl I n t e l8 0 0 / 9 0 0S e r i e sV B I O SH a c k:v e r s i o n0 . 5 . 3 [ . . . ] M o d e3 0:6 4 0 x 4 8 0 ,8b i t s / p i x e l [ . . . ]

Next, we overwrite the M o d e3 0 with 1 4 4 0 x 9 0 0 resolution:


/ e t c / g r u b . d / 0 0 _ h e a d e r [ . . . ] 9 1 5 r e s o l u t i o n3 01 4 4 09 0 0 #I n s e r t e dl i n e s e tg f x m o d e = $ { G R U B _ G F X M O D E } [ . . . ]

Lastly we need to set G R U B _ G F X M O D E as described earlier, regenerate g r u b . c f g and reboot to test changes. Background image and bitmap fonts GRUB comes with support for background images and bitmap fonts in p f 2 format. The unifont font is included in the g r u b( h t t p s : / / w w w . a r c h l i n u x . o r g / p a c k a g e s / ? n a m e = g r u b )package under the filename u n i c o d e . p f 2, or, as only ASCII characters under the name a s c i i . p f 2.

https://wiki.archlinux.org/index.php/GRUB

14/37

1/11/14

GRUB - ArchWiki

Image formats supported include tga, png and jpeg, providing the correct modules are loaded. The maximum supported resolution depends on your hardware. Make sure you have set up the proper framebuffer resolution. Edit / e t c / d e f a u l t / g r u b like this:
G R U B _ B A C K G R O U N D = " / b o o t / g r u b / m y i m a g e " # G R U B _ T H E M E = " / p a t h / t o / g f x t h e m e " G R U B _ F O N T = " / p a t h / t o / f o n t . p f 2 "

Note: If you have installed GRUB on a separate partition, / b o o t / g r u b / m y i m a g e becomes / g r u b / m y i m a g e . Re-generate g r u b . c f g to apply the changes. If adding the splash image was successful, the user will see " F o u n db a c k g r o u n di m a g e . . . " in the terminal as the command is executed. If this phrase is not seen, the image information was probably not incorporated into the g r u b . c f g file. If the image is not displayed, check: The path and the filename in / e t c / d e f a u l t / g r u b are correct The image is of the proper size and format (tga, png, 8-bit jpg) The image was saved in the RGB mode, and is not indexed The console mode is not enabled in / e t c / d e f a u l t / g r u b The command g r u b m k c o n f i g must be executed to place the background image information into the / b o o t / g r u b / g r u b . c f g file Theme Here is an example for configuring Starfield theme which was included in GRUB package. Edit / e t c / d e f a u l t / g r u b
G R U B _ T H E M E = " / u s r / s h a r e / g r u b / t h e m e s / s t a r f i e l d / t h e m e . t x t "

Re-generate g r u b . c f g to apply the changes. If configuring the theme was successful, you will see F o u n dt h e m e :/ u s r / s h a r e / g r u b / t h e m e s / s t a r f i e l d / t h e m e . t x t in the terminal. Your splash image will usually not be displayed when using a theme. Menu colors You can set the menu colors in GRUB. The available colors for GRUB can be found in the GRUB Manual (https://www.gnu.org/software/grub/manual/html_node/Theme-file-format.html). Here is an example:

https://wiki.archlinux.org/index.php/GRUB

15/37

1/11/14

GRUB - ArchWiki

Edit / e t c / d e f a u l t / g r u b:
G R U B _ C O L O R _ N O R M A L = " l i g h t b l u e / b l a c k " G R U B _ C O L O R _ H I G H L I G H T = " l i g h t c y a n / b l u e "

Hidden menu One of the unique features of GRUB is hiding/skipping the menu and showing it by holding E s c when needed. You can also adjust whether you want to see the timeout counter. Edit / e t c / d e f a u l t / g r u b as you wish. Here is an example where the comments from the beginning of the two lines have been removed to enable the feature, the timeout has been set to five seconds and to be shown to the user:
G R U B _ T I M E O U T = 0 G R U B _ H I D D E N _ T I M E O U T = 5 G R U B _ H I D D E N _ T I M E O U T _ Q U I E T = f a l s e

GRUB_HIDDEN_TIMEOUT is how many seconds before displaying menu. You also need to set GRUB_TIMEOUT=0 if you want to hide menu. Disable framebuffer Users who use NVIDIA proprietary driver might wish to disable GRUB's framebuffer as it can cause problems with the binary driver. To disable framebuffer, edit / e t c / d e f a u l t / g r u b and uncomment the following line:
G R U B _ T E R M I N A L _ O U T P U T = c o n s o l e

Another option if you want to keep the framebuffer in GRUB is to revert to text mode just before starting the kernel. To do that modify the variable in / e t c / d e f a u l t / g r u b:
G R U B _ G F X P A Y L O A D _ L I N U X = t e x t

Persistent block device naming


One naming scheme for Persistent block device naming is the use of globally unique UUIDs to detect partitions instead of the "old" / d e v / s d *. Advantages are covered up in the above linked article. Persistent naming via filesystem UUIDs are used by default in GRUB. Note: The / b o o t / g r u b . c f g file needs regeneration with the new UUID in / e t c / d e f a u l t / g r u b every time

https://wiki.archlinux.org/index.php/GRUB

16/37

1/11/14

GRUB - ArchWiki

a relevant filesystem is resized or recreated. Remember this when modifying partitions & filesystems with a LiveCD. Whether to use UUIDs is controlled by an option in / e t c / d e f a u l t / g r u b:
G R U B _ D I S A B L E _ L I N U X _ U U I D = t r u e

Recall previous entry


GRUB can remember the last entry you booted from and use this as the default entry to boot from next time. This is useful if you have multiple kernels (i.e., the current Arch one and the LTS kernel as a fallback option) or operating systems. To do this, edit / e t c / d e f a u l t / g r u b and change the value of G R U B _ D E F A U L T:
G R U B _ D E F A U L T = s a v e d

This ensures that GRUB will default to the saved entry. To enable saving the selected entry, add the following line to / e t c / d e f a u l t / g r u b:
G R U B _ S A V E D E F A U L T = t r u e

Note: Manually added menu items, e.g. Windows in / e t c / g r u b . d / 4 0 _ c u s t o m or / b o o t / g r u b / c u s t o m . c f g, will need s a v e d e f a u l t added.

Changing the default menu entry


To change the default selected entry, edit / e t c / d e f a u l t / g r u b and change the value of G R U B _ D E F A U L T: Using numbers :
G R U B _ D E F A U L T = 0

Grub identifies entries in generated menu counted from zero. That means 0 for the first entry which is the default value, 1 for the second and so on. Or using menu titles :
G R U B _ D E F A U L T = ' A r c hL i n u x ,w i t hL i n u xc o r er e p ok e r n e l '

Root encryption
To let GRUB automatically add the kernel parameters for root encryption, add c r y p t d e v i c e = / d e v / y o u r d e v i c e : l a b e l to G R U B _ C M D L I N E _ L I N U X in / e t c / d e f a u l t / g r u b.

https://wiki.archlinux.org/index.php/GRUB

17/37

1/11/14

GRUB - ArchWiki

Tip: If you are upgrading from a working GRUB Legacy configuration, check / b o o t / g r u b / m e n u . l s t . p a c s a v e for the correct device/label to add. Look for them after the text k e r n e l/ v m l i n u z l i n u x. Example with root mapped to / d e v / m a p p e r / r o o t:
G R U B _ C M D L I N E _ L I N U X = " c r y p t d e v i c e = / d e v / s d a 2 : r o o t "

Also, disable the usage of UUIDs for the rootfs:


G R U B _ D I S A B L E _ L I N U X _ U U I D = t r u e

Boot non-default entry only once


The command g r u b r e b o o t is very helpful to boot another entry than the default only once. GRUB loads the entry passed in the first command line argument, when the system is rebooted the next time. Most importantly GRUB returns to loading the default entry for all future booting. Changing the configuration file or selecting an entry in the GRUB menu is not necessary. Note: This requires G R U B _ D E F A U L T = s a v e d in / e t c / d e f a u l t / g r u b (and then regenerating g r u b . c f g) or, in case of hand-made g r u b . c f g, the line s e td e f a u l t = " $ { s a v e d _ e n t r y } ".

Advanced configuration
This section covers manual editing of g r u b . c f g, writing custom scripts in / e t c / g r u b . d / and other advanced settings.

Manually creating grub.cfg


Warning: Editing this file is strongly discouraged. The file is generated by the g r u b m k c o n f i g command, and it is best to edit your / e t c / d e f a u l t / g r u b or one of the scripts in the / e t c / g r u b . d folder. A basic GRUB config file uses the following options:
( h d X , Y ) is the partition Y on disk X, partition numbers starting at 1, disk numbers starting at 0 s e td e f a u l t = N is the default boot entry that is chosen after timeout for user action s e tt i m e o u t = M is the time M to wait in seconds for a user selection before default is booted m e n u e n t r y" t i t l e "{ e n t r yo p t i o n s } is a boot entry titled t i t l e s e tr o o t = ( h d X , Y ) sets the boot partition, where the kernel and GRUB modules are stored (boot need not be a separate partition, and may simply be a directory under the "root" partition ( /)

An example configuration:

https://wiki.archlinux.org/index.php/GRUB

18/37

1/11/14

GRUB - ArchWiki

/ b o o t / g r u b / g r u b . c f g #C o n f i gf i l ef o rG R U B-T h eG N UG R a n dU n i f i e dB o o t l o a d e r #/ b o o t / g r u b / g r u b . c f g # # # # # # # # # D E V I C EN A M EC O N V E R S I O N S L i n u x G r u b / d e v / f d 0 ( f d 0 ) / d e v / s d a ( h d 0 ) / d e v / s d b 2 ( h d 1 , 2 ) / d e v / s d a 3 ( h d 0 , 3 )

#T i m e o u tf o rm e n u s e tt i m e o u t = 5 #S e td e f a u l tb o o te n t r ya sE n t r y0 s e td e f a u l t = 0 #( 0 )A r c hL i n u x m e n u e n t r y" A r c hL i n u x "{ s e tr o o t = ( h d 0 , 1 ) l i n u x/ v m l i n u z l i n u xr o o t = / d e v / s d a 3r o i n i t r d/ i n i t r a m f s l i n u x . i m g } # #( 1 )W i n d o w s # m e n u e n t r y" W i n d o w s "{ # s e tr o o t = ( h d 0 , 3 ) # c h a i n l o a d e r+ 1 # }

Dual-booting
Note: If you want GRUB to automatically search for other systems, you may wish to install o s p r o b e r ( h t t p s : / / w w w . a r c h l i n u x . o r g / p a c k a g e s / ? n a m e = o s p r o b e r ) . Automatically generating using /etc/grub.d/40_custom and grub-mkconfig The best way to add other entries is editing the / e t c / g r u b . d / 4 0 _ c u s t o m or / b o o t / g r u b / c u s t o m . c f g. The entries in this file will be automatically added when running g r u b m k c o n f i g. After adding the new lines, run:
#g r u b m k c o n f i go/ b o o t / g r u b / g r u b . c f g

or, for UEFI-GPT Mode:


#g r u b m k c o n f i go/ b o o t / e f i / E F I / G R U B / g r u b . c f g

to generate an updated g r u b . c f g.

https://wiki.archlinux.org/index.php/GRUB

19/37

1/11/14

GRUB - ArchWiki

For example, a typical / e t c / g r u b . d / 4 0 _ c u s t o m file, could appear similar to the following one, created for HP Pavilion 15-e056sl Notebook PC (http://h10025.www1.hp.com/ewfrf/wc/product? cc=us&destPage=product&lc=en&product=5402703&tmp_docname=), originally with Microsoft Windows 8 preinstalled. Each m e n u e n t r y should mantain a structure similar to the following ones. Note that the UEFI partition / d e v / s d a 2 within GRUB is called h d 0 , g p t 2 and a h c i 0 , g p t 2 (see here for more info). /etc/grub.d/40_custom:
# ! / b i n / s h e x e ct a i ln+ 3$ 0 #T h i sf i l ep r o v i d e sa ne a s yw a yt oa d dc u s t o mm e n ue n t r i e s . S i m p l yt y p et h e #m e n ue n t r i e sy o uw a n tt oa d da f t e rt h i sc o m m e n t . B ec a r e f u ln o tt oc h a n g e #t h e' e x e ct a i l 'l i n ea b o v e .

m e n u e n t r y" H P/M i c r o s o f tW i n d o w s8 . 1 "{ e c h o" L o a d i n gH P/M i c r o s o f tW i n d o w s8 . 1 . . . " i n s m o dp a r t _ g p t i n s m o df a t i n s m o ds e a r c h _ f s _ u u i d i n s m o dc h a i n s e a r c hf s u u i ds e t = r o o th i n t b i o s = h d 0 , g p t 2h i n t e f i = h d 0 , g p t 2h i n t b a r e m e t a l = a h c i 0 , g p t 2 c h a i n l o a d e r( $ { r o o t } ) / E F I / M i c r o s o f t / B o o t / b o o t m g f w . e f i }

m e n u e n t r y" H P/M i c r o s o f tC o n t r o lC e n t e r "{ e c h o" L o a d i n gH P/M i c r o s o f tC o n t r o lC e n t e r . . . " i n s m o dp a r t _ g p t i n s m o df a t i n s m o ds e a r c h _ f s _ u u i d i n s m o dc h a i n s e a r c hf s u u i ds e t = r o o th i n t b i o s = h d 0 , g p t 2h i n t e f i = h d 0 , g p t 2h i n t b a r e m e t a l = a h c i 0 , g p t 2 c h a i n l o a d e r( $ { r o o t } ) / E F I / H P / b o o t / b o o t m g f w . e f i } m e n u e n t r y" S y s t e ms h u t d o w n "{ e c h o" S y s t e ms h u t t i n gd o w n . . . " h a l t } m e n u e n t r y" S y s t e mr e s t a r t "{ e c h o" S y s t e mr e b o o t i n g . . . " r e b o o t }

GNU/Linux menu entry

Assuming that the other distro is on partition s d a 2:


m e n u e n t r y" O t h e rL i n u x "{ s e tr o o t = ( h d 0 , 2 ) l i n u x/ b o o t / v m l i n u z( a d do t h e ro p t i o n sh e r ea sr e q u i r e d ) i n i t r d/ b o o t / i n i t r d . i m g( i ft h eo t h e rk e r n e lu s e s / n e e d so n e ) }

FreeBSD menu entry

https://wiki.archlinux.org/index.php/GRUB

20/37

1/11/14

GRUB - ArchWiki

Requires that FreeBSD is installed on a single partition with UFS. Assuming it is installed on s d a 4:
m e n u e n t r y" F r e e B S D "{ s e tr o o t = ( h d 0 , 4 ) c h a i n l o a d e r+ 1 }

Windows XP menu entry

This assumes that your Windows partition is s d a 3. Remember you need to point set root and chainloader to the system reserve partition that windows made when it installed, not the actual partition windows is on. This example works if your system reserve partition is s d a 3.
#( 2 )W i n d o w sX P m e n u e n t r y" W i n d o w sX P "{ s e tr o o t = " ( h d 0 , 3 ) " c h a i n l o a d e r+ 1 }

If the Windows bootloader is on an entirely different hard drive than GRUB, it may be necessary to trick Windows into believing that it is the first hard drive. This was possible with d r i v e m a p. Assuming GRUB is on h d 0 and Windows is on h d 2, you need to add the following after s e tr o o t:
d r i v e m a psh d 0h d 2

Windows Installed in UEFI-GPT Mode menu entry

i f[" $ { g r u b _ p l a t f o r m } "= =" e f i "] ;t h e n m e n u e n t r y" M i c r o s o f tW i n d o w sV i s t a / 7 / 8x 8 6 _ 6 4U E F I G P T "{ i n s m o dp a r t _ g p t i n s m o df a t i n s m o ds e a r c h _ f s _ u u i d i n s m o dc h a i n s e a r c hf s u u i ds e t = r o o t$ h i n t s _ s t r i n g$ u u i d c h a i n l o a d e r/ E F I / M i c r o s o f t / B o o t / b o o t m g f w . e f i } f i

where $ h i n t s _ s t r i n g and $ u u i d are obtained with the following two commands. $ u u i d's command:
#g r u b p r o b et a r g e t = f s _ u u i d$ e s p / E F I / M i c r o s o f t / B o o t / b o o t m g f w . e f i 1 c e 5 7 f 2 8

$ h i n t s _ s t r i n g's command:
#g r u b p r o b et a r g e t = h i n t s _ s t r i n g$ e s p / E F I / M i c r o s o f t / B o o t / b o o t m g f w . e f i h i n t b i o s = h d 0 , g p t 1h i n t e f i = h d 0 , g p t 1h i n t b a r e m e t a l = a h c i 0 , g p t 1

https://wiki.archlinux.org/index.php/GRUB

21/37

1/11/14

GRUB - ArchWiki

These two commands assume the ESP Windows uses is mounted at $ e s p. There might be case differences in the path to Windows's EFI file, what with being Windows, and all.
"Shutdown" menu entry

m e n u e n t r y" S y s t e ms h u t d o w n "{ e c h o" S y s t e ms h u t t i n gd o w n . . . " h a l t }

"Restart" menu entry

m e n u e n t r y" S y s t e mr e s t a r t "{ e c h o" S y s t e mr e b o o t i n g . . . " r e b o o t }

Windows installed in BIOS-MBR mode

Note: GRUB supports booting b o o t m g r directly and chainload of partition boot sector is no longer required to boot Windows in a BIOS-MBR setup. Warning: It is the system partition that has b o o t m g r, not your "real" Windows partition (usually C:). When showing all UUIDs with blkid, the system partition is the one with L A B E L = " S Y S T E MR E S E R V E D " or L A B E L = " S Y S T E M " and is only about 100 to 200 MB in size (much like the boot partition for Arch). See Wikipedia:System partition and boot partition for more info. Throughout this section, it is assumed your Windows partition is / d e v / s d a 1. A different partition will change every instance of hd0,msdos1. First, find the UUID of the NTFS filesystem of the Windows's SYSTEM PARTITION where the b o o t m g r and its files reside. For example, if Windows b o o t m g r exists at / m e d i a / S Y S T E M _ R E S E R V E D / b o o t m g r: For Windows Vista/7/8:
#g r u b p r o b et a r g e t = f s _ u u i d/ m e d i a / S Y S T E M _ R E S E R V E D / b o o t m g r 6 9 B 2 3 5 F 6 7 4 9 E 8 4 C E

#g r u b p r o b et a r g e t = h i n t s _ s t r i n g/ m e d i a / S Y S T E M _ R E S E R V E D / b o o t m g r h i n t b i o s = h d 0 , m s d o s 1h i n t e f i = h d 0 , m s d o s 1h i n t b a r e m e t a l = a h c i 0 , m s d o s 1

Note: For Windows XP, replace b o o t m g r with N T L D R in the above commands. And note that there may not be a separate SYSTEM_RESERVED partition; just probe the file NTLDR on your Windows partition.

https://wiki.archlinux.org/index.php/GRUB

22/37

1/11/14

GRUB - ArchWiki

Then, add the below code to / e t c / g r u b . d / 4 0 _ c u s t o m or / b o o t / g r u b / c u s t o m . c f g and regenerate g r u b . c f g with g r u b m k c o n f i g as explained above to boot Windows (XP, Vista, 7 or 8) installed in BIOSMBR mode: For Windows Vista/7/8:

i f[" $ { g r u b _ p l a t f o r m } "= =" p c "] ;t h e n m e n u e n t r y" M i c r o s o f tW i n d o w sV i s t a / 7 / 8B I O S M B R "{ i n s m o dp a r t _ m s d o s i n s m o dn t f s i n s m o ds e a r c h _ f s _ u u i d i n s m o dn t l d r s e a r c hf s u u i ds e t = r o o th i n t b i o s = h d 0 , m s d o s 1h i n t e f i = h d 0 , m s d o s 1h i n t b a r e m e t a l = a h c i 0 , m s d o n t l d r/ b o o t m g r } f i

For Windows XP:

i f[" $ { g r u b _ p l a t f o r m } "= =" p c "] ;t h e n m e n u e n t r y" M i c r o s o f tW i n d o w sX P "{ i n s m o dp a r t _ m s d o s i n s m o dn t f s i n s m o ds e a r c h _ f s _ u u i d i n s m o dn t l d r s e a r c hf s u u i ds e t = r o o th i n t b i o s = h d 0 , m s d o s 1h i n t e f i = h d 0 , m s d o s 1h i n t b a r e m e t a l = a h c i 0 , m s d o n t l d r/ b o o t m g r } f i

Note: In some cases, mine I have installed GRUB before a clean Windows 8, you cannot boot Windows having an error with \ b o o t \ b c d (error code 0 x c 0 0 0 0 0 0 f). You can fix it going to Windows Recovery Console (cmd from install disk) and executing:
x : \ >" b o o t r e c . e x e/ f i x b o o t " x : \ >" b o o t r e c . e x e/ R e b u i l d B c d " .

Do not use b o o t r e c . e x e/ F i x m b r because it will wipe GRUB out. as a template to create / e t c / g r u b . d / n n _ c u s t o m. Where n n defines the precendence, indicating the order the script is executed. The order scripts are executed determine the placement in the grub boot menu. Note: n n should be greater than 06 to ensure necessary scripts are executed first. With Windows via EasyBCD and NeoGRUB
/ e t c / g r u b . d / 4 0 _ c u s t o m can be used

https://wiki.archlinux.org/index.php/GRUB

23/37

1/11/14

GRUB - ArchWiki

Since EasyBCD's NeoGRUB currently does not understand the GRUB menu format, chainload to it by replacing the contents of your C : \ N S T \ m e n u . l s t file with lines similar to the following:
d e f a u l t0 t i m e o u t1

t i t l e r o o t k e r n e l

C h a i n l o a di n t oG R U Bv 2 ( h d 0 , 7 ) / b o o t / g r u b / i 3 8 6 p c / c o r e . i m g

Finally, recreate your g r u b . c f g using g r u b m k c o n f i g.

Booting an ISO directly from GRUB


Edit / e t c / g r u b . d / 4 0 _ c u s t o m or / b o o t / g r u b / c u s t o m . c f g to add an entry for the target ISO. When finished, update the GRUB menu as with the usual g r u b m k c o n f i go/ b o o t / g r u b / g r u b . c f g (as root). Arch ISO Note: The following examples assume the ISO is in / a r c h i v e s on h d 0 , 6. Tip: For thumbdrives, use something like ( h d 1 , $ p a r t i t i o n ) and either / d e v / s d b Y for the i m g _ d e v parameter or a persistent name, e.g. i m g _ d e v = / d e v / d i s k / b y l a b e l / C O R S A I R.
x86_64

m e n u e n t r y" A r c h l i n u x 2 0 1 3 . 0 5 . 0 1 d u a l . i s o "c l a s si s o{ s e ti s o f i l e = " / a r c h i v e s / a r c h l i n u x 2 0 1 3 . 0 5 . 0 1 d u a l . i s o " s e tp a r t i t i o n = " 6 " l o o p b a c kl o o p( h d 0 , $ p a r t i t i o n ) / $ i s o f i l e l i n u x( l o o p ) / a r c h / b o o t / x 8 6 _ 6 4 / v m l i n u za r c h i s o l a b e l = A R C H _ 2 0 1 3 0 5i m g _ d e v = / d e v / s d a $ p a r t i t i o ni m g _ l o o p = $ i s i n i t r d( l o o p ) / a r c h / b o o t / x 8 6 _ 6 4 / a r c h i s o . i m g }

i686

m e n u e n t r y" A r c h l i n u x 2 0 1 3 . 0 5 . 0 1 d u a l . i s o "c l a s si s o{ s e ti s o f i l e = " / a r c h i v e s / a r c h l i n u x 2 0 1 3 . 0 5 . 0 1 d u a l . i s o " s e tp a r t i t i o n = " 6 " l o o p b a c kl o o p( h d 0 , $ p a r t i t i o n ) / $ i s o f i l e l i n u x( l o o p ) / a r c h / b o o t / i 6 8 6 / v m l i n u za r c h i s o l a b e l = A R C H _ 2 0 1 3 0 5i m g _ d e v = / d e v / s d a $ p a r t i t i o ni m g _ l o o p = $ i s o f i n i t r d( l o o p ) / a r c h / b o o t / i 6 8 6 / a r c h i s o . i m g }

https://wiki.archlinux.org/index.php/GRUB

24/37

1/11/14

GRUB - ArchWiki

Ubuntu ISO Note: The example assumes that the iso is in / a r c h i v e s on h d 0 , 6. Users must adjust the location and hdd/partition in the lines below to match their systems.

m e n u e n t r y" u b u n t u 1 3 . 0 4 d e s k t o p a m d 6 4 . i s o "{ s e ti s o f i l e = " / a r c h i v e s / u b u n t u 1 3 . 0 4 d e s k t o p a m d 6 4 . i s o " l o o p b a c kl o o p( h d 0 , 6 ) / $ i s o f i l e l i n u x( l o o p ) / c a s p e r / v m l i n u z . e f ib o o t = c a s p e ri s o s c a n / f i l e n a m e = $ i s o f i l eq u i e tn o e j e c tn o p r o m p ts p l a s hi n i t r d( l o o p ) / c a s p e r / i n i t r d . l z }

m e n u e n t r y" u b u n t u 1 2 . 0 4 d e s k t o p a m d 6 4 . i s o "{ s e ti s o f i l e = " / a r c h i v e s / u b u n t u 1 2 . 0 4 d e s k t o p a m d 6 4 . i s o " l o o p b a c kl o o p( h d 0 , 6 ) / $ i s o f i l e l i n u x( l o o p ) / c a s p e r / v m l i n u zb o o t = c a s p e ri s o s c a n / f i l e n a m e = $ i s o f i l eq u i e tn o e j e c tn o p r o m p ts p l a s hi n i t r d( l o o p ) / c a s p e r / i n i t r d . l z }

Other ISOs Other working configurations from link Source (http://askubuntu.com/questions/141940/how-to-boot-live-isoimages).

LVM
If you use LVM for your / b o o t, add the following before menuentry lines:
i n s m o dl v m

and specify your root in the menuentry as:


s e tr o o t = l v m / l v m _ g r o u p _ n a m e l v m _ l o g i c a l _ b o o t _ p a r t i t i o n _ n a m e

Example:
#( 0 )A r c hL i n u x m e n u e n t r y" A r c hL i n u x "{ i n s m o dl v m s e tr o o t = l v m / V o l u m e G r o u p l v _ b o o t #y o uc a no n l ys e tf o l l o w i n gt w ol i n e s l i n u x/ v m l i n u z l i n u xr o o t = / d e v / m a p p e r / V o l u m e G r o u p r o o tr o i n i t r d/ i n i t r a m f s l i n u x . i m g }

RAID
https://wiki.archlinux.org/index.php/GRUB 25/37

1/11/14

GRUB - ArchWiki

GRUB provides convenient handling of RAID volumes. You need to add i n s m o dm d r a i d which allows you to address the volume natively. For example, / d e v / m d 0 becomes:
s e tr o o t = ( m d 0 )

whereas a partitioned RAID volume (e.g. / d e v / m d 0 p 1) becomes:


s e tr o o t = ( m d 0 , 1 )

To install grub when using RAID1 as the / b o o t partition (or using / b o o t housed on a RAID1 root partition), on devices with GPT ef02/'BIOS boot partition', simply run grub-install on both of the drives, such as:
#g r u b i n s t a l lt a r g e t = i 3 8 6 p cr e c h e c kd e b u g/ d e v / s d a #g r u b i n s t a l lt a r g e t = i 3 8 6 p cr e c h e c kd e b u g/ d e v / s d b

Where the RAID1 array housing / b o o t is housed on / d e v / s d a and / d e v / s d b.

Using labels
It is possible to use labels, human-readable strings attached to filesystems, by using the l a b e l option to s e a r c h. First of all, label your existing partition:
#t u n e 2 f sLL A B E LP A R T I T I O N

Then, add an entry using labels. An example of this:


m e n u e n t r y" A r c hL i n u x ,s e s s i o nt e x t e "{ s e a r c hl a b e ls e t = r o o ta r c h r o o t l i n u x/ b o o t / v m l i n u z l i n u xr o o t = / d e v / d i s k / b y l a b e l / a r c h r o o tr o i n i t r d/ b o o t / i n i t r a m f s l i n u x . i m g }

Password protection of GRUB menu


If you want to secure GRUB so it is not possible for anyone to change boot parameters or use the command line, you can add a user/password combination to GRUB's configuration files. To do this, run the command g r u b m k p a s s w d p b k d f 2. Enter a password and confirm it:
g r u b m k p a s s w d p b k d f 2

[ . . . ] Y o u rP B K D F 2i sg r u b . p b k d f 2 . s h a 5 1 2 . 1 0 0 0 0 . C 8 A B D 3 E 9 3 C 4 D F C 8 3 1 3 8 B 0 C 7 A 3 D 7 1 9 B C 6 5 0 E 6 2 3 4 3 1 0 D A 0 6 9 E 6 F D B 0 D D 4 1 5 6 3 1 3 D A

https://wiki.archlinux.org/index.php/GRUB

26/37

1/11/14

GRUB - ArchWiki

Then, add the following to / e t c / g r u b . d / 0 0 _ h e a d e r:


/ e t c / g r u b . d / 0 0 _ h e a d e r c a t< <E O F s e ts u p e r u s e r s = " u s e r n a m e " p a s s w o r d _ p b k d f 2u s e r n a m e< p a s s w o r d > E O F

where < p a s s w o r d > is the string generated by g r u b m k p a s s w d _ p b k d f 2. Regenerate your configuration file. Your GRUB command line, boot parameters and all boot entries are now protected. This can be relaxed and further customized with more users as described in the "Security" part of the GRUB manual (https://www.gnu.org/software/grub/manual/grub.html#Security).

Hide GRUB unless the Shift key is held down


In order to achieve the fastest possible boot, instead of having GRUB wait for a timeout, it is possible for GRUB to hide the menu, unless the S h i f t key is held down during GRUB's start-up. In order to achieve this, you should add the following line to / e t c / d e f a u l t / g r u b:
G R U B _ F O R C E _ H I D D E N _ M E N U = " t r u e "

And the following file should be created:


/ e t c / g r u b . d / 3 1 _ h o l d _ s h i f t # !/ b i n / s h s e te # # # # # # # # # # # # # # # g r u b m k c o n f i gh e l p e rs c r i p t . C o p y r i g h t( C )2 0 0 6 , 2 0 0 7 , 2 0 0 8 , 2 0 0 9 F r e eS o f t w a r eF o u n d a t i o n ,I n c . G R U Bi sf r e es o f t w a r e :y o uc a nr e d i s t r i b u t ei ta n d / o rm o d i f y i tu n d e rt h et e r m so ft h eG N UG e n e r a lP u b l i cL i c e n s ea sp u b l i s h e db y t h eF r e eS o f t w a r eF o u n d a t i o n ,e i t h e rv e r s i o n3o ft h eL i c e n s e ,o r ( a ty o u ro p t i o n )a n yl a t e rv e r s i o n . G R U Bi sd i s t r i b u t e di nt h eh o p et h a ti tw i l lb eu s e f u l , b u tW I T H O U TA N YW A R R A N T Y ;w i t h o u te v e nt h ei m p l i e dw a r r a n t yo f M E R C H A N T A B I L I T Yo rF I T N E S SF O RAP A R T I C U L A RP U R P O S E . S e et h e G N UG e n e r a lP u b l i cL i c e n s ef o rm o r ed e t a i l s . Y o us h o u l dh a v er e c e i v e dac o p yo ft h eG N UG e n e r a lP u b l i cL i c e n s e a l o n gw i t hG R U B . I fn o t ,s e e< h t t p : / / w w w . g n u . o r g / l i c e n s e s / > .

p r e f i x = " / u s r " e x e c _ p r e f i x = " $ { p r e f i x } "

https://wiki.archlinux.org/index.php/GRUB

27/37

1/11/14

GRUB - ArchWiki

d a t a r o o t d i r = " $ { p r e f i x } / s h a r e " e x p o r tT E X T D O M A I N = g r u b e x p o r tT E X T D O M A I N D I R = " $ { d a t a r o o t d i r } / l o c a l e " s o u r c e" $ { d a t a r o o t d i r } / g r u b / g r u b m k c o n f i g _ l i b " f o u n d _ o t h e r _ o s = m a k e _ t i m e o u t( ){ i f[" x $ { G R U B _ F O R C E _ H I D D E N _ M E N U } "=" x t r u e "];t h e n i f[" x $ { 1 } "! =" x "];t h e n i f[" x $ { G R U B _ H I D D E N _ T I M E O U T _ Q U I E T } "=" x t r u e "];t h e n v e r b o s e = e l s e v e r b o s e = "v e r b o s e " f i i f[" x $ { 1 } "=" x 0 "];t h e n c a t< < E O F i f[" x \ $ { t i m e o u t } "! =" x 1 "] ;t h e n i fk e y s t a t u s ;t h e n i fk e y s t a t u ss h i f t ;t h e n s e tt i m e o u t = 1 e l s e s e tt i m e o u t = 0 f i e l s e i fs l e e p $ v e r b o s ei n t e r r u p t i b l e3;t h e n s e tt i m e o u t = 0 f i f i f i E O F e l s e c a t< <E O F i f[" x \ $ { t i m e o u t } "! =" x 1 "] ;t h e n i fs l e e p $ v e r b o s ei n t e r r u p t i b l e$ { G R U B _ H I D D E N _ T I M E O U T };t h e n s e tt i m e o u t = 0 f i f i E O F f i f i f i } a d j u s t _ t i m e o u t( ){ i f[" x $ G R U B _ B U T T O N _ C M O S _ A D D R E S S "! =" x "] ;t h e n c a t< < E O F i fc m o s t e s t$ G R U B _ B U T T O N _ C M O S _ A D D R E S S;t h e n E O F m a k e _ t i m e o u t" $ { G R U B _ H I D D E N _ T I M E O U T _ B U T T O N } "" $ { G R U B _ T I M E O U T _ B U T T O N } " e c h oe l s e m a k e _ t i m e o u t" $ { G R U B _ H I D D E N _ T I M E O U T } "" $ { G R U B _ T I M E O U T } " e c h of i e l s e m a k e _ t i m e o u t" $ { G R U B _ H I D D E N _ T I M E O U T } "" $ { G R U B _ T I M E O U T } " f i } a d j u s t _ t i m e o u t c a t< < E O F i f[" x \ $ { t i m e o u t } "! =" x 1 "] ;t h e n i fk e y s t a t u s ;t h e n i fk e y s t a t u ss h i f t ;t h e n

https://wiki.archlinux.org/index.php/GRUB

28/37

1/11/14

GRUB - ArchWiki

s e tt i m e o u t = 1 e l s e s e tt i m e o u t = 0 f i e l s e i fs l e e p $ v e r b o s ei n t e r r u p t i b l e3;t h e n s e tt i m e o u t = 0 f i f i f i E O F

Combining the use of UUIDs and basic scripting


If you like the idea of using UUIDs to avoid unreliable BIOS mappings or are struggling with GRUB's syntax, here is an example boot menu item that uses UUIDs and a small script to direct GRUB to the proper disk partitions for your system. All you need to do is replace the UUIDs in the sample with the correct UUIDs for your system. The example applies to a system with a boot and root partition. You will obviously need to modify the GRUB configuration if you have additional partitions:
m e n u e n t r y" A r c hL i n u x6 4 "{ #S e tt h eU U I D sf o ry o u rb o o ta n dr o o tp a r t i t i o nr e s p e c t i v e l y s e tt h e _ b o o t _ u u i d = e c e 0 4 4 8 f b b 0 8 4 8 6 d 9 8 6 4 a c 3 2 7 1 b d 8 d 0 7 s e tt h e _ r o o t _ u u i d = c 5 5 d a 1 6 f e 2 a f 4 6 0 3 9 e 0 b 0 3 f 5 f 5 6 5 e c 4 a #( N o t e :T h i sm a yb et h es a m ea sy o u rb o o tp a r t i t i o n ) #G e tt h eb o o t / r o o td e v i c e sa n ds e tt h e mi nt h er o o ta n dg r u b _ b o o tv a r i a b l e s s e a r c hf s u u i d$ t h e _ r o o t _ u u i ds e t = r o o t s e a r c hf s u u i d$ t h e _ b o o t _ u u i ds e t = g r u b _ b o o t #C h e c kt os e ei fb o o ta n dr o o ta r ee q u a l . #I ft h e ya r e ,t h e na p p e n d/ b o o tt o$ g r u b _ b o o t( S i n c e$ g r u b _ b o o ti sa c t u a l l yt h er o o tp a r t i t i o n ) i f[$ t h e _ b o o t _ u u i d= =$ t h e _ r o o t _ u u i d];t h e n s e tg r u b _ b o o t = ( $ g r u b _ b o o t ) / b o o t e l s e s e tg r u b _ b o o t = ( $ g r u b _ b o o t ) f i #$ g r u b _ b o o tn o wp o i n t st ot h ec o r r e c tl o c a t i o n ,s ot h ef o l l o w i n gw i l lp r o p e r l yf i n dt h ek e r n e la n d l i n u x$ g r u b _ b o o t / v m l i n u z l i n u xr o o t = / d e v / d i s k / b y u u i d / $ t h e _ r o o t _ u u i dr o i n i t r d$ g r u b _ b o o t / i n i t r a m f s l i n u x . i m g }

Using the command shell


Since the MBR is too small to store all GRUB modules, only the menu and a few basic commands reside there. The majority of GRUB functionality remains in modules in / b o o t / g r u b, which are inserted as needed. In error conditions (e.g. if the partition layout changes) GRUB may fail to boot. When this happens, a command shell may appear. GRUB offers multiple shells/prompts. If there is a problem reading the menu but the bootloader is able to find the disk, you will likely be dropped to the "normal" shell:

https://wiki.archlinux.org/index.php/GRUB

29/37

1/11/14

GRUB - ArchWiki

s h : g r u b >

If there is a more serious problem (e.g. GRUB cannot find required files), you may instead be dropped to the "rescue" shell:
g r u br e s c u e >

The rescue shell is a restricted subset of the normal shell, offering much less functionality. If dumped to the rescue shell, first try inserting the "normal" module, then starting the "normal" shell:
g r u br e s c u e >s e tp r e f i x = ( h d X , Y ) / b o o t / g r u b g r u br e s c u e >i n s m o d( h d X , Y ) / b o o t / g r u b / i 3 8 6 p c / n o r m a l . m o d r e s c u e : g r u b >n o r m a l

Pager support
GRUB supports pager for reading commands that provide long output (like the h e l p command). This works only in normal shell mode and not in rescue mode. To enable pager, in GRUB command shell type:
s h : g r u b >s e tp a g e r = 1

Using the command shell environment to boot operating systems


g r u b >

The GRUB's command shell environment can be used to boot operating systems. A common scenario may be to boot Windows / Linux stored on a drive/partition via chainloading. Chainloading means to load another boot-loader from the current one, ie, chain-loading. The other bootloader may be embedded at the starting of the disk(MBR) or at the starting of a partition. Chainloading a partition
s e tr o o t = ( h d X , Y ) c h a i n l o a d e r+ 1 b o o t

X=0,1,2... Y=1,2,3... For example to chainload Windows stored in the first partiton of the first hard disk,
s e tr o o t = ( h d 0 , 1 )

https://wiki.archlinux.org/index.php/GRUB

30/37

1/11/14

GRUB - ArchWiki

c h a i n l o a d e r+ 1 b o o t

Similarly GRUB installed to a partition can be chainloaded. Chainloading a disk/drive


s e tr o o t = h d X c h a i n l o a d e r+ 1 b o o t

Normal loading See the examples in #Using_the_rescue_console

GUI configuration tools


Following package may be installed: grub-customizer Customize the bootloader (GRUB or BURG) https://launchpad.net/grub-customizer || g r u b c u s t o m i z e r
( h t t p s : / / a u r . a r c h l i n u x . o r g / p a c k a g e s / g r u b c u s t o m i z e r / )

grub2-editor KDE4 control module for configuring the GRUB bootloader http://kde-apps.org/content/show.php?content=139643 || g r u b 2 e d i t o r
( h t t p s : / / a u r . a r c h l i n u x . o r g / p a c k a g e s / g r u b 2 e d i t o r / )

kcm-grub2 This Kcm module manages the most common settings of GRUB http://kde-apps.org/content/show.php?content=137886 || k c m g r u b 2
( h t t p s : / / a u r . a r c h l i n u x . o r g / p a c k a g e s / k c m g r u b 2 / )

startupmanager GUI app for changing the settings of GRUB Legacy, GRUB, Usplash and Splashy (abandonned (https://launchpad.net/startup-manager/+announcement/8300)) http://sourceforge.net/projects/startup-manager/ || s t a r t u p m a n a g e r
( h t t p s : / / a u r . a r c h l i n u x . o r g / p a c k a g e s / s t a r t u p m a n a g e r / )

parttool for hide/unhide


If you have a Windows 9x paradigm with hidden C : \ disks GRUB can hide/unhide it using p a r t t o o l. For example, to boot the third C : \ disk of three Windows 9x installations on the CLI enter the CLI and:
p a r t t o o lh d 0 , 1h i d d e n +b o o t -

https://wiki.archlinux.org/index.php/GRUB

31/37

1/11/14

GRUB - ArchWiki

p a r t t o o lh d 0 , 2h i d d e n +b o o t p a r t t o o lh d 0 , 3h i d d e n -b o o t + s e tr o o t = h d 0 , 3 c h a i n l o a d e r+ 1 b o o t

Using the rescue console


See #Using the command shell first. If unable to activate the standard shell, one possible solution is to boot using a live CD or some other rescue disk to correct configuration errors and reinstall GRUB. However, such a boot disk is not always available (nor necessary); the rescue console is surprisingly robust. The available commands in GRUB rescue include i n s m o d, l s, s e t, and u n s e t. This example uses s e t and i n s m o d. s e t modifies variables and i n s m o d inserts new modules to add functionality. Before starting, the user must know the location of their / b o o t partition (be it a separate partition, or a subdirectory under their root):
g r u br e s c u e >s e tp r e f i x = ( h d X , Y ) / b o o t / g r u b

where X is the physical drive number and Y is the partition number. To expand console capabilities, insert the l i n u x module:
g r u br e s c u e >i n s m o d( h d X , Y ) / b o o t / g r u b / l i n u x . m o d

Note: With a separate boot partition, omit / b o o t from the path, (i.e. type s e tp r e f i x = ( h d X , Y ) / g r u b and i n s m o d( h d X , Y ) / g r u b / l i n u x . m o d). This introduces the l i n u x and i n i t r d commands, which should be familiar (see #Advanced configuration). An example, booting Arch Linux:
s e tr o o t = ( h d 0 , 5 ) l i n u x/ b o o t / v m l i n u z l i n u xr o o t = / d e v / s d a 5 i n i t r d/ b o o t / i n i t r a m f s l i n u x . i m g b o o t

With a separate boot partition, again change the lines accordingly:


s e tr o o t = ( h d 0 , 5 ) l i n u x/ v m l i n u z l i n u xr o o t = / d e v / s d a 6 i n i t r d/ i n i t r a m f s l i n u x . i m g b o o t

https://wiki.archlinux.org/index.php/GRUB

32/37

1/11/14

GRUB - ArchWiki

After successfully booting the Arch Linux installation, users can correct g r u b . c f g as needed and then reinstall GRUB. To reinstall GRUB and fix the problem completely, changing / d e v / s d a if needed. See #Installation for details.

Troubleshooting
Intel BIOS not booting GPT
Some Intel BIOS's require at least one bootable MBR partition to be present at boot, causing GPT-partitioned boot setups to be unbootable. This can be circumvented by using (for instance) fdisk to mark one of the GPT partitions (preferably the 1007 KiB partition you have created for GRUB already) bootable in the MBR. This can be achieved, using fdisk, by the following commands: Start fdisk against the disk you are installing, for instance f d i s k/ d e v / s d a, then press a and select the partition you wish to mark as bootable (probably #1) by pressing the corresponding number, finally press w to write the changes to the MBR. Note: The bootable-marking must be done in f d i s k or similar, not in GParted or others, as they will not set the bootable flag in the MBR. More information is available here (http://www.rodsbooks.com/gdisk/bios.html)

Enable debug messages


Add:
s e tp a g e r = 1 s e td e b u g = a l l

to g r u b . c f g.

"No suitable mode found" error


If you get this error when booting any menuentry:
e r r o r :n os u i t a b l em o d ef o u n d B o o t i n gh o w e v e r

Then you need to initialize GRUB graphical terminal ( g f x t e r m) with proper video mode ( g f x m o d e) in GRUB. This video mode is passed by GRUB to the linux kernel via 'gfxpayload'. In case of UEFI systems, if the GRUB video mode is not initialized, no kernel boot messages will be shown in the terminal (atleast until KMS kicks in).

https://wiki.archlinux.org/index.php/GRUB

33/37

1/11/14

GRUB - ArchWiki

Copy / u s r / s h a r e / g r u b / u n i c o d e . p f 2 to ${GRUB_PREFIX_DIR} ( / b o o t / g r u b / in case of BIOS and UEFI systems). If GRUB UEFI was installed with b o o t d i r e c t o r y = $ e s p / E F I set, then the directory is $ e s p / E F I / g r u b /:
#c p/ u s r / s h a r e / g r u b / u n i c o d e . p f 2$ { G R U B _ P R E F I X _ D I R }

If / u s r / s h a r e / g r u b / u n i c o d e . p f 2 does not exist, install b d f u n i f o n t ( h t t p s : / / w w w . a r c h l i n u x . o r g / p a c k a g e s / ? n a m e = b d f u n i f o n t ) , create the u n i f o n t . p f 2 file and then copy it to $ { G R U B _ P R E F I X _ D I R }:
#g r u b m k f o n tou n i c o d e . p f 2/ u s r / s h a r e / f o n t s / m i s c / u n i f o n t . b d f

Then, in the g r u b . c f g file, add the following lines to enable GRUB to pass the video mode correctly to the kernel, without of which you will only get a black screen (no output) but booting (actually) proceeds successfully without any system hang. BIOS systems:
i n s m o dv b e

UEFI systems:
i n s m o de f i _ g o p i n s m o de f i _ u g a

After that add the following code (common to both BIOS and UEFI):
i n s m o df o n t

i fl o a d f o n t$ { p r e f i x } / f o n t s / u n i c o d e . p f 2 t h e n i n s m o dg f x t e r m s e tg f x m o d e = a u t o s e tg f x p a y l o a d = k e e p t e r m i n a l _ o u t p u tg f x t e r m f i

As you can see for gfxterm (graphical terminal) to function properly, u n i c o d e . p f 2 font file should exist in $ { G R U B _ P R E F I X _ D I R }.

msdos-style error message

g r u b s e t u p :w a r n :T h i sm s d o s s t y l ep a r t i t i o nl a b e lh a sn op o s t M B Rg a p ;e m b e d d i n gw i l ln o tb ep o s s i b l e ! g r u b s e t u p :w a r n :E m b e d d i n gi sn o tp o s s i b l e .G R U Bc a no n l yb ei n s t a l l e di nt h i ss e t u pb yu s i n gb l o c k l i s t

https://wiki.archlinux.org/index.php/GRUB

34/37

1/11/14

GRUB - ArchWiki

H o w e v e r ,b l o c k l i s t sa r eU N R E L I A B L Ea n di t su s ei sd i s c o u r a g e d . g r u b s e t u p :e r r o r :I fy o ur e a l l yw a n tb l o c k l i s t s ,u s ef o r c e .

This error may occur when you try installing GRUB in a VMware container. Read more about it here (https://bbs.archlinux.org/viewtopic.php?pid=581760#p581760). It happens when the first partition starts just after the MBR (block 63), without the usual space of 1 MiB (2048 blocks) before the first partition. Read #Master Boot Record (MBR) specific instructions

GRUB UEFI drops to shell


If GRUB loads but drops you into the rescue shell with no errors, it may be because of a missing or misplaced g r u b . c f g. This will happen if GRUB UEFI was installed with b o o t d i r e c t o r y and g r u b . c f g is missing OR if the partition number of the boot partition changed (which is hard-coded into the g r u b x 6 4 . e f i file).

GRUB UEFI not loaded


An example of a working EFI:
#e f i b o o t m g rv B o o t C u r r e n t :0 0 0 0 T i m e o u t :3s e c o n d s B o o t O r d e r :0 0 0 0 , 0 0 0 1 , 0 0 0 2 B o o t 0 0 0 0 *G r u b H D ( 1 , 8 0 0 , 3 2 0 0 0 , 2 3 5 3 2 f b b 1 b f a 4 e 4 6 8 5 1 a b 4 9 4 b f e 9 4 7 8 c ) F i l e ( \ e f i \ g r u b \ g r u b . e f i ) B o o t 0 0 0 1 *S h e l lH D ( 1 , 8 0 0 , 3 2 0 0 0 , 2 3 5 3 2 f b b 1 b f a 4 e 4 6 8 5 1 a b 4 9 4 b f e 9 4 7 8 c ) F i l e ( \ E f i S h e l l . e f i ) B o o t 0 0 0 2 *F e s t p l a t t e B I O S ( 2 , 0 , 0 0 ) P 0 :S A M S U N GH D 2 0 4 U I

If the screen only goes black for a second and the next boot option is tried afterwards, according to this post (https://bbs.archlinux.org/viewtopic.php?pid=981560#p981560), moving GRUB to the partition root can help. The boot option has to be deleted and recreated afterwards. The entry for GRUB should look like this then:
B o o t 0 0 0 0 *G r u b H D ( 1 , 8 0 0 , 3 2 0 0 0 , 2 3 5 3 2 f b b 1 b f a 4 e 4 6 8 5 1 a b 4 9 4 b f e 9 4 7 8 c ) F i l e ( \ g r u b . e f i )

Invalid signature
If trying to boot Windows results in an "invalid signature" error, e.g. after reconfiguring partitions or adding additional hard drives, (re)move GRUB's device configuration and let it reconfigure:
#m v/ b o o t / g r u b / d e v i c e . m a p/ b o o t / g r u b / d e v i c e . m a p o l d #g r u b m k c o n f i go/ b o o t / g r u b / g r u b . c f g

g r u b m k c o n f i g should

now mention all found boot options, including Windows. If it works, remove / b o o t / g r u b / d e v i c e . m a p o l d.

Boot freezes
https://wiki.archlinux.org/index.php/GRUB 35/37

1/11/14

GRUB - ArchWiki

If booting gets stuck without any error message after GRUB loading the kernel and the initial ramdisk, try removing the a d d _ e f i _ m e m m a p kernel parameter.

Restore GRUB Legacy


Move GRUB v2 files out of the way:
#m v/ b o o t / g r u b/ b o o t / g r u b . n o n f u n c t i o n a l

Copy GRUB Legacy back to / b o o t:


#c pa f/ b o o t / g r u b l e g a c y/ b o o t / g r u b

Replace MBR and next 62 sectors of sda with backed up copy Warning: This command also restores the partition table, so be careful of overwriting a modified partition table with the old one. It will mess up your system.
#d di f = / p a t h / t o / b a c k u p / f i r s t s e c t o r so f = / d e v / s d Xb s = 5 1 2c o u n t = 1

A safer way is to restore only the MBR boot code use:


#d di f = / p a t h / t o / b a c k u p / m b r b o o t c o d eo f = / d e v / s d Xb s = 4 4 6c o u n t = 1

Arch not found from other OS


Some have reported that other distributions have trouble finding Arch Linux automatically with o s p r o b e r. If this problem arises, it has been reported that detection can be improved with the presence of / e t c / l s b r e l e a s e. This file and updating tool is available with the package l s b r e l e a s e ( h t t p s : / / w w w . a r c h l i n u x . o r g / p a c k a g e s / ? n a m e = l s b r e l e a s e )in the official repositories.

Out of memory/Syntax error running grub-mkconfig


Note: This is workaround for FS#37904 (https://bugs.archlinux.org/task/37904). Add G R U B _ D I S A B L E _ S U B M E N U = y in / e t c / d e f a u l t / g r u b and regenerate g r u b . c f g.

See also
1. Official GRUB Manual - https://www.gnu.org/software/grub/manual/grub.html 2. Ubuntu wiki page for GRUB - https://help.ubuntu.com/community/Grub2 3. GRUB wiki page describing steps to compile for UEFI systems -

https://wiki.archlinux.org/index.php/GRUB

36/37

1/11/14

GRUB - ArchWiki

https://help.ubuntu.com/community/UEFIBooting 4. Wikipedia's page on BIOS Boot partition 5. http://members.iinet.net/~herman546/p20/GRUB2%20Configuration%20File%20Commands.html - quite complete description of how to configure GRUB Retrieved from "https://wiki.archlinux.org/index.php?title=GRUB&oldid=291860" Category: Boot loaders This page was last modified on 7 January 2014, at 03:12. Content is available under GNU Free Documentation License 1.3 or later unless otherwise noted.

https://wiki.archlinux.org/index.php/GRUB

37/37

Das könnte Ihnen auch gefallen