2001-12-23 14:40:47

by Harald Dunkel

[permalink] [raw]
Subject: Patch: Support for grub at installation time

diff -cr linux.orig/Documentation/kbuild/commands.txt linux/Documentation/kbuild/commands.txt
*** linux.orig/Documentation/kbuild/commands.txt Fri Jul 28 21:50:51 2000
--- linux/Documentation/kbuild/commands.txt Sun Dec 23 14:36:09 2001
***************
*** 24,38 ****
text interface, or 'make xconfig' for an X interface using TCL/TK.

'make bzImage' will leave your new kernel image in arch/i386/boot/bzImage.
! You can also use 'make bzdisk' or 'make bzlilo'.

! See the lilo documentation for more information on how to use lilo.
You can also use the 'loadlin' program to boot Linux from MS-DOS.

Some computers won't work with 'make bzImage', either due to hardware
problems or very old versions of lilo or loadlin. If your kernel image
! is small, you may use 'make zImage', 'make zdisk', or 'make zlilo'
! on theses systems.

If you find a file name 'vmlinux' in the top directory of the source tree,
just ignore it. This is an intermediate file and you can't boot from it.
--- 24,38 ----
text interface, or 'make xconfig' for an X interface using TCL/TK.

'make bzImage' will leave your new kernel image in arch/i386/boot/bzImage.
! You can also use 'make bzdisk', 'make bzgrub' or 'make bzlilo'.

! See the documentation for more information on how to use lilo or grub.
You can also use the 'loadlin' program to boot Linux from MS-DOS.

Some computers won't work with 'make bzImage', either due to hardware
problems or very old versions of lilo or loadlin. If your kernel image
! is small, you may use 'make zImage', 'make zdisk', 'make zgrub', or
! 'make zlilo' on theses systems.

If you find a file name 'vmlinux' in the top directory of the source tree,
just ignore it. This is an intermediate file and you can't boot from it.
diff -cr linux.orig/Documentation/kbuild/makefiles.txt linux/Documentation/kbuild/makefiles.txt
*** linux.orig/Documentation/kbuild/makefiles.txt Tue Feb 13 23:13:42 2001
--- linux/Documentation/kbuild/makefiles.txt Sun Dec 23 14:39:49 2001
***************
*** 427,432 ****
--- 427,433 ----
bootpfile alpha, ia64
bzImage i386, m68k
bzdisk i386
+ bzgrub i386
bzlilo i386
compressed i386, m68k, mips, mips64, sh
dasdfmt s390
***************
*** 446,451 ****
--- 447,453 ----
zImage arm, i386, m68k, mips, mips64, ppc, sh
zImage.initrd ppc
zdisk i386, mips, mips64, sh
+ zgrub i386
zinstall arm
zlilo i386
znetboot.initrd ppc
diff -cr linux.orig/arch/i386/Makefile linux/arch/i386/Makefile
*** linux.orig/arch/i386/Makefile Thu Apr 12 21:20:31 2001
--- linux/arch/i386/Makefile Sun Dec 23 13:37:16 2001
***************
*** 111,116 ****
--- 111,117 ----
FORCE: ;

.PHONY: zImage bzImage compressed zlilo bzlilo zdisk bzdisk install \
+ zgrub bzgrub \
clean archclean archmrproper archdep

zImage: vmlinux
***************
*** 128,133 ****
--- 129,140 ----
@$(MAKEBOOT) BOOTIMAGE=bzImage zlilo
bzlilo: vmlinux
@$(MAKEBOOT) BOOTIMAGE=bzImage zlilo
+
+ zgrub: vmlinux
+ @$(MAKEBOOT) BOOTIMAGE=zImage zgrub
+
+ bzgrub: vmlinux
+ @$(MAKEBOOT) BOOTIMAGE=bzImage zgrub

zdisk: vmlinux
@$(MAKEBOOT) BOOTIMAGE=zImage zdisk
diff -cr linux.orig/arch/i386/boot/Makefile linux/arch/i386/boot/Makefile
*** linux.orig/arch/i386/boot/Makefile Sun Aug 5 22:13:19 2001
--- linux/arch/i386/boot/Makefile Sun Dec 23 13:48:10 2001
***************
*** 36,41 ****
--- 36,46 ----
cp $(TOPDIR)/System.map $(INSTALL_PATH)/
if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi

+ zgrub: $(CONFIGURE) $(BOOTIMAGE)
+ cat $(BOOTIMAGE) > /boot/vmlinuz-$(KERNELRELEASE)
+ cp $(TOPDIR)/System.map /boot/System.map-$(KERNELRELEASE)
+ if [ -x /sbin/update-grub ]; then /sbin/update-grub; fi
+
install: $(CONFIGURE) $(BOOTIMAGE)
sh -x ./install.sh $(KERNELRELEASE) $(BOOTIMAGE) $(TOPDIR)/System.map "$(INSTALL_PATH)"


Attachments:
grub.patch (3.83 kB)

2001-12-23 15:06:30

by Keith Owens

[permalink] [raw]
Subject: Re: Patch: Support for grub at installation time

On Sun, 23 Dec 2001 15:39:59 +0100,
Harald Dunkel <[email protected]> wrote:
>Below you can find a tiny patch to add 2 new targets to the top level
>Makefile: bzgrub and zgrub. This is a suggestion about how the Grub

I am removing all the special targets that have crept into kbuild,
including zlilo, I do not want to add any new boot targets. It is the
job of the kernel makefiles to build the kernel, install the kernel and
modules and that is all. Anything after the kernel and modules have
been installed is not the job of kbuild. There is too much special
case code in the kernel makefiles, some of which only works for a few
users.

All is not lost, however. kbuild 2.5 has a config option to run a
post-install script. You can specify any script that you want and that
script is responsible for doing whatever you want after the kernel and
modules install. There is a sample in scripts/lilo_new_kernel:

#!/bin/sh
#
# This is a sample script to add a new kernel to /etc/lilo.conf. If it
# does not do what you want, copy this script to somewhere outside the
# kernel, change the copy and point your .config at the modified copy.
# Then you do not need to change the script when you upgrade your kernel.
#

label=$(echo "$KERNELRELEASE" | cut -c1-15)
if ! grep "label=$label\$" /etc/lilo.conf > /dev/null
then
ed /etc/lilo.conf > /dev/null 2>&1 <<EODATA
/^image/
i
image=$CONFIG_INSTALL_PREFIX_NAME$CONFIG_INSTALL_KERNEL_NAME
label=$label
optional

.
w
q
EODATA
if [ ! $? ]
then
echo edit of /etc/lilo.conf failed
exit 1
fi
fi
lilo


The problem with embedding boot loader data in kbuild is that everybody
wants their boot to do something slightly different. In the past they
had to patch the kernel makefiles to do what they wanted, which shows
it was a bad design.

In kbuild 2.5, lilo users invoke scripts/lilo_new_kernel as the post
install script. If they want something different, copy lilo_new_kernel
to their own directory and tell kbuild to use the local copy. No more
patching kernel makefiles for local changes.

grub will be handled the same. kbuild 2.5 can supply a sample
scripts/grub_new_kernel which users can use as is or copy and change to
their own requirements. I will take a sample grub script, I will not
take a new target in the makefiles.

2001-12-23 15:15:43

by Christoph Hellwig

[permalink] [raw]
Subject: Re: Patch: Support for grub at installation time

In article <[email protected]> you wrote:
> Below you can find a tiny patch to add 2 new targets to the top level
> Makefile: bzgrub and zgrub. This is a suggestion about how the Grub
> boot loader could be supported.

Please provide a grub-specific /sbin/installkernel instead.
The lilo targets should die aswell, IMHO.

> It would be nice if you could consider this patch to be included in
> one of the future kernels. I am not the kernel patch specialist, so
> please excuse if I missed to follow a specific procedure.

No. The kernel build process shouldn't know at all about boot loaders.

Christoph (a happy grub user)

--
Of course it doesn't work. We've performed a software upgrade.

2001-12-23 20:55:09

by Harald Dunkel

[permalink] [raw]
Subject: Re: Patch: Support for grub at installation time

Keith Owens wrote:
>
> On Sun, 23 Dec 2001 15:39:59 +0100,
> Harald Dunkel <[email protected]> wrote:
> >Below you can find a tiny patch to add 2 new targets to the top level
> >Makefile: bzgrub and zgrub. This is a suggestion about how the Grub
>
> I am removing all the special targets that have crept into kbuild,
> including zlilo, I do not want to add any new boot targets. It is the
> job of the kernel makefiles to build the kernel, install the kernel and
> modules and that is all. Anything after the kernel and modules have
> been installed is not the job of kbuild. There is too much special
> case code in the kernel makefiles, some of which only works for a few
> users.
>
> All is not lost, however. kbuild 2.5 has a config option to run a
> post-install script. You can specify any script that you want and that
> script is responsible for doing whatever you want after the kernel and
> modules install. There is a sample in scripts/lilo_new_kernel:
>

Currently there are just 2 ways to install the freshly build kernel
outside of the source tree: 'make bzlilo' and 'make install'. Both
call lilo, if the executable can be found. Its good to hear that this
is going to be removed.

My patch is not for kbuild 2.5, but for the current Makefiles in the
kernel sources. I am eager to check the new features you provide when
kbuild 2.5 or a newer version is included for one of the future kernels,
but since then I would suggest to consider my patch.

If you have kbuild for 2.4.16 completed, please send me a note. I would
like to try it.


Regards

Harri

2001-12-23 21:15:20

by Harald Dunkel

[permalink] [raw]
Subject: Re: Patch: Support for grub at installation time

Harald Dunkel wrote:
>
> If you have kbuild for 2.4.16 completed, please send me a note. I would
> like to try it.
>
2.4.17, of course.

Harri

2001-12-23 22:17:33

by H. Peter Anvin

[permalink] [raw]
Subject: Re: Patch: Support for grub at installation time

Followup to: <[email protected]>
By author: Harald Dunkel <[email protected]>
In newsgroup: linux.dev.kernel
>
> Currently there are just 2 ways to install the freshly build kernel
> outside of the source tree: 'make bzlilo' and 'make install'. Both
> call lilo, if the executable can be found. Its good to hear that this
> is going to be removed.
>

"make install" *DEFAULTS* to calling LILO (in a fairly useless manner,
IMNSHO.) In practice it calls /sbin/installkernel, which is where you
should put your LILO/GRUB/whathaveyou configuration stuff.

-hpa
--
<[email protected]> at work, <[email protected]> in private!
"Unix gives you enough rope to shoot yourself in the foot."
http://www.zytor.com/~hpa/puzzle.txt <[email protected]>

2001-12-24 12:29:58

by Chmouel Boudjnah

[permalink] [raw]
Subject: Re: Patch: Support for grub at installation time

Harald Dunkel <[email protected]> writes:

> It would be nice if you could consider this patch to be included in
> one of the future kernels. I am not the kernel patch specialist, so
> please excuse if I missed to follow a specific procedure.

Looking at your patch :

+ if [ -x /sbin/update-grub ]; then /sbin/update-grub; fi

This is distro specific. We should leave that job to installkernel up
to the vendors to customing it.