2. What will we be covering?
●
Introduction to GRUB
●
Installing GRUB
●
Exploring GRUB
●
Customizing GRUB
●
GRUB Error Recovery
3. Introduction...err...Features
➔
Many features and lot of flexibility
➔
Supports booting multiple operating systems
➔
Support for many boot devices
➢
➔
Hard disk (of course), cd-rom(El-Torito), network(tftp)
Support for many file systems (ext2/3, xfs, jfs,reiserfs, dos, fat16,
fat32...)
➔
Configuration File
4. Features (continued)
➔
➔
Support for network cards (etherboot)
Menu Interfaces for regular and command interface for
advanced users
➔
Remote control from serial console.
➔
Supports multiple executable formats
➔
Can uncompress compressed files.
5. Installing GRUB
From Scratch (i.e. on a blank disk)
➔
Do it from a host with GNU/GRUB installed.
➔
Create a partition on disk
fdisk /dev/sda
➔
Format and mount this partition:
mkfs.ext3 /dev/sda1
sudo mount /dev/sda1 /mnt/sda1
6. Installation....(Continued)
➔
Download grub tarball ftp://ftp.gnu.org/gnu/grub
➔
Compiling :)
➔
Install grub:
grub-install –root-directory=/mnt/sda1 /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg
A secret:
The grub-install (Just a shell script !!! :-O)
The real heroes are :
➔
'grub-mkimage' and
➔
'grub-setup'
7. Exploring(The quest to learn GRUB-fu)
➔
Changes???
➔
/boot/grub
➔
/etc/grub.d
➔
/etc/default/grub
➔
Other places: /usr/lib/grub(Modules)| /usr/bin or /bin (Binaries),Docs
8. Exploring....(Digging In)
➔
Scanning grub.cfg(/boot/grub/grub.cfg)
Phew!!.....looks complicated....(actually non-editable)we'll come back later.
➔
Peeking in /etc/grub.d
➔
➔
10_* Native boot entries
➔
20_* Third party apps
➔
30_osprobe :Scans for other O.S.
➔
➔
00_* contains header info
40_custom : Custom templates for additional entries
Looking at /etc/default/grub....
Hmmm....looks interesting.!!! :)
11. Making Custom Settings
➔
We change the /etc/default/grub file.
➔
Some of the configurations are:
➔
GRUB_DEFAULT,
➔
GRUB_TIMEOUT,
➔
GRUB_HIDDEN_TIMEOUT,
➔
GRUB_DISABLE_RECOVERY,
➔
GRUB_BACKGROUND,
➔
GRUB_THEME,
➔
.....AND MANY MORE.
12. Making Custom Scripts
➔
Can be done by adding scripts in
➔
Sample:
echo "Some string"
–
cat << EOF
–
menuentry "Something" {
–
set root=(hdX,Y)
–
-- boot parameters --
–
}EOF
/etc/default/grub
15. Error Recovery Contd...
➔
The Easy Way Out: A Rescue CD.
➔
The Tough Way:
set prefix=(hdx,y)/boot/grub
insmod (hdx,y)/boot/grub/linux.mod
set root=(hdx,y)
linux /boot/vmlinux-<version> root=/dev/sda5 #Change the numbers
initrd /boot/initramfs-3.0.0-1.fc16.i686.img
boot
grub-install /dev/sda5 #After booting
#Change the numbers
16. Error Recovery Contd....
➔
Error with UEFI
➔
Try disabling Secure-Boot
➔
Install grub-efi and shim packages
grub-mkconfig -o /boot/efi/EFI/$distr/grub.cfg
➔
Try using Boot-Repair
➔
Report a bug
Forums to the rescue.
17. Hacking With GRUB
➔
With GRUB users can access single user mode(root)
➔
How?
➔
➔
➔
Booting in recovery mode and going to
root
Modifying kernel arguments(Press a):
appending '1' at the last of arguments
On root prompt type passwd to change
password!!!:-D
19. Securing....Continued.
➔
Adding hashed password
$ grub-mkpasswd-pbkdf2
Enter your password:
Re-enter your password:
Your PBKDF2 is .................................
Now adding the output to 00_header (in /etc/grub.d)
➔
set superusers=”Umar”
password_pbkdf2 Umar
grub.pbkdf2.sha512.10000.FC58373BCA15A797C418C1EA7FFB007BF5A5
20. What we haven't covered
➔
List of command line and menu-entry commands
➔
All the bugs/errors which you may encounter.
➔
Designing of GRUB themes.
➔
GRUB environment variables/block.
➔
Booting with GRUB on a network.
21. Where to go from here?
➔
GNU-GRUB Documentation
http://www.gnu.org/software/grub/manual/
➔
GRUB Mailing list
help-grub@gnu.org
➔
bug-grub@gnu.org grub-devel@gnu.org
Wiki's
https://fedoraproject.org/wiki/GRUB_2
https://wiki.archlinux.org/index.php/GRUB
https://help.ubuntu.com/community/Grub2