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

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Chris Green
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.

So, is there a good tutorial anywhere about all this?  Much of what I
have found goes into detail about how grub2 is different from the
original grub but doesn't really give details of how to use grub2.

I just need to reconfigure my system to use a separate (small) boot
partition and a large (non bootable from BIOS) main partition.

So, currently I have:-

    /dev/sdb1         112515  15996     90782  15% /
    /dev/sdc1         938771 275489    615589  31% /home

with xubuntu 19.04 booting from /boot on /dev/sdb1.

What I want to do is add /dev/sda and install /boot on that 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?

I am fairly unix/linux aware (like 40 years aware!) and have done
quite 'techy' things in my time like build custom kernels and such but
this has got me really confused.

I suspect what I may have to do is try this out on a spare system (I
have a few PCs around which are redundant) and "see what happens".
However it does seem rather poorly documented.

--
Chris Green

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

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

Bret Busby-2
On 17/11/2019, Chris Green <[hidden email]> 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.
>
> So, is there a good tutorial anywhere about all this?  Much of what I
> have found goes into detail about how grub2 is different from the
> original grub but doesn't really give details of how to use grub2.
>
> I just need to reconfigure my system to use a separate (small) boot
> partition and a large (non bootable from BIOS) main partition.
>
> So, currently I have:-
>
>     /dev/sdb1         112515  15996     90782  15% /
>     /dev/sdc1         938771 275489    615589  31% /home
>
> with xubuntu 19.04 booting from /boot on /dev/sdb1.
>
> What I want to do is add /dev/sda and install /boot on that 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?
>
> I am fairly unix/linux aware (like 40 years aware!) and have done
> quite 'techy' things in my time like build custom kernels and such but
> this has got me really confused.
>
> I suspect what I may have to do is try this out on a spare system (I
> have a few PCs around which are redundant) and "see what happens".
> However it does seem rather poorly documented.
>
> --
> Chris Green
>
> --
> ubuntu-users mailing list
> [hidden email]
> Modify settings or unsubscribe at:
> https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
>

I do not know whether this will lead to what you seek, but, perhaps,
you could look at
https://lists.gnu.org/mailman/listinfo/help-grub
and subscribe to that list, and, ask there?


--
Bret Busby
Armadale
West Australia
..............

"So once you do know what the question actually is,
 you'll know what the answer means."
- Deep Thought,
 Chapter 28 of Book 1 of
 "The Hitchhiker's Guide to the Galaxy:
 A Trilogy In Four Parts",
 written by Douglas Adams,
 published by Pan Books, 1992

....................................................

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

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

Chris Green
On Sun, Nov 17, 2019 at 06:31:02PM +0000, Bret Busby wrote:

> > I suspect what I may have to do is try this out on a spare system (I
> > have a few PCs around which are redundant) and "see what happens".
> > However it does seem rather poorly documented.
> >
>
> I do not know whether this will lead to what you seek, but, perhaps,
> you could look at
> https://lists.gnu.org/mailman/listinfo/help-grub
> and subscribe to that list, and, ask there?
>
That's certainly a possibility, thanks!

--
Chris Green

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

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

Liam Proven
In reply to this post by Chris Green
On Sun, 17 Nov 2019 at 19:08, Chris Green <[hidden email]> 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.

Hi, Chris.

This is something that is fairly trivial to do at installation time.
It's probably non-trivial afterwards.

So, I feel I must ask:

[1] Is a reinstall feasible?
[2] And, er, well... why?

Anyway. What I _have_ done a few times is move /home into its own
filesystem, post-install. That is non-trivial too. Doing it to /boot
might actually be _easier_. As such, trying to translate the steps
from what I've done before, I'd say:

[1] make your new /boot partition.
[2] mount it somewhere else for now, e.g. /newboot
[3] copy the contents of the old /boot directory into the new mountpoint
[4] add the new filesystem to /etc/fstab
[5] (extra step) install GRUB2 to the new /boot filesystem
[6] tell your firmware to boot from the new partition not the old one
[7] rename your old /boot directory to something else, e.g. /oldboot

*Make sure you have working boot media to hand with the same version
of the OS on them!*

And then try it.

In theory that's about it, I think.


--
Liam Proven - Profile: https://about.me/liamproven
Email: [hidden email] - Google Mail/Hangouts/Plus: [hidden email]
Twitter/Facebook/Flickr: lproven - Skype/LinkedIn: liamproven
UK: +44 7939-087884 - ČR (+ WhatsApp/Telegram/Signal): +420 702 829 053

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

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

Colin Watson
In reply to this post by Chris Green
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.

(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.

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.

--
Colin Watson                                       [[hidden email]]

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

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

Chris Green
In reply to this post by Liam Proven
On Mon, Nov 18, 2019 at 01:03:57PM +0100, Liam Proven wrote:

> On Sun, 17 Nov 2019 at 19:08, Chris Green <[hidden email]> 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.
>
> Hi, Chris.
>
> This is something that is fairly trivial to do at installation time.
> It's probably non-trivial afterwards.
>
Yes, you're probably right. :-)


> So, I feel I must ask:
>
> [1] Is a reinstall feasible?
>
Yes, but it would take a while to add all the extra bits and pieces
that I have added to the basic installation.  Thus it would save a lot
of time if I can avoid a complete re-install from scratch.


> [2] And, er, well... why?
>
It's because I'm adding a fast SSD which will probably not be seen by
the BIOS and thus I can't boot from it.


> Anyway. What I _have_ done a few times is move /home into its own
> filesystem, post-install. That is non-trivial too. Doing it to /boot
> might actually be _easier_. As such, trying to translate the steps
> from what I've done before, I'd say:
>
Moving /home is easy, I've done it quite often.


> [1] make your new /boot partition.
> [2] mount it somewhere else for now, e.g. /newboot
> [3] copy the contents of the old /boot directory into the new mountpoint
> [4] add the new filesystem to /etc/fstab
> [5] (extra step) install GRUB2 to the new /boot filesystem
> [6] tell your firmware to boot from the new partition not the old one
> [7] rename your old /boot directory to something else, e.g. /oldboot
>
> *Make sure you have working boot media to hand with the same version
> of the OS on them!*
>
> And then try it.
>
The above sounds good to me, what I think I will do is try it on a
'spare' old system first to see if there are any gotchas and then I'll
try it on my 'real' desktop.


> In theory that's about it, I think.
>
Yes, thanks Liam.  :-)

--
Chris Green

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

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

Chris Green
In reply to this post by Colin Watson
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

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

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

Liam Proven
In reply to this post by Chris Green
On Mon, 18 Nov 2019 at 18:18, Chris Green <[hidden email]> wrote:

> Yes, but it would take a while to add all the extra bits and pieces
> that I have added to the basic installation.  Thus it would save a lot
> of time if I can avoid a complete re-install from scratch.

IKWYM. Common problem.

OTOH, a clean install is often nice and fast.

Some lovely generous chap gave me a dead MacBook Pro a month ago. I
refurbed it for my girlfriend -- new HD, bit more RAM, clean install
of the last version of macOS it can run.

Surprisingly, a 2010 machine running the 2017 release of macOS goes like stink.

> It's because I'm adding a fast SSD which will probably not be seen by
> the BIOS and thus I can't boot from it.

Ahaaa, right! Goes with the NVM/PCI-E hard disk... right.


--
Liam Proven - Profile: https://about.me/liamproven
Email: [hidden email] - Google Mail/Hangouts/Plus: [hidden email]
Twitter/Facebook/Flickr: lproven - Skype/LinkedIn: liamproven
UK: +44 7939-087884 - ČR (+ WhatsApp/Telegram/Signal): +420 702 829 053

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

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

Colin Watson
In reply to this post by Chris Green
On Mon, Nov 18, 2019 at 05:23:23PM +0000, Chris Green wrote:

> On Mon, Nov 18, 2019 at 12:07:53PM +0000, Colin Watson wrote:
> > 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?  

It doesn't matter.  Neither one depends on the output of the other one
(I mean, when running the tools; of course both outputs have to be there
at boot time if you want things to work).

> > 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.

Correct.

--
Colin Watson                                       [[hidden email]]

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

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

Liam Proven
On Mon, 18 Nov 2019 at 19:04, Colin Watson <[hidden email]> wrote:

> It doesn't matter.  Neither one depends on the output of the other one
> (I mean, when running the tools; of course both outputs have to be there
> at boot time if you want things to work).

Hmm. Most recently I've been fiddling with this on openSUSE and it
doesn't have an ``upgdate-grub'' command, which is a PITA.

Not sure the statement above is universally true, is all I'm saying.
> > 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.
>
> Correct.

Stop me if I'm wrong, but I vaguely thought GRUB recorded where you'd
installed it somewhere, so subsequent updates will just update
wherever it was last installed to...?


--
Liam Proven - Profile: https://about.me/liamproven
Email: [hidden email] - Google Mail/Hangouts/Plus: [hidden email]
Twitter/Facebook/Flickr: lproven - Skype/LinkedIn: liamproven
UK: +44 7939-087884 - ČR (+ WhatsApp/Telegram/Signal): +420 702 829 053

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

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

Colin Watson
On Mon, Nov 18, 2019 at 07:08:24PM +0100, Liam Proven wrote:

> On Mon, 18 Nov 2019 at 19:04, Colin Watson <[hidden email]> wrote:
>
> > It doesn't matter.  Neither one depends on the output of the other one
> > (I mean, when running the tools; of course both outputs have to be there
> > at boot time if you want things to work).
>
> Hmm. Most recently I've been fiddling with this on openSUSE and it
> doesn't have an ``upgdate-grub'' command, which is a PITA.
>
> Not sure the statement above is universally true, is all I'm saying.

Right, the update-grub wrapper is specific to Debian and its
descendants.  The statement should be true with only minor alteration,
though: openSUSE would have to have done something quite odd to make
either grub-install or grub-mkconfig depend on the other.

> > > 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.
> >
> > Correct.
>
> Stop me if I'm wrong, but I vaguely thought GRUB recorded where you'd
> installed it somewhere, so subsequent updates will just update
> wherever it was last installed to...?

Er, yes, that's a good point that I'd managed to forget, sorry (perhaps
blotting out the horror ...): on non-UEFI PC systems, rather than using
grub-install directly, it's better to use "dpkg-reconfigure grub-pc" to
record where you want the boot loader installed so that it can remember
it for the next time.  "grub-install" alone will work for the time being
but will probably eventually break with later upgrades.

I recognise that this situation is not ideal.

--
Colin Watson                                       [[hidden email]]

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

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

Chris Green
In reply to this post by Liam Proven
On Mon, Nov 18, 2019 at 06:26:25PM +0100, Liam Proven wrote:
> On Mon, 18 Nov 2019 at 18:18, Chris Green <[hidden email]> wrote:
>
> > Yes, but it would take a while to add all the extra bits and pieces
> > that I have added to the basic installation.  Thus it would save a lot
> > of time if I can avoid a complete re-install from scratch.
>
> IKWYM. Common problem.

There are ways of finding what one has added and I do try and use
*only* software from proper repositories so it's not an insuperable
problem.

>
> OTOH, a clean install is often nice and fast.
>
A clean install every few years is probably a 'good thing'. :-)

--
Chris Green

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users