This topic was published by DevynCJohnson and viewed 1060 times since "". The last page revision was "".
- Topics - 443
Many open-source bootloaders for GNU/Linux (and other systems in general) exist, but the most dominate one among GNU/Linux is GRUB (GRand Unified Bootloader), sometimes called GNU-GRUB. Bootloaders are special pieces of software that start the operating system or another bootloader (called chain loading). GRUB is a popular bootloader that may be the best choice for most people. Clearly, it is important that many admins and regular-users have a general understanding of GRUB.
The current version of GRUB is called GRUB2 (version 1.98 onwards) while the older version series is referred to as GRUB Legacy (0.97 and before [yes, 0.97, not 1.97]). In this article, we will be discussing GRUB2. GRUB supports a variety of filesystems (ext4, NTFS, UFS, etc.) and partition tables (MBR, GPT, etc.). GRUB functions differently on different partition tables, but this is transparent to the administrator. Whether GRUB is on an MBR or GPT storage unit, GRUB is still configured and managed the same way (however, GRUB functions differently). Also, nothing needs to be done to make GRUB boot an operating system on any given filesystem. In other words, when managing GRUB, do not worry about an operating system's filesystem. GRUB will either be able to boot the system or not.
GRUB owns various files on the system. /etc/grub.d/ contains various scripts that load data or start utilities/services. For instance, /etc/grub.d/00_header is a script that loads Grub's configuration file (/etc/default/grub). A sample of this configuration file can be seen towards the end of this article. /usr/lib/grub/ contains various modules for GRUB that allow GRUB to handle various filesystems or complete certain tasks. The modules are the "*.mod" files. For instance, the module "hfsplus.mod" allows GRUB to boot systems off of HFS+ filesystems.
FUN FACT: Sony's Playstation uses GRUB Legacy.
Grub can be configured via its configuration file /etc/default/grub. Be sure to make a backup file before making changes. After making changes, run "update-grub" in a terminal as the Root user. Running this command will update the /boot/grub/grub.cfg configuration file.
The command "
grub2-mkconfig -o /boot/grub2/grub.cfg" remakes GRUB's configuration file based on the current system's setup.
Older versions of GRUB can easily be managed with a GUI program called StartUp-Manager. This application is no longer actively developed and may not work on newer versions of GRUB. GRUB Customizer is a new GUI application for configuring newer versions of GRUB. GRUB Customizer can be installed on Debian-based systems by running the command "add-apt-repository ppa:danielrichter2007/grub-customizer" as Root. The website is https://launchpad.net/grub-customizer.
GRUB addresses partitions and storage units differently than GNU/Linux. For example, under GNU/Linux, the first storage unit is designated as /dev/sda while GRUB refers to the same unit as "hd0". This means /dev/sdb is hd1 to GRUB. GNU/Linux addresses the second partition of the first storage unit as /dev/sda1 while GRUB uses "hd0,1". Floppy disks are designated as fd0 (the first floppy), and optical disks (like DVDs and CDs) are referenced the same way as hard-drives/memory-cards. The root (as in filesystem hierarchy) can be set using this command after substituting "#" for the correct numbers - "set root=(hd#,#)".
Migrating from GRUB Legacy to GRUB2
If a system uses Grub Legacy and the administrator needs GRUB2, then here are the commands needed to migrate the system. Of course, they need to be run as Root.
apt-get install grub2 #Debian-based systems yum install grub2 #RedHat-based systems upgrade-from-grub-legacy #The migration
Make sure that important files are backed up just in case something goes wrong.
Install GRUB while Logged into GNU/Linux
Users can install GRUB while they are logged into a running GNU/Linux system. In a terminal, type "grub-install LOCATION", where LOCATION is a storage unit like /dev/sda. This command requires Root privileges. If errors occur, edit /boot/grub/device.map as needed removing the faulty lines. After fixing the map file, run the command again.
This installation installs Grub to the boot sector. This only works if Grub's files exist somewhere on the system. To download and install Grub so the "grub-install" command is present, use this command as Root - "apt-get install grub2". This will not install Grub on the boot sector. Instead, this makes the package for Grub and the install command available.
GRUB is a Text-User-Interface (TUI). GRUB has a simple command-line that is far below the capabilities of a full shell. However, GRUB's command-line still offers many features and capabilities. I am just trying to say that GRUB will lack many commands you may normally use in a shell like BASH or CSH. To access Grub's command-line, press "c" when in the menu. Once in the command-line, type "help" to see a list of commands. For help on a particular command, type "help COMMAND", where "COMMAND" is the command you wish to know more about. Grub can mount filesystems and view files on the partition (using the common "ls" command).
FUN FACT: GRUB can even mount ISO files that are on the storage units. To mount an ISO, type "
loopback loop (hd?,?)/PATH/FILE.iso".
The Grub command-line can be used/accessed in the booted GNU/Linux system. In a terminal, type "grub". This command can only be used with Root privileges.
GRUB can be configured to use colored backgrounds, but it is best to follow the KISS principle - Keep It Simple Stupid. It is best not to change any of GRUB's files or settings unless absolutely necessary. Plus, why would someone want a wallpaper for GRUB. It can be done and some users enjoy it, but be careful.
GRUB's main/first screen contains a list of all of the kernels and operating systems that GRUB is configured to see or detected during setup. Each line on the menu is called a "stanza". GRUB can handle multiboots between a variety of systems. A multiboot where many operating systems are installed on the system and GRUB can boot any one of them. This means in the list, the user may see some Linux distros, Solaris, BSD systems, Windows, or any combination of others. GRUB should also detect all of the different kernel versions. For instance, if a user has three different kernels install on their GNU/Linux system, GRUB will display all three and allow the user to boot using either one. This is helpful when a user tries a new kernel that happens to have a major/critical bug.
QUICK TIP: If multibooting with Windows, install Windows first and then Unix and Unix-like systems.
In the list, users may see a bootloader listed. When a bootloader loads another bootloader, that is called chainloading. This may be done because one bootloader may not be able to boot some operating system or another bootloader offers a desired feature not provided by the primary bootloader. For example, GRUB is not actually booting Windows directly. GRUB is chainloading Microsoft's bootloader which then loads Windows.
List of Grub's Directories/Files
# If you change this file, run 'update-grub' afterwards to update # /boot/grub/grub.cfg. # For full documentation of the options in this file, see: # info -f grub -n 'Simple configuration' GRUB_DEFAULT=0 #The first Stanza is the default choice GRUB_HIDDEN_TIMEOUT=0 #The time window listening for the user to press "shift" if the user wants the menu GRUB_HIDDEN_TIMEOUT_QUIET=true #true = do not show menu; false = show menu GRUB_TIMEOUT=10 #Boot the default in 10 seconds GRUB_DISTRIBUTOR=lsb_release -i -s 2> /dev/null || echo Debian #The name of the Linux distro GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" #kernel parameters for a normal boot GRUB_CMDLINE_LINUX="" #kernel parameters for a normal and rescue boot # Uncomment to enable BadRAM filtering, modify to suit your needs # This works with Linux (no patch required) and with any kernel that obtains # the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...) #GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef" # Uncomment to disable graphical terminal (grub-pc only) #GRUB_TERMINAL=console # The resolution used on graphical terminal # note that you can use only modes which your graphic card supports via VBE # you can see them in real GRUB with the command 'vbeinfo' #GRUB_GFXMODE=640x480 # Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux #GRUB_DISABLE_LINUX_UUID=true # Uncomment to disable generation of recovery mode menu entries #GRUB_DISABLE_RECOVERY="true" # Uncomment to get a beep at grub start #GRUB_INIT_TUNE="480 440 1"
Burg is a fork of Grub, and yes, Burg is Grub spelled backwards. Burg has been discontinued or at least appears that way. This bootloader can be obtained for Debian-based systems via a PPA. To add the PPA and install Burg via Root, run these commands in a terminal - "
add-apt-repository ppa:n-muench/burg; apt-get update; apt-get install burg burg-themes". Now, to apply Burg as the bootloader, run this command as Root - "burg-install /dev/sda". You may need to change the device location (/dev/sda).
Many portions of the configuration files used in GRUB will be the same in BURG.
WARNING: Make sure you have backed up your data just in case the installation and application of Burg fails which will make your OS unbootable. This will require you to install another bootloader to replace Burg or repair the bootloader. Failed bootloaders are fixable. The easiest (and laziest) way to fix a failed system is to reinstall the whole system. Yes, this is unnecessary, but easy.
- Linux Bootloaders - http://dcjtech.info/topic/linux-bootloaders/
- Grub Commands - http://dcjtech.info/topic/grub-commands/
- Grub Modules - http://dcjtech.info/topic/grub-modules/