Gentoo Archives: gentoo-user

From: Wolf Canis <wolf.canis@××××××××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Re: grub weirdness
Date: Wed, 07 May 2008 02:57:56
Message-Id: 48211AA4.8020909@googlemail.com
In Reply to: [gentoo-user] Re: grub weirdness by "Sven Köhler"
1 Sven Köhler wrote:
2 >> When you emerged grub-0.97-r5, this was displayed on your console:
3 >> WARN: postinst
4 >> *** IMPORTANT NOTE: you must run grub and install
5 >> the new version's stage1 to your MBR. Until you do,
6 >> stage1 and stage2 will still be the old version, but
7 >> later stages will be the new version, which could
8 >> cause problems such as an unbootable system.
9 >
10 > Yes, the ebuild writes that to the screen.
11 >
12 > But silently, in the background (because every output is piped to
13 > /dev/null - how evil!), the ebuild calls grub with some commands
14 > inside your grub.conf.
15
16 I just updated grub to version 0.97-r5 and this was,
17 at the end, displayed:
18
19 To avoid automounting and autoinstalling with /boot,
20 just export the DONT_MOUNT_BOOT variable.
21
22
23 Your boot partition was not mounted as /boot, but portage
24 was able to mount it without additional intervention.
25 Files will be installed there for grub to function correctly.
26
27 *** IMPORTANT NOTE: you must run grub and install
28 the new version's stage1 to your MBR. Until you do,
29 stage1 and stage2 will still be the old version, but
30 later stages will be the new version, which could
31 cause problems such as an unbootable system.
32 Copying files from /lib/grub and /usr/lib/grub to //boot/grub
33 To install grub files to another device (like a usb stick), just run:
34 emerge --config =grub-0.97-r5
35
36 >
37 > If there's a setup-command in your grub.conf, it is indeed executed.
38 > So if that command is outdated (something you won't notice, since that
39 > command is not used by grub in any situation i know), the ebuild will
40 > execute that setup-command and write to some device's boot sector. How
41 > evil, again!
42 >
43 > Regards,
44 > Sven
45 >
46 > P.S.: here's the code from grub-0.97-r5.ebuild:
47 >
48 > if [[ -e ${dir}/grub.conf ]] ; then
49 > egrep \
50 > -v
51 > '^[[:space:]]*(#|$|default|fallback|initrd|password|splashimage|timeout|title)'
52 > \
53 > "${dir}"/grub.conf | \
54 > /sbin/grub --batch \
55 > --device-map="${dir}"/device.map \
56 > > /dev/null
57 > fi
58 And following the code of the functions which does the job:
59 found in ebuild: /usr/portage/sys-boot/grub/grub-0.97-r5.ebuild
60
61 setup_boot_dir() {
62 local boot_dir=$1
63 local dir=${boot_dir}
64
65 [[ ! -e ${dir} ]] && die "${dir} does not exist!"
66 [[ ! -L ${dir}/boot ]] && ln -s . "${dir}/boot"
67 dir="${dir}/grub"
68 if [[ ! -e ${dir} ]] ; then
69 mkdir "${dir}" || die "${dir} does not exist!"
70 fi
71
72 # change menu.lst to grub.conf
73 if [[ ! -e ${dir}/grub.conf ]] && [[ -e ${dir}/menu.lst ]] ; then
74 mv -f "${dir}"/menu.lst "${dir}"/grub.conf
75 ewarn
76 ewarn "*** IMPORTANT NOTE: menu.lst has been renamed to grub.conf"
77 ewarn
78 fi
79
80 if [[ -e ${dir}/stage2 ]] ; then
81 mv "${dir}"/stage2{,.old}
82 ewarn "*** IMPORTANT NOTE: you must run grub and install"
83 ewarn "the new version's stage1 to your MBR. Until you do,"
84 ewarn "stage1 and stage2 will still be the old version, but"
85 ewarn "later stages will be the new version, which could"
86 ewarn "cause problems such as an unbootable system."
87 ebeep
88 fi
89
90 einfo "Copying files from /lib/grub and /usr/lib/grub to ${dir}"
91 for x in "${ROOT}"/lib*/grub/*/* "${ROOT}"/usr/lib*/grub/*/* ; do
92 [[ -f ${x} ]] && cp -p "${x}" "${dir}"/
93 done
94
95 if [[ -e ${dir}/grub.conf ]] ; then
96 egrep \
97 -v
98 '^[[:space:]]*(#|$|default|fallback|initrd|password|splashimage|timeout|title)'
99 \
100 "${dir}"/grub.conf | \
101 /sbin/grub --batch \
102 --device-map="${dir}"/device.map \
103 > /dev/null
104 fi
105
106 # the grub default commands silently piss themselves if
107 # the default file does not exist ahead of time
108 if [[ ! -e ${dir}/default ]] ; then
109 grub-set-default --root-directory="${boot_dir}" default
110 fi
111 }
112
113
114 How you can see isn't the message piped to /dev/null, only
115 the command "/sbin/grub -batch -device-map...".
116
117 Have fun,
118 W. Canis

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies

Subject Author
[gentoo-user] Re: grub weirdness "Sven Köhler" <skoehler@×××.de>