Configuring/using grub with grub-install and grub-mkconfig

Chris Green cl at isbd.net
Mon Nov 18 17:23:23 UTC 2019


On Mon, Nov 18, 2019 at 12:07:53PM +0000, Colin Watson wrote:
> On Sun, Nov 17, 2019 at 06:05:56PM +0000, Chris Green wrote:
> > I have been searching around (and asking questions) about how to add a
> > separate /boot partition.  As a result I have become steadily *more*
> > confused about the relationship between grub-mkconfig and grub-install.
> 
> grub-install puts the boot loader code on disk such that the system
> firmware can transfer control to it at boot time, with enough
> information that it knows how to find /boot/grub.
> 
> grub-mkconfig generates grub.cfg, which the boot loader runs, and whose
> main purpose is to find the root filesystem and transfer control to an
> appropriate kernel found there.
> 
So, having said that, which should one run first?  Say I have changed
where my /boot is do I run grub-mkconfig to create grub.cfg and then
grub-install?  


> (On Debian-based systems such as Ubuntu, you should normally run
> update-grub rather than running grub-mkconfig directly.  It's just a
> simple wrapper, but it saves you from typing out the path to
> /boot/grub/grub.cfg.)
> 
> > I just need to reconfigure my system to use a separate (small) boot
> > partition and a large (non bootable from BIOS) main partition.
> [...]
> > So I can mount /dev/sda1, no problem there.  So what do I do next?
> > Do I run grub-install?  Do I run grub-mkconfig?
> 
> You'll definitely need to run grub-install, because you're trying to
> make parts of the boot loader code live in a new place and refer to the
> new /boot directory.
> 
Yes, makes sense.


> It may be possible to get away without running update-grub if you move
> across the existing /boot/grub/grub.cfg and don't move the existing root
> filesystem, because grub.cfg shouldn't itself depend on the details of
> where /boot is, only on where / is.  However, just running update-grub
> is simpler and doesn't hurt.
> 
OK, so, if I understand it right, I run update-grub (which runs
grub-mkconfig for me with some parameters pre-set) which creates
/boot/grub/grub.cfg and then I should run grub-install to write the
things the BIOS needs to start the system.

Thanks.

-- 
Chris Green




More information about the ubuntu-users mailing list