minimal grub:2 install? [grub:0 being removed]

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

minimal grub:2 install? [grub:0 being removed]

Grant Edwards-6
Apparently they're going to try to pry grub-0.97 from my cold dead
fingers...

Is there any documentation on how to do a basic minimal grub:2
install?

I really don't want any of the auto-magical, devs know better than I
do what I want, os-probing, hide all the details from the stupid user,
config file generator stuff installed.  I just want the bare minimum
required to boot using a hand-edited grub.conf file.

There doesn't seem to be a USE flag...

--
Grant Edwards               grant.b.edwards        Yow! Here I am at the flea
                                  at               market but nobody is buying
                              gmail.com            my urine sample bottles ...


Reply | Threaded
Open this post in threaded view
|

Re: minimal grub:2 install? [grub:0 being removed]

Grant Edwards-6
On 2019-01-17, Grant Edwards <[hidden email]> wrote:

> Is there any documentation on how to do a basic minimal grub:2
> install?
>
> I really don't want any of the auto-magical, devs know better than I
> do what I want, os-probing, hide all the details from the stupid user,
> config file generator stuff installed.  I just want the bare minimum
> required to boot using a hand-edited grub.conf file.

Perhaps I'm a bit too jaded from my experiences with grub2 on other
distros.  It's sort of implied at https://wiki.gentoo.org/wiki/GRUB2_Quick_Start#Manual_configuration
that if you want, you can just manually edit grub.conf and not use
grub-mkconfig.

Do all the Gentoo package maintainers promise they'll never run
grub-mkconfig as part of a any package (even grub:2) install, remove,
or update?

Other distros seem to have calls to grub-mkconfig sprinkled around in
various other package install scripts so that you've got to manually
hobble grub-mkconfig so that it doesn't trash your grub.conf file
without asking because some other package got updated or installed.
But then the next time grub2 gets updated, it get's un-hobbled and
goes ahead and trashes your grub.conf file.

--
Grant Edwards               grant.b.edwards        Yow! The Korean War must
                                  at               have been fun.
                              gmail.com            


Reply | Threaded
Open this post in threaded view
|

Re: minimal grub:2 install? [grub:0 being removed]

Jack
In reply to this post by Grant Edwards-6
On 2019.01.17 17:52, Grant Edwards wrote:

> Apparently they're going to try to pry grub-0.97 from my cold dead
> fingers...
>
> Is there any documentation on how to do a basic minimal grub:2
> install?
>
> I really don't want any of the auto-magical, devs know better than I
> do what I want, os-probing, hide all the details from the stupid user,
> config file generator stuff installed.  I just want the bare minimum
> required to boot using a hand-edited grub.conf file.
>
> There doesn't seem to be a USE flag...
I just copied the ebuild (and required patches) into my local overlay.  
Still no grub2 for me in Gentoo.  (I do use it on other PCs with other  
distros, and the grub "magic" has so far been kind to me and not  
screwed anything up yet.)
Reply | Threaded
Open this post in threaded view
|

Re: minimal grub:2 install? [grub:0 being removed]

Dale-46
In reply to this post by Grant Edwards-6
Grant Edwards wrote:

> Apparently they're going to try to pry grub-0.97 from my cold dead
> fingers...
>
> Is there any documentation on how to do a basic minimal grub:2
> install?
>
> I really don't want any of the auto-magical, devs know better than I
> do what I want, os-probing, hide all the details from the stupid user,
> config file generator stuff installed.  I just want the bare minimum
> required to boot using a hand-edited grub.conf file.
>
> There doesn't seem to be a USE flag...
>


I made the switch a good while back.  Even for me, it has been fairly
easy.  I don't recall it ever breaking or giving me trouble.  When I
build a new kernel and get the init thingy in /boot, I run this command
to update grub.

grub2-mkconfig -o /boot/grub2/grub.cfg

I put it in a little script and just run the script, so I don't have to
remember the thing.  ;-)  The only thing I recall it being picky on, the
names of the kernel and the init thingy.  If they don't match correctly,
it won't match them up when you run the above.  A little sample of my
naming that works. 


-rw-------  1 root root 5038915 Feb 27  2015 initramfs-3.18.7-1.img
-rw-------  1 root root 7675107 Feb 16  2018 initramfs-4.14.19-gentoo.img
-rw-------  1 root root 7752134 Oct 15 00:16 initramfs-4.18.12-1.img
-rw-------  1 root root 8233752 Dec 21 16:22 initramfs-4.19.8-1.img
-rw-------  1 root root 5377395 May 20  2016 initramfs-4.5.2-1.img
-rw-------  1 root root 7752249 Oct 15 00:14 initramfs-4.5.2-gentoo.img
-rw-------  1 root root 6488176 Apr 22  2017 initramfs-4.9.22-1.img
-rw-------  1 root root 6479446 Aug 21  2017 initramfs-4.9.34-1.img
-rw-r--r--  1 root root 5387680 Feb 27  2015 kernel-3.18.7-1
-rw-r--r--  1 root root 6848464 Feb 16  2018 kernel-4.14.19-gentoo
-rw-r--r--  1 root root 7061552 Oct 14 23:53 kernel-4.18.12-1
-rw-r--r--  1 root root 7110704 Dec 21 15:59 kernel-4.19.8-1
-rw-r--r--  1 root root 5858496 Jun 17  2016 kernel-4.5.2-1
-rw-r--r--  1 root root 6983664 Aug 21  2017 kernel-4.9.34-1


To your real desire, I don't think there is a minimal grub2 install. 
While bigger than the old Grub, it isn't to bad, given the size of
drives nowadays. 

root@fireball / # equery s grub
 * sys-boot/grub-2.02-r1
         Total files : 1207
         Total size  : 50.85 MiB
root@fireball / #

If the old grub isn't being maintained anymore, from what I've read it
isn't, you will have to switch at some point.  If grub2 works for me, it
should work great for you.  I'm pretty good at finding problems. lol 

Dale

:-)  :-) 

Reply | Threaded
Open this post in threaded view
|

Re: minimal grub:2 install? [grub:0 being removed]

Grant Edwards-6
On 2019-01-17, Dale <[hidden email]> wrote:

> I made the switch a good while back.  Even for me, it has been fairly
> easy.  I don't recall it ever breaking or giving me trouble.  When I
> build a new kernel and get the init thingy in /boot, I run this command
> to update grub.
>
> grub2-mkconfig -o /boot/grub2/grub.cfg

I don't want to use grub2-mkconfig.  On my simple machines, the grub
config file (for either 0.97 or 2) is trivial and I prefer to maintain
it manually.  On my complex machine (about a dozen different distros
installed in as many partitions), grub2-mkconfig invariably guesses
wrong too much of the time.  Disabling the os-prober helps a lot, but
it's still way easier to just maintain the config file manually.

> To your real desire, I don't think there is a minimal grub2 install. 
> While bigger than the old Grub, it isn't to bad, given the size of
> drives nowadays.

I'm not worried about the size, I just don't want any of the
automagical config stuff happening (and would feel safest if it wasn't
even installed).

--
Grant Edwards               grant.b.edwards        Yow! My haircut is totally
                                  at               traditional!
                              gmail.com            


Reply | Threaded
Open this post in threaded view
|

Re: minimal grub:2 install? [grub:0 being removed]

Grant Edwards-6
In reply to this post by Jack
On 2019-01-17, Jack <[hidden email]> wrote:

> I just copied the ebuild (and required patches) into my local overlay.  
> Still no grub2 for me in Gentoo.

I'll probably do that for now.  As long as it keeps working, there's
no need to battle with grub2...

> (I do use it on other PCs with other distros, and the grub "magic"
> has so far been kind to me and not screwed anything up yet.)

Same here.  For the most part I've beaten it into submission so that
it doesn't screw things up too often on Suse, RedHat, Ubuntu, Mint
etc.  It's just not something I wanted to doing on my Gentoo machines.

--
Grant Edwards               grant.b.edwards        Yow! I have a very good
                                  at               DENTAL PLAN.  Thank you.
                              gmail.com            


Reply | Threaded
Open this post in threaded view
|

Re: minimal grub:2 install? [grub:0 being removed]

Rich Freeman
In reply to this post by Grant Edwards-6
On Thu, Jan 17, 2019 at 6:15 PM Grant Edwards <[hidden email]> wrote:
>
> Do all the Gentoo package maintainers promise they'll never run
> grub-mkconfig as part of a any package (even grub:2) install, remove,
> or update?
>

I doubt you'd get it in writing but I'd be shocked if they ever did.
Gentoo doesn't install a kernel for you, so why would it go messing
with grub?

You definitely can manually configure grub.conf for grub2, and it
would basically work the same as grub legacy if you did so.  The
syntax is slightly different so you'll have to check on that, but it
would basically consist of taking your old config file and just making
a few syntax tweaks.

I do suggest at least giving grub-mkconfig a try though.  It does
depend on kernels/initramfs/etc using a standardized naming
convention.  If you use make install to install your kernels you're
fine.  If you go hand copying things then it won't.  The one thing I
have noticed is that it doesn't always get ordering right if you go
messing around and creating kernels with suffixes on the filenames or
+'s on them.  You can run grub-mkconfig and if you don't append -o to
the command line it just dumps the config file to stdout, so you can
see what it would do.

But, if you want to always have a vmlinux and vmlinux.old in your
/boot and just point grub to the one and then the other and never
touch it, that will work perfectly fine.  The autogenerated configs
have a ton of scripting in them but a minimal one isn't really any
more complex than the old grub was.

Basically grub2 is a completely inert package.  The stuff in /usr/bin
and so on doesn't do anything unless you explicitly run it.  The
bootloader reads its config file and does what it says, just like the
old one.  The bootloader won't even be there unless you explicitly
install it, just as with the old grub.

The one issue you're going to have is finding documentation on the
config file.  There is a TON of docs on running mkconfig, and very
little on rolling your own, but it definitely can be done.

--
Rich

Reply | Threaded
Open this post in threaded view
|

Re: minimal grub:2 install? [grub:0 being removed]

Grant Edwards-6
On 2019-01-17, Rich Freeman <[hidden email]> wrote:
> On Thu, Jan 17, 2019 at 6:15 PM Grant Edwards <[hidden email]> wrote:
>>
>> Do all the Gentoo package maintainers promise they'll never run
>> grub-mkconfig as part of a any package (even grub:2) install, remove,
>> or update?
>
> I doubt you'd get it in writing but I'd be shocked if they ever did.
> Gentoo doesn't install a kernel for you, so why would it go messing
> with grub?

Good point. :)

> You definitely can manually configure grub.conf for grub2, and it
> would basically work the same as grub legacy if you did so.  The
> syntax is slightly different so you'll have to check on that, but it
> would basically consist of taking your old config file and just making
> a few syntax tweaks.

Yep, I've spent plenty of time editing grub2's grub.conf files.

> I do suggest at least giving grub-mkconfig a try though.

I've used it on plenty of other distros and didn't like it -- maybe
it's better on Gentoo...

> Basically grub2 is a completely inert package.  The stuff in
> /usr/bin and so on doesn't do anything unless you explicitly run it.
> The bootloader reads its config file and does what it says, just
> like the old one.  The bootloader won't even be there unless you
> explicitly install it, just as with the old grub.

OK, that sounds reasonable.  I should have had more faith in the
Gentoo devs.

> The one issue you're going to have is finding documentation on the
> config file.

It's pretty well documented in the grub2 manual:

https://www.gnu.org/software/grub/manual/grub/grub.html#Shell_002dlike-scripting
https://www.gnu.org/software/grub/manual/grub/grub.html#Multi_002dboot-manual-config
https://www.gnu.org/software/grub/manual/grub/grub.html#Environment
https://www.gnu.org/software/grub/manual/grub/grub.html#Commands

The thing to keep in mind, is that grub.conf is more of a shell-script
than a config file.  Amongh other things, you can define shell
functions that are attached to menu entries. Then, if execution falls
off the bottom of the script, that menu is executed and the selected
shell function executes.

IIRC, you don't actually _have_ to define a menu at all if you don't
want to, but that rather limits your options at boot time...

> There is a TON of docs on running mkconfig, and very little on
> rolling your own, but it definitely can be done.

Not a problem -- I know enough about the config file syntax to do
everything I need to do.

--
Grant Edwards               grant.b.edwards        Yow! UH-OH!!  I put on
                                  at               "GREAT HEAD-ON TRAIN
                              gmail.com            COLLISIONS of the 50's"
                                                   by mistake!!!


Reply | Threaded
Open this post in threaded view
|

Re: minimal grub:2 install? [grub:0 being removed]

Neil Bothwick
In reply to this post by Rich Freeman
On Thu, 17 Jan 2019 18:51:20 -0500, Rich Freeman wrote:

> Basically grub2 is a completely inert package.  The stuff in /usr/bin
> and so on doesn't do anything unless you explicitly run it.  The
> bootloader reads its config file and does what it says, just like the
> old one.  The bootloader won't even be there unless you explicitly
> install it, just as with the old grub.
>
> The one issue you're going to have is finding documentation on the
> config file.  There is a TON of docs on running mkconfig, and very
> little on rolling your own, but it definitely can be done.

You can also replace the generator scripts in /etc/grub with your own,
which is what I did. They are just simple shell scripts that look at the
contents of /boot and generate menu entries. The supplied scripts have to
cover all use cases, which is where much of the bloat comes from, but
scripts for a setup controlled by you can be very simple.


--
Neil Bothwick

The cow is nothing but a machine which makes grass fit for us people to
eat.

attachment0 (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: minimal grub:2 install? [grub:0 being removed]

Neil Bothwick
In reply to this post by Grant Edwards-6
On Thu, 17 Jan 2019 23:34:48 +0000 (UTC), Grant Edwards wrote:

> I'm not worried about the size, I just don't want any of the
> automagical config stuff happening (and would feel safest if it wasn't
> even installed).

Add grub-mkconfig to INSTALL_MASK in make.conf.


Neil Bothwick

Don't let your mind wander, it's too little to be let out alone.

attachment0 (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: minimal grub:2 install? [grub:0 being removed]

Daniel Frey-6
In reply to this post by Grant Edwards-6
On 1/17/19 2:52 PM, Grant Edwards wrote:

> Apparently they're going to try to pry grub-0.97 from my cold dead
> fingers...
>
> Is there any documentation on how to do a basic minimal grub:2
> install?
>
> I really don't want any of the auto-magical, devs know better than I
> do what I want, os-probing, hide all the details from the stupid user,
> config file generator stuff installed.  I just want the bare minimum
> required to boot using a hand-edited grub.conf file.
>
> There doesn't seem to be a USE flag...
>

As someone else mentioned you can mask grub-mkconfig. I didn't bother,
it isn't run automatically.

After looking through docs I was scratching my head and it took me a
while of searching to find a usable grub.cfg file, as permutations I
tried never seemed to work right.

I can share my basic grub.cfg for both EFI and non-EFI to get you started.

Non-EFI grub.cfg:
--------------------
timeout=10
default=0

menuentry 'Gentoo 4.14.83' {
         root=hd0,2
         linux /boot/kernel-4.14.83-gentoo root=PARTUUID=97657954-04
quiet rootfstype=ext4
}


menuentry 'Gentoo 4.14.78' {
         root=hd0,2
         linux /boot/kernel-4.14.78-gentoo root=PARTUUID=97657954-04
quiet rootfstype=ext4
}

menuentry 'Gentoo 4.9.95' {
         root=hd0,2
         linux /boot/kernel-4.9.95-gentoo root=PARTUUID=97657954-04
quiet rootfstype=ext4
}

menuentry 'Gentoo 4.9.76-r1' {
         root=hd0,2
         linux /boot/kernel-4.9.76-gentoo-r1 root=PARTUUID=97657954-04
quiet rootfstype=ext4
}

menuentry "Windows 7" {
         set root=(hd0,1)
         chainloader +1
         boot
}
----------

It boots a few kernels as well as dual boots Windows 7.

For my EFI based NUCs it was a little different:

EFI grub.cfg:
-------------
timeout=0
default=0

# Declare where the Grub modules are located
set prefix=(hd0,gpt2)/grub

# Load EFI video drivers. This device is EFI so keep the
# video mode while booting the linux kernel.
insmod efi_gop
insmod font
if loadfont ${prefix}/fonts/unicode.pf2
then
         insmod gfxterm
         set gfxmode=auto
         set gfxpayload=keep
         terminal_output gfxterm
fi

# Declare boot entries below this line
menuentry 'Gentoo 4.14.83' {
         root=hd0,gpt2
         linux /boot/kernel-4.14.83-gentoo quiet root=/dev/sda4
intel_idle.max_cstate=1
}

menuentry 'Gentoo 4.14.78' {
         root=hd0,gpt2
         linux /boot/kernel-4.14.78-gentoo quiet root=/dev/sda4
intel_idle.max_cstate=1
}

menuentry 'Gentoo 4.9.95' {
         root=hd0,gpt2
         linux /boot/kernel-4.9.95-gentoo quiet root=/dev/sda4
intel_idle.max_cstate=1
}

menuentry 'Gentoo 4.9.76-r1' {
         root=hd0,gpt2
         linux /boot/kernel-4.9.76-gentoo-r1 quiet root=/dev/sda4
intel_idle.max_cstate=1
}
-------------------

This one I had trouble with as the video display wasn't initializing
properly at first. It does work the same as Mint now.

Both examples are the entirety of the grub.cfg and manually set with no
grub-mkconfig.

Dan

Reply | Threaded
Open this post in threaded view
|

Re: minimal grub:2 install? [grub:0 being removed]

Grant Edwards-6
On 2019-01-18, Daniel Frey <[hidden email]> wrote:

> On 1/17/19 2:52 PM, Grant Edwards wrote:
>> Apparently they're going to try to pry grub-0.97 from my cold dead
>> fingers...
>>
>> Is there any documentation on how to do a basic minimal grub:2
>> install?
>>
>> I really don't want any of the auto-magical, devs know better than I
>> do what I want, os-probing, hide all the details from the stupid user,
>> config file generator stuff installed.  I just want the bare minimum
>> required to boot using a hand-edited grub.conf file.
>>
>> There doesn't seem to be a USE flag...
>
> As someone else mentioned you can mask grub-mkconfig. I didn't bother,
> it isn't run automatically.

I should have known that on Gentoo it wouldn't be.  I ought to think
about starting to switch to grub2.  On one of my simpler installs, I
may try out the chainloading from grub to grub2 scheme documented at

https://wiki.gentoo.org/wiki/GRUB2_Migration

I often need to install grub2 in a partition instead of the MBR, and
these are good references.

https://github.com/alberthdev/alberthdev-misc/wiki/Installing-GRUB2-to-a-Partition
https://wiki.archlinux.org/index.php/GRUB#Install_to_partition_or_partitionless_disk

The Arch wiki also has some good tips on manually creating a grub2
config file:

https://wiki.archlinux.org/index.php/GRUB#Custom_grub.cfg

[If you can't find what you're looking for on the Gentoo web site, the
 Arch linux site is an excellent resource.  I've learned to ignore
 Google hits that point to Ubuntu forums...]


Reply | Threaded
Open this post in threaded view
|

Re: minimal grub:2 install? [grub:0 being removed]

Neil Bothwick
In reply to this post by Daniel Frey-6
On Thu, 17 Jan 2019 17:57:40 -0800, Daniel Frey wrote:

> After looking through docs I was scratching my head and it took me a
> while of searching to find a usable grub.cfg file, as permutations I
> tried never seemed to work right.

I found the easiest way was to run grub-mkconfig to get a starting point,
then prune out everything I didn't need.


--
Neil Bothwick

Never ask a geek why, just nod your head and slowly back away

attachment0 (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: minimal grub:2 install? [grub:0 being removed]

Grant Edwards-6
In reply to this post by Grant Edwards-6
On 2019-01-18, Grant Edwards <[hidden email]> wrote:

> On 2019-01-18, Daniel Frey <[hidden email]> wrote:
>
>> As someone else mentioned you can mask grub-mkconfig. I didn't bother,
>> it isn't run automatically.
>
> I should have known that on Gentoo it wouldn't be.  I ought to think
> about starting to switch to grub2.  On one of my simpler installs, I
> may try out the chainloading from grub to grub2 scheme documented at
>
> https://wiki.gentoo.org/wiki/GRUB2_Migration

I had some spare time while watching a Windows 10 machine while away a
few hours doing updates (WTF does it take so long?  Is it rebuilding
everything from sources?). So, I decided to give the above migration
scheme a try on one of my "simple" machines, and it worked swimmingly
except the auto-generated grub.cfg file fell over.  I was not
surprised. The kernel started to boot, but then locked up at the point
where the video mode switches.

Fortunately, the chainloading scheme allows you to reboot into a
working system via grub-0.97 and tweak things until grub-2 works. I
manually created a grub.cfg file, and it worked fine.  Then I did a
final 'grub2-install', uninstalled grub:0, and all that's left is to
clean the grub:0 files out of /boot/grub.

I'm still amazed by the giant mess that grub2-mkconfig spits out.
It's 90X larger than my manually generated config file:

# grub2-mkconfig 2>/dev/null | wc
    438    1661   17888

# wc boot/grub/grub.cfg
     10      17     200 boot/grub/grub.cfg

--
Grant Edwards               grant.b.edwards        Yow! But they went to MARS
                                  at               around 1953!!
                              gmail.com            


Reply | Threaded
Open this post in threaded view
|

Re: minimal grub:2 install? [grub:0 being removed]

Mick-10
On Friday, 18 January 2019 20:57:45 GMT Grant Edwards wrote:

> On 2019-01-18, Grant Edwards <[hidden email]> wrote:
> > On 2019-01-18, Daniel Frey <[hidden email]> wrote:
> >> As someone else mentioned you can mask grub-mkconfig. I didn't bother,
> >> it isn't run automatically.
> >
> > I should have known that on Gentoo it wouldn't be.  I ought to think
> > about starting to switch to grub2.  On one of my simpler installs, I
> > may try out the chainloading from grub to grub2 scheme documented at
> >
> > https://wiki.gentoo.org/wiki/GRUB2_Migration
>
> I had some spare time while watching a Windows 10 machine while away a
> few hours doing updates (WTF does it take so long?  Is it rebuilding
> everything from sources?). So, I decided to give the above migration
> scheme a try on one of my "simple" machines, and it worked swimmingly
> except the auto-generated grub.cfg file fell over.  I was not
> surprised. The kernel started to boot, but then locked up at the point
> where the video mode switches.
>
> Fortunately, the chainloading scheme allows you to reboot into a
> working system via grub-0.97 and tweak things until grub-2 works. I
> manually created a grub.cfg file, and it worked fine.  Then I did a
> final 'grub2-install', uninstalled grub:0, and all that's left is to
> clean the grub:0 files out of /boot/grub.
>
> I'm still amazed by the giant mess that grub2-mkconfig spits out.
> It's 90X larger than my manually generated config file:
>
> # grub2-mkconfig 2>/dev/null | wc
>     438    1661   17888
>
> # wc boot/grub/grub.cfg
>      10      17     200 boot/grub/grub.cfg
There's also extlinux of the syslinux project.  I'm thinking of giving this a
spin on an old system of mine.  It's pretty minimalist, doesn't need re-
installing after adding a new kernel[1] and it will boot FAT, NTFS, ext2/3/4,
Btrfs, XFS, UFS/FFS, so it should cover my needs.

[1] I'm used to manually editing /boot/grub/grub.conf with legacy grub anyway,
so extlinux is no different.
--
Regards,
Mick

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: minimal grub:2 install? [grub:0 being removed]

William Hubbs
In reply to this post by Neil Bothwick
On Fri, Jan 18, 2019 at 08:33:39AM +0000, Neil Bothwick wrote:
> On Thu, 17 Jan 2019 17:57:40 -0800, Daniel Frey wrote:
>
> > After looking through docs I was scratching my head and it took me a
> > while of searching to find a usable grub.cfg file, as permutations I
> > tried never seemed to work right.
>
> I found the easiest way was to run grub-mkconfig to get a starting point,
> then prune out everything I didn't need.

You have a lot of control over what grub-mkconfig does; there is not
anything auto-magical about it. ;-)

The configuration is controlled by /etc/default/grub and the generator scripts
are in /etc/grub.d. Yes a default is provided, but this is all
customizable.

William


signature.asc (201 bytes) Download Attachment