Linux Format - UK (2019-12)

(Antfer) #1
72 LXF257 December 2019 http://www.linuxformat.com

TUTORIALS Customising GRUB


compiling. If you do need to compile, the tools are the
common ones: GCC, make and binutils. For ordinary
tweaking, you have plenty of tools available together
with GRUB itself. Please remember that you are playing
with the boot system: do something wrong and you may
need to do a recovery (why not see our recovery feature
on page 44) action. This can take time and you may lose
all your data.
Wise readers always have important data backed up
using the cloud, Clonezilla or the backup application
delivered with your distribution. If you want to boot
without GRUB, you may need to compile your kernel.

32-bit vs 64-bit
GRUB comes as both 32-bit and 64-bit, though in
today’s world, the former is seldom useful. However,
you may have an old system lying around that you want
to boot from a memory stick, so consider getting GRUB
32-bit for this edge case. While you can start a 32-bit
OS with GRUB 64-bit, you may need 32-bit GRUB only
for the case of an old 32-bit computer. This is common
for old (2006) iMac computers. The limitation is in the
UEFI being 32-bit, making GRUB unbootable.
The package that handles this is grub-efi-ia32; you
will ordinarily have to do a bit of work to make it work.
sudo apt install grub-efi-ia32 grub-efi-ia32-bin
You should be aware that when you install this you
change the GRUB version on the machine you’re
working on. This could be a disaster if you do it on your
ordinary machine. The safe alternative is to create one

ooting your PC is something that just happens
and most people don’t even give it a second
thought, unless it’s brain-numbingly slow or
something goes about as wrong as Brexit has. This is
largely as most distributions, when you install them,
automatically create the partitions and sets up any
dual-boot required. Beyond that, most users leave it be
and get on with their lives.
This makes the thing we call GRUB and generally the
entire boot process a mystery to most people. In this
article, you can start clearing the fog a little bit and see
what you can do to improve things. If dual-booting isn’t
on your agenda, you still have other interesting options
to explore along expanding your knowledge.
If you’re wondering what it stands for, GNU GRUB
is the GRand Unified Bootloader. The bootloader is
the software glue that sits between the BIOS/UEFI
firmware that kickstarts your PC hardware into life and
the Linux (or Windows) kernel being run – started by
the bootloader – and then the Process ID One (PiD1)
‘init’, very often Systemd.
Depending on what you are after, you may need to
compile (don’t panic!) GRUB or even the kernel. One
interesting feature to consider is EFI_STUB, which
makes the kernel a boot loader that you can set to be
the first to load. That will be faster, but you will be
unable to dual-boot your machine, which can make life
complicated. Single-booting is not necessarily bad
though – have you decided to stick with Linux or do you
need other operating systems? If you only have one or
two applications that need Windows, you can run that
in a virtual machine.
In most cases, your GRUB binary is good to go, as
you can make many tweaks to your system without

Plop Linux comes
with rEFInd as its
default bootloader.
Create a virtual
machine with it
and you can start
the rEFInd shell to
configure the boot.

Most standard boot menus on Linux machines are blue like this, but
you have the power to change all of this.

Get more from your


grubby boot menu


Mats Tage Axelsson takes you through the intricacies of GRUB


that you never thought you would wonder about...


Mats Tage
Axelsson
keeps fighting the
tide, showing you
what even he can
do using Linux to
make the world
a better place.

B


GRUB


OUR
EXPERT

Practice in
a virtual
machine, as any
experiments
with GRUB
can make
your system
unbootable.
Most features
will behave the
same in a VM
as on your
real machine.

72 LXF257 December 2019 http://www.linuxformat.com


TUTORIALS Customising GRUB


compiling.If youdoneedtocompile,thetoolsarethe
commonones:GCC,makeandbinutils. Forordinary
tweaking,youhaveplentyoftoolsavailabletogether
withGRUBitself.Pleaserememberthatyouareplaying
withthebootsystem:dosomethingwrongandyoumay
needtodoa recovery(whynotseeourrecoveryfeature
onpage44)action.Thiscantaketimeandyoumaylose
allyourdata.
Wisereadersalwayshaveimportantdatabackedup
usingthecloud,Clonezillaorthebackupapplication
deliveredwithyourdistribution.If youwanttoboot
withoutGRUB, youmayneedtocompileyourkernel.

32-bitvs64-bit
GRUBcomesasboth32-bitand64-bit,thoughin
today’sworld,theformerisseldomuseful.However,
youmayhaveanoldsystemlyingaroundthatyouwant
tobootfroma memorystick,soconsidergettingGRUB
32-bitforthisedgecase.Whileyoucanstarta 32-bit
OSwithGRUB64-bit,youmayneed32-bitGRUBonly
forthecaseofanold32-bitcomputer.Thisiscommon
forold(2006)iMaccomputers.Thelimitationisinthe
UEFIbeing32-bit,makingGRUBunbootable.
Thepackagethathandlesthisisgrub-efi-ia32;you
willordinarilyhavetodoa bitofworktomakeit work.
sudoaptinstallgrub-efi-ia32grub-efi-ia32-bin
Youshouldbeawarethatwhenyouinstallthisyou
changetheGRUBversiononthemachineyou’re
workingon.Thiscouldbea disasterif youdoit onyour
ordinarymachine.Thesafealternativeistocreateone

ootingyourPCissomethingthatjusthappens
andmostpeopledon’tevengiveit a second
thought,unlessit’sbrain-numbinglyslowor
somethinggoesaboutaswrongasBrexithas.Thisis
largelyasmostdistributions,whenyouinstallthem,
automaticallycreatethepartitionsandsetsupany
dual-bootrequired.Beyondthat,mostusersleaveit be
andgetonwiththeirlives.
ThismakesthethingwecallGRUBandgenerallythe
entirebootprocessa mysterytomostpeople.Inthis
article,youcanstartclearingthefoga littlebitandsee
whatyoucandotoimprovethings.If dual-bootingisn’t
onyouragenda,youstillhaveotherinterestingoptions
toexplorealongexpandingyourknowledge.
If you’rewonderingwhatit standsfor,GNUGRUB
istheGRandUnifiedBootloader.Thebootloaderis
thesoftwaregluethatsitsbetweentheBIOS/UEFI
firmwarethatkickstartsyourPChardwareintolifeand
theLinux(orWindows)kernelbeingrun– startedby
thebootloader– andthentheProcessIDOne(PiD1)
‘init’,veryoftenSystemd.
Dependingonwhatyouareafter,youmayneedto
compile(don’tpanic!)GRUBoreventhekernel.One
interestingfeaturetoconsiderisEFI_STUB,which
makesthekernela bootloaderthatyoucansettobe
thefirsttoload.Thatwillbefaster,butyouwillbe
unabletodual-bootyourmachine,whichcanmakelife
complicated.Single-bootingisnotnecessarilybad
though– haveyoudecidedtostickwithLinuxordoyou
needotheroperatingsystems?If youonlyhaveoneor
twoapplicationsthatneedWindows,youcanrunthat
ina virtualmachine.
Inmostcases,yourGRUBbinaryisgoodtogo,as
youcanmakemanytweakstoyoursystemwithout

Plop Linux comes
with rEFInd as its
default bootloader.
Create a virtual
machine with it
and you can start
the rEFInd shell to
configure the boot.

MoststandardbootmenusonLinuxmachinesarebluelike this, but
youhavethepowertochangeallofthis.

Get more from your


grubby boot menu


Mats TageAxelsson takes you through the intricacies of GRUB


thatyouneverthought you would wonder about...


MatsTage
Axelsson
keeps fighting the
tide, showing you
what even he can
do using Linux to
make the world
a better place.


B


GRUB


OUR
EXPERT

Practicein
a virtual
machine,asany
experiments
withGRUB
canmake
yoursystem
unbootable.
Mostfeatures
willbehavethe
sameina VM
asonyour
realmachine.
Free download pdf