Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Grub - Boot Sequence.

75 views
Skip to first unread message

Kanjana

unread,
Aug 10, 2012, 2:28:15 AM8/10/12
to
Hi Guys/Gals,

I just removed Linux Mint 13 (Maya) from my machine and successfully
replaced it with LMDE 201204 with Mate and Mint menu.

I then installed Ubuntu 12.04 LTS and have now a workable dual-boot
set-up, however the grub menu displays Ubuntu before LMDE.

I wanted to change the boot sequence so that LMDE starts-up first
(automatically after about 10 seconds or so).

So, I went into the Ubuntu Teminal:

sudo gedit /etc/etc/default/grub

to edit the file accordingly but this proved to be a little too
confusing & complex for my limited knowledge (I can not identify the
right items to move). I then looked at "info -f grub" but this is all
too technical for me also. Before botching up the grub menu could
somebody please have a look at the document and change it so that LMDE
starts up before Ubuntu, thanks.

Start of document.
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
# info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0
#GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to
Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"
End of document.





Kees Theunissen

unread,
Aug 10, 2012, 3:18:36 AM8/10/12
to
Kanjana wrote:
> Hi Guys/Gals,
>
> I just removed Linux Mint 13 (Maya) from my machine and successfully
> replaced it with LMDE 201204 with Mate and Mint menu.
>
> I then installed Ubuntu 12.04 LTS and have now a workable dual-boot
> set-up, however the grub menu displays Ubuntu before LMDE.
>
> I wanted to change the boot sequence so that LMDE starts-up first
> (automatically after about 10 seconds or so).

You can't change the the ordering of the items in the boot menu
as far as I know (unless you change the scripts generating the
menu). But you can specify which menu item must be selected by
default.

> So, I went into the Ubuntu Teminal:
>
> sudo gedit /etc/etc/default/grub
>
> to edit the file accordingly but this proved to be a little too
> confusing & complex for my limited knowledge (I can not identify the
> right items to move). I then looked at "info -f grub" but this is all
> too technical for me also. Before botching up the grub menu could
> somebody please have a look at the document and change it so that LMDE
> starts up before Ubuntu, thanks.
>
> Start of document.
> # If you change this file, run 'update-grub' afterwards to update
> # /boot/grub/grub.cfg.
> # For full documentation of the options in this file, see:
> # info -f grub -n 'Simple configuration'

So start: info -f grub -n 'Simple configuration'
and look for GRUB_DEFAULT

> GRUB_DEFAULT=0

This says that the first menu item must be selected by default. Items
are counted from 0. "0" is the first item, "1" the second, and so on.
Instead of specifying a number you can also give the full name of the
menu item you want to select.


Regards,

Kees.

--
Kees Theunissen.

Sherman Croud

unread,
Aug 10, 2012, 3:51:42 AM8/10/12
to
On 10/08/12 14:18, Kees Theunissen wrote:
>> Kanjana wrote:
>> Hi Guys/Gals,

>> I wanted to change the boot sequence so that LMDE starts-up first
>> (automatically after about 10 seconds or so).

> This says that the first menu item must be selected by default. Items
> are counted from 0. "0" is the first item, "1" the second, and so on.
> Instead of specifying a number you can also give the full name of the
> menu item you want to select.

Would I have a home-run if I were to change the script like this?

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_DEFAULT=0
#GRUB_HIDDEN_TIMEOUT=0

Please confirm or correct, thanks.

Ole Christensen

unread,
Aug 10, 2012, 6:06:36 AM8/10/12
to
On 2012-08-10 08:28, Kanjana wrote:
> Hi Guys/Gals,
>
> I just removed Linux Mint 13 (Maya) from my machine and successfully
> replaced it with LMDE 201204 with Mate and Mint menu.
>
> I then installed Ubuntu 12.04 LTS and have now a workable dual-boot
> set-up, however the grub menu displays Ubuntu before LMDE.
>
> I wanted to change the boot sequence so that LMDE starts-up first
> (automatically after about 10 seconds or so).

You could do it like this:
Booting LMDE,...
# sudo grub-install /dev/sdX, (where X most likely are a, (sda)),
now You boot default to LMDE,...

Then, if, LMDE are based on Debian install StartUp-Manager,...
(anybody know why this disappear from Ubuntu,...?)

Then i change 3 lines in /etc/default/grub to this:

GRUB_DISTRIBUTOR=`lsb_release -d -s 2> /dev/null || echo Debian`
GRUB_DISABLE_LINUX_UUID=true # i hate UUID
GRUB_DISABLE_RECOVERY="true" # if more than one dist don't need

and # sudo update-grub
(must be done for all dist installed)

<ole>

Kees Theunissen

unread,
Aug 10, 2012, 7:28:25 AM8/10/12
to
Sherman Croud wrote:
> On 10/08/12 14:18, Kees Theunissen wrote:
>>> Kanjana wrote:
>>> Hi Guys/Gals,
>
>>> I wanted to change the boot sequence so that LMDE starts-up first
>>> (automatically after about 10 seconds or so).
>
>> This says that the first menu item must be selected by default. Items
>> are counted from 0. "0" is the first item, "1" the second, and so on.
>> Instead of specifying a number you can also give the full name of the
>> menu item you want to select.
>
> Would I have a home-run if I were to change the script like this?

For home-runs you need to play aonther kind of game. ;-)

Are you the original poster BTW?. Conversation will be easier if
participants use the same name during the whole thread.

> GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
> GRUB_CMDLINE_LINUX=""
> GRUB_HIDDEN_TIMEOUT_QUIET=true
> GRUB_TIMEOUT=10
> GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
> GRUB_DEFAULT=0
> #GRUB_HIDDEN_TIMEOUT=0

I don't see any difference, apart from the line ordering,
between this and the similar part from the original message.
Changing the order of the statements in /etc/default/grub
won't influence the boot menu.

Adjust the value of GRUB_DEFAULT to select a different boot
menu item as default.
GRUB_DEFAULT=0 selects the first item of the boot menu,
GRUB_DEFAULT=1 selects the second item,
GRUB_DEFAULT=2 selects the third item, etc.

Run 'update-grub' afterwards as mentioned in the start of the document.

Lars Enderin

unread,
Aug 10, 2012, 7:45:37 AM8/10/12
to
This is what I use to boot with the same system as I did the last time:

GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT="true"


>
> Run 'update-grub' afterwards as mentioned in the start of the document.

--
Lars Enderin

Skeezix LaRocca

unread,
Aug 10, 2012, 9:04:30 AM8/10/12
to
Don't take my word for it as I'm just a rank novice, but i downloaded
"Startup Manager" from the package manager & it has never failed me.

It allows me to set my default distro & I can set the time for auto start.
--
Dr. Skeezix LaRocca, D.B. (Doctor Of Buffoonery)
Registered Linux Novice & Abuser #526706
We aren't cheap, but we're reasonable
No appointment needed

TheGlimmerMan

unread,
Aug 10, 2012, 8:26:31 PM8/10/12
to
On Fri, 10 Aug 2012 09:18:36 +0200, Kees Theunissen <theu...@rijnh.nl>
wrote:

>Kanjana wrote:
>> Hi Guys/Gals,
>>
>> I just removed Linux Mint 13 (Maya) from my machine and successfully
>> replaced it with LMDE 201204 with Mate and Mint menu.
>>
>> I then installed Ubuntu 12.04 LTS and have now a workable dual-boot
>> set-up, however the grub menu displays Ubuntu before LMDE.
>>
>> I wanted to change the boot sequence so that LMDE starts-up first
>> (automatically after about 10 seconds or so).
>
>You can't change the the ordering of the items in the boot menu
>as far as I know (unless you change the scripts generating the
>menu). But you can specify which menu item must be selected by
>default.
>

You can,butit requires editing the probe script and changing the order
things get probed and subsequently posted to the cfg file with.

>> So, I went into the Ubuntu Teminal:
>>
>> sudo gedit /etc/etc/default/grub
>>
>> to edit the file accordingly but this proved to be a little too
>> confusing & complex for my limited knowledge (I can not identify the
>> right items to move). I then looked at "info -f grub" but this is all
>> too technical for me also. Before botching up the grub menu could
>> somebody please have a look at the document and change it so that LMDE
>> starts up before Ubuntu, thanks.
>>
>> Start of document.
>> # If you change this file, run 'update-grub' afterwards to update
>> # /boot/grub/grub.cfg.
>> # For full documentation of the options in this file, see:
>> # info -f grub -n 'Simple configuration'
>
>So start: info -f grub -n 'Simple configuration'
>and look for GRUB_DEFAULT
>
>> GRUB_DEFAULT=0
>
>This says that the first menu item must be selected by default. Items
>are counted from 0. "0" is the first item, "1" the second, and so on.
>Instead of specifying a number you can also give the full name of the
>menu item you want to select.

The other selection is "saved", which boots the previously selected
entry.

Best bet is to install BURG, and then all kinds of custom configurations
can be utilized.

BURG is an alternate boot loader based on Grub II.

It also allows for a graphical boot menu to be implemented.

I thought I did pretty good, considering that it is a 1080 HD screen.

http://www.flickr.com/photos/48373875@N06/7755915738/

TheGlimmerMan

unread,
Aug 10, 2012, 8:29:25 PM8/10/12
to
He can manually re=position the menu entries, but would have to each
time grub updates itself.

The only other way is to change the order the OS probing engine looks
for OSes, and then enters them into the cfg file.

Kanjana

unread,
Aug 11, 2012, 3:16:21 AM8/11/12
to
On 08/10/12 18:28, Kees Theunissen wrote:
> Sherman Croud wrote:

>> Would I have a home-run if I were to change the script like this?
> For home-runs you need to play another kind of game. ;-)

No games! My request for assistance is/was genuine.

> Are you the original poster BTW?. Conversation will be easier if
> participants use the same name during the whole thread.

Yes, I am the original poster who in an preoccupied manner responded
from my husband's desk-top computer. Mea culpa for causing confusion -
so sorry very big! And thanks to everyone for continuous responds.
Best wishes... Kanjana.

Kanjana

unread,
Aug 11, 2012, 3:56:35 AM8/11/12
to
On 08/10/12 13:28, Kanjana wrote:
> Hi Guys/Gals,

[snip]

> ...the grub menu displays Ubuntu before LMDE.

> I wanted to change the boot sequence so that LMDE starts-up first
> (automatically after about 10 seconds or so).

I installed the Grub Customizer and was able to change the boot
sequence, thanks.

mechanic

unread,
Aug 11, 2012, 5:03:58 AM8/11/12
to
On Fri, 10 Aug 2012 17:26:31 -0700, TheGlimmerMan wrote:

>>You can't change the the ordering of the items in the boot menu
>>as far as I know (unless you change the scripts generating the
>>menu). But you can specify which menu item must be selected by
>>default.
>>
>
> You can,butit requires editing the probe script and changing the
> order things get probed and subsequently posted to the cfg file
> with.

It just requires renaming the files in the /etc/grub.d/ directory,
which have names beginning with a number and are loaded into the
menu in order of the name. Just change the number at the beginning
of the names to reorder the list (then run sudo update-grub to
rewrite the grub.cfg file).

J G Miller

unread,
Aug 11, 2012, 5:21:41 AM8/11/12
to
On Saturday, August 11th, 2012, at 10:03:58h +0100, Mechanic wrote:

> It just requires renaming the files in the /etc/grub.d/ directory,
> which have names beginning with a number and are loaded into the
> menu in order of the name.

This is not only bad advice but incorrect.

The files in /etc/grub.d directory are shell scripts which are
run in the order of their number. When these shell scripts
are run in sequence (via update-grub) they create the grub
configuration file in /boot/grub/grub.cfg. So if you change
the order of them, you could end up with a totally unusuable
grub.cg.

For example the first script 00_header contains this

# Do this as early as possible, since other commands might depend on it.
# (e.g. the `loadfont' command might need lvm or raid modules)
for i in ${GRUB_PRELOAD_MODULES} ; do
echo "insmod $i"
done

And as the name of the script implies, this writes the header
of the top of the grub.cfg file, which obviously will be ineffective
if it is not placed first in the grub.cfg file.

Thus unless you know exactly what each script is doing and how they
depend on one another, changing the order of the scripts is a higly
dangerous thing to do, and offering this advice to somebody who writes

"this is all too technical for me also"

is either very foolish advice or malicious.

Furthermore, the detection of the Linux based OS is all done by
the same script 30_os_prober so renumbering the scripts is not
going to change the order of the Linux based OS that 30_os_prober
writes to the grub.cfg, so your advice to change the order in
grub.cfg of the Linux based OSes is invalid.

Ole Christensen

unread,
Aug 11, 2012, 5:23:38 AM8/11/12
to
on 2012-08-11 02:29, TheGlimmerMan wrote:

> He can manually re=position the menu entries,

No one was talking about "manually re=position the menu entries",...!

> but would have to each time grub updates itself.

grub don't updates itself,...

When a new kernel are in updates update-grub are run,

that's also the reason for why just changing the default
number don't work,...

When grub are updated grub-install are run only one
or two times a year, (Ubuntu),... (by mistake (?))

> The only other way is to change the order the OS probing engine looks
> for OSes, and then enters them into the cfg file.

Now the Q was how to change the default boot to the
distro installed before the last installed distro,
and not how to change / re=position the hole menu,...

<ole>

Bit Twister

unread,
Aug 11, 2012, 7:13:54 AM8/11/12
to
On Sat, 11 Aug 2012 09:21:41 +0000 (UTC), J G Miller wrote:

> Furthermore, the detection of the Linux based OS is all done by
> the same script 30_os_prober so renumbering the scripts is not
> going to change the order of the Linux based OS that 30_os_prober
> writes to the grub.cfg, so your advice to change the order in
> grub.cfg of the Linux based OSes is invalid.

Hmmmmm, looking at
http://www.gnu.org/software/grub/manual/grub.html#Simple-configuration
would seem to suggest otherwise. :)

I can agree with warning the "too technical for me" about the danger
and indicating they should know how to boot a rescue cd and know how
to back out their changes.

Bit Twister

unread,
Aug 11, 2012, 7:25:10 AM8/11/12
to
On Sat, 11 Aug 2012 11:23:38 +0200, Ole Christensen wrote:

> Now the Q was how to change the default boot to the
> distro installed before the last installed distro,
> and not how to change / re=position the hole menu,...

My recommendation would be to create a /etc/grub.d/40_my_changes
script to scan grub.cfg to to locate the preferred default distro and
modify the GRUB_DEFAULT directive.

You would have to remember to copy in 40_my_changes on clean installs. :)

Ole Christensen

unread,
Aug 11, 2012, 8:43:00 AM8/11/12
to
on 2012-08-11 13:25, Bit Twister wrote:> On Sat, 11 Aug 2012 11:23:38
Sure,... and write the 40_my_changes script first of cause,...
do You have some small "recommendation" for that one to,...?
sound "nice" anyway,... not just to go for grub.cfg in the
"other" distro, but make a scan there to,...(?)

In my case the first boot, (and grub), are on Sid,
L/Xububtu are "backup" rescue when Sid screw up,...
Ubuntu, most always updates to new kernel-image witch
force me to: update Ubuntu, boot Sid, run grub-update,
boot L/Xubuntu, remove old kernel-image, boot Sid,
run grub-update,...

<ole>


TheGlimmerMan

unread,
Aug 11, 2012, 9:09:53 AM8/11/12
to
On Sat, 11 Aug 2012 11:23:38 +0200, Ole Christensen
<ole2...@newsguy.com> wrote:

>on 2012-08-11 02:29, TheGlimmerMan wrote:
>
> > He can manually re=position the menu entries,
>
>No one was talking about "manually re=position the menu entries",...!

Did I need you fucktarded permission to mention this valid solution,
you fucking jackass?

NO, I did NOT.

FOAD, you stupid fuck.
>
> > but would have to each time grub updates itself.
>
>grub don't updates itself,...

Yes, it does, whenever the software updates the kernel.

Don't get semantical with me, you fucking retard.
>
>When a new kernel are in updates update-grub are run,

No shit, fucktard. And it is "update-grub IS run., not "are", you
fucking English loser as well.

>that's also the reason for why just changing the default
>number don't work,...

I never said a goddamned thing about changing a number, fuckhead.

>When grub are updated grub-install are run only one
>or two times a year, (Ubuntu),... (by mistake (?))

The term is IS updated, asshole. It is SINGULAR. "ARE" is INCORRECT.

> > The only other way is to change the order the OS probing engine looks
> > for OSes, and then enters them into the cfg file.
>
>Now the Q was how to change the default boot to the
>distro installed before the last installed distro,
>and not how to change / re=position the hole menu,...
>
><ole>

Look, you fucking retard, he wanted to change the order GRUB PLACES it
in the menu. That means that the next update would ALSO have to carry
that change. That means that the PROBING engine has to be modified.
That way when he updates his system, he will not have to go through this
again.

Get a clue, you fucking jackoff.

J G Miller

unread,
Aug 11, 2012, 9:38:49 AM8/11/12
to
On Saturday, August 11th, 2012, at 11:13:54h +0000, Bit Twister pondered:

> Hmmmmm, looking at
> http://www.gnu.org/software/grub/manual/grub.html#Simple-configuration
> would seem to suggest otherwise. :)

No that would not suggest otherwise at all, since the scripts in
/etc/grub.d are used by grub-mkconfig, this being called by
/usr/sbin/update-grub

exec grub-mkconfig -o /boot/grub/grub.cfg "$@"


egrep grub-mkconfig /etc/grub.d/*

/etc/grub.d/00_header: # grub-mkconfig helper script.
/etc/grub.d/00_header: . "${datarootdir}/grub/grub-mkconfig_lib"
/etc/grub.d/05_debian_theme: # grub-mkconfig helper script.
/etc/grub.d/05_debian_theme: # Include the GRUB helper library for grub-mkconfig.
/etc/grub.d/05_debian_theme: . /usr/lib/grub/grub-mkconfig_lib
/etc/grub.d/06_mint_theme: source /usr/lib/grub/grub-mkconfig_lib
/etc/grub.d/10_linux: # grub-mkconfig helper script.
/etc/grub.d/10_linux: . "${datarootdir}/grub/grub-mkconfig_lib"
/etc/grub.d/20_linux_xen: # grub-mkconfig helper script.
/etc/grub.d/20_linux_xen: . "${datarootdir}/grub/grub-mkconfig_lib"
/etc/grub.d/20_memtest86+: if [ -f /usr/lib/grub/grub-mkconfig_lib ]; then
/etc/grub.d/20_memtest86+: . /usr/lib/grub/grub-mkconfig_lib
/etc/grub.d/30_os-prober: # grub-mkconfig helper script.
/etc/grub.d/30_os-prober: . "${datarootdir}/grub/grub-mkconfig_lib"
/etc/grub.d/30_os-prober: echo " ${LONGNAME} is not yet supported by grub-mkconfig." >&2

Bit Twister

unread,
Aug 11, 2012, 10:08:34 AM8/11/12
to
On Sat, 11 Aug 2012 13:38:49 +0000 (UTC), J G Miller wrote:
> On Saturday, August 11th, 2012, at 11:13:54h +0000, Bit Twister pondered:
>
>> Hmmmmm, looking at
>> http://www.gnu.org/software/grub/manual/grub.html#Simple-configuration
>> would seem to suggest otherwise. :)
>
> No that would not suggest otherwise at all,

Go back and read last line, second paragraph. :)

Bit Twister

unread,
Aug 11, 2012, 10:08:56 AM8/11/12
to
On Sat, 11 Aug 2012 14:43:00 +0200, Ole Christensen wrote:

> Sure,... and write the 40_my_changes script first of cause,...

And test/check before booting, of course. :)

> do You have some small "recommendation" for that one to,...?

You bet, first thing is to get your head wrapped around
http://tldp.org/LDP/abs/html/index.html :-D

initialize your default counter to 0
create two functions, find_default and update_grub_cfg

find_default would use a while loop to read grub.cfg.
Every time it found a "### BEGIN /etc/grub.d/"
it would decide it stanza was the desired one and exit function, or
bump the default counter and keep looking.

Best decision maker there wold be a "case" statement because there are
some ### BEGINs that are not boot stanzas.


update_grub function would be called to do the actual update.

> sound "nice" anyway,... not just to go for grub.cfg in the
> "other" distro, but make a scan there to,...(?)

Not real sure what you mean there.


> In my case the first boot, (and grub), are on Sid,
> L/Xububtu are "backup" rescue when Sid screw up,...
> Ubuntu, most always updates to new kernel-image witch
> force me to: update Ubuntu, boot Sid, run grub-update,
> boot L/Xubuntu, remove old kernel-image, boot Sid,
> run grub-update,...

Ok, that would involve a bit more coding.

For me, I would use blkid to parse out the device names for partitions
needing updating.
I used e2label and mkswap to label partitions and swap.

Your loop would then mount the partition, call a function to do the
update and umount the partition.

Some tips, you can use:
o "set" command to parse a line into words ($1, $2, ...),

o ${string:position:length} to extract $length characters substring
from $string at $position (0 relative)

o expr index "$string" $substring to get numerical position in $string
of first character in $substring that matches
If you get a non-zero result you know the string is in the line.


Example while loop would be

while read -r line ; do
set -- $(IFS=' ='; echo $line)
_word_1=$1
_char_1=${line:0:1}

done < $_in_fn


Ole Christensen

unread,
Aug 11, 2012, 11:00:49 AM8/11/12
to
on 2012-08-11 16:08, Bit Twister wrote:
> On Sat, 11 Aug 2012 14:43:00 +0200, Ole Christensen wrote:
>
>> In my case the first boot, (and grub), are on Sid,
>> L/Xububtu are "backup" rescue when Sid screw up,...
>> Ubuntu, most always updates to new kernel-image witch
>> force me to: update Ubuntu, boot Sid, run grub-update,
>> boot L/Xubuntu, remove old kernel-image, boot Sid,
>> run grub-update,...
>
> Ok, that would involve a bit more coding.

Not sure,... but let's say we have:
sda1: distro1, with active grub installed on sda,
sda2: distro2, no active grub,...

when distro2 get a new kernel-image distro2 should
update grub.cfg on sda1 and place itself on say 2de
place if a variable in /etc/default/grub tell so,...

maybe sound not to hard after all,...(?)

<ole>

mechanic

unread,
Aug 11, 2012, 1:00:52 PM8/11/12
to
On Sat, 11 Aug 2012 09:21:41 +0000 (UTC), J G Miller wrote:

> Thus unless you know exactly what each script is doing and how they
> depend on one another, changing the order of the scripts is a higly
> dangerous thing to do, and offering this advice to somebody who writes
>
> "this is all too technical for me also"
>
> is either very foolish advice or malicious.

It wasn't offered as advice to the OP, it was in response to a
previous post - see above in the thread. In practice there aren't
many problems with this approach, you may need to remove os-prober
(last time the distro I used didn't even have this installed), and I
usually find it's best to write individual /etc/grub.d/ files
manually based on simple prototypes, then change permissions for
entries you don't like (like mem test) so they don't appear. It's
not Linux 101 but it isn't rocket science either. And Grub allows
one to test entries and edit the parameters before booting to get it
right by trial and error if necessary.

mechanic

unread,
Aug 11, 2012, 1:03:56 PM8/11/12
to
On Sat, 11 Aug 2012 11:13:54 +0000 (UTC), Bit Twister wrote:

> I can agree with warning the "too technical for me" about the
> danger and indicating they should know how to boot a rescue cd
> and know how to back out their changes.

Re-installing grub2 from a live-CD is relatively painless, and quite
quick, so no need to fear experiments!

Bit Twister

unread,
Aug 11, 2012, 2:14:42 PM8/11/12
to
On Sat, 11 Aug 2012 17:00:49 +0200, Ole Christensen wrote:

> Not sure,... but let's say we have:
> sda1: distro1, with active grub installed on sda,
> sda2: distro2, no active grub,...
>
> when distro2 get a new kernel-image distro2 should
> update grub.cfg on sda1 and place itself on say 2de
> place if a variable in /etc/default/grub tell so,...

I hear where you are coming from but, there is a basic chicken or egg
first problem. In your case, you would have to set a variable in the
"Production/Master" /etc/default/grub.

40_my_changes would then have to hunt down the
"Production/Master" /etc/default/grub file to get/set the variable.

Just keep it simple and put the "Production" information in
40_my_changes so it can know what needs to be done from the start.

Ole Christensen

unread,
Aug 12, 2012, 6:49:20 AM8/12/12
to
on 2012-08-11 20:14, Bit Twister wrote:
> On Sat, 11 Aug 2012 17:00:49 +0200, Ole Christensen wrote:
>
>> Not sure,... but let's say we have:
>> sda1: distro1, with active grub installed on sda,
>> sda2: distro2, no active grub,...
>>
>> when distro2 get a new kernel-image distro2 should
>> update grub.cfg on sda1 and place itself on say 2de
>> place if a variable in /etc/default/grub tell so,...
>
> I hear where you are coming from but, there is a basic chicken or egg
> first problem. In your case, you would have to set a variable in the
> "Production/Master" /etc/default/grub.

As i see it there should be no chicken / egg 1st problem,
but i could have overlook something,...(?)

Of cause a variable have to tell if we are master or guest OS
and who "own" mbr,...

> 40_my_changes would then have to hunt down the
> "Production/Master" /etc/default/grub file to get/set the variable.

Oh,... I almost forgot Your recommended 40_my_changes,...
but don't You think the race are over when we turn 40,...?

00_header # run by master
05_debian_theme # run by master
10_linux # run by master, modify for guest OS
20_linux_xen # i don't need
20_memtest86+ # i don't need
30_os-prober # should not run or modify for master, (WinOS etc)
40_custom # do nothing

Then,... on master, at update, before / in grub-update save
a copy of old grub.cfg and as last copy the contents from
the guest OS into the new grub.cfg,...(?)

> Just keep it simple and put the "Production" information in
> 40_my_changes so it can know what needs to be done from the start.

Sound simple enough to me,...(?)
It's not clear to me what You mean with "Production" information,...?
do You mean something like the output from 'lsb_release -d',...?

<ole>

Bit Twister

unread,
Aug 12, 2012, 9:49:52 AM8/12/12
to
On Sun, 12 Aug 2012 12:49:20 +0200, Ole Christensen wrote:
> on 2012-08-11 20:14, Bit Twister wrote:
> > On Sat, 11 Aug 2012 17:00:49 +0200, Ole Christensen wrote:
> >

> >> when distro2 get a new kernel-image distro2 should
> >> update grub.cfg on sda1 and place itself on say 2de
> >> place if a variable in /etc/default/grub tell so,...

> As i see it there should be no chicken / egg 1st problem,
> but i could have overlook something,...(?)

I like to code for the worst case, disk died, it is a clean install
which does not have the variable in /etc/default/grub let alone know
if the install is to be the Production distro.

Production is defined as the distribution in control of the boot
loader installed into the MBR.


> Of cause a variable have to tell if we are master or guest OS
> and who "own" mbr,...

Master/guest are nice terms except if you have installed VirtualBox.

There, Master would be same as Guest, but you have VirtualBox guests
along with your other distros installed on the Production/Master.


> > 40_my_changes would then have to hunt down the
> > "Production/Master" /etc/default/grub file to get/set the variable.
>
> Oh,... I almost forgot Your recommended 40_my_changes,...
> but don't You think the race are over when we turn 40,...?
>
> 00_header # run by master
> 05_debian_theme # run by master
> 10_linux # run by master, modify for guest OS
> 20_linux_xen # i don't need
> 20_memtest86+ # i don't need
> 30_os-prober # should not run or modify for master, (WinOS etc)
> 40_custom # do nothing

40_my_changes was chosen so it would run after 40_custom and be
somewhat descriptive. Having checked a mint install which has a
40_custom and 41_custom I can recommend using 50_my_changes as the script name.

> Then,... on master, at update, before / in grub-update save
> a copy of old grub.cfg and as last copy the contents from
> the guest OS into the new grub.cfg,...(?)

Now you are starting to see some of the chicken/egg problems. :)
My recommendation is that you always try to code in such a way as to
avoid any manual steps where possible.

In my scripts, I use two names, fn_vorig and fn_vinstall.

_vorig is the vendor installed file.
_install is the copy of fn before I make my modifications.

In my setup, I run my new_install script, install_addons, install_toys
and install_changes. Those scripts run (whatever)_changes. Each of
those scripts check for somefn_vorig and if it does not exist, copies fn to
fn_vorig.
It then copies fn to fn_install and modifies it into fn.

In this case, new_install would call grub_cfg_changes which would have
something like
_fn=/boot/grub/grub.cnf
if [ ! -e "${_fn}_vorig" ] ; then
cp $_fn ${_fn}_vorig
fi

ln -s /local/bin/50_my_changes /etc/grub.d/

> > Just keep it simple and put the "Production" information in
> > 40_my_changes so it can know what needs to be done from the start.
>
> Sound simple enough to me,...(?)
> It's not clear to me what You mean with "Production" information,...?
> do You mean something like the output from 'lsb_release -d',...?

No, that changes on a new release and as in your case, you have other
copies of the same distribution.

First thing you have to decide is what your variable will contain as
the identifier of the Production installation. I label my partitions
so I could use _prod_distro=mga2
to identify the Production distribution.

Instead of using lsb_release, script would have something like
set -- $(df -h /)
_current_partition=$8

It then becomes a simple matter to loop through blkid output

/sbin/blkid
/dev/sda1: LABEL="SYSTEM" UUID="E858B4EB58B4BA20" TYPE="ntfs"
/dev/sda2: LABEL="OS" UUID="4614B60114B5F451" TYPE="ntfs"
/dev/sda4: LABEL="HP_RECOVERY" UUID="2A449E8C449E5A81" TYPE="ntfs"
/dev/sda5: LABEL="dos_d" UUID="07378A593F364047" TYPE="ntfs"
/dev/sda6: LABEL="cauldron" UUID="35f73957-91a80267dda6" TYPE="ext4"
/dev/sda7: LABEL="alpha2" UUID="a1db361e-a05a-4b2c20a416" TYPE="ext4"
/dev/sdb1: LABEL="swap" UUID="f4d61d52-4313-4b1b-adeb-597fb37ece22" TYPE="swap"
/dev/sdb2: LABEL="hotbu" UUID="4beb8f73fc3fb6e" TYPE="ext4"
/dev/sdb3: LABEL="mga1" UUID="ba828" TYPE="ext4"
/dev/sdb5: LABEL="accounts" UUID="ccf256ea-c-bd797f44ca9c" TYPE="ext4"
/dev/sdb6: LABEL="local" UUID="a25dac22-b-bf84c6b23c3d" TYPE="ext4"
/dev/sdb7: LABEL="mga2" UUID="5dddc24b-2e28d198f" TYPE="ext4"
/dev/sdb8: LABEL="2010_2_64" UUID="012bb3468bc" TYPE="ext4"
/dev/sdb9: LABEL="cooker" UUID="751c8a9a51b11" TYPE="ext4"
/dev/sdb10: LABEL="vmguest" UUID="1f22baedc543cb71648" TYPE="ext4"
/dev/sdb11: LABEL="video" UUID="a9736ba47cdea5" TYPE="ext4"



looking for a label with mga2 and comparing
$_current_partition to the /dev/ contents to decide if this
installation is the Production installation.

0 new messages