LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   make grub boot from other partition --> only once (https://www.linuxquestions.org/questions/linux-software-2/make-grub-boot-from-other-partition-only-once-263374/)

bglnelissen 12-06-2004 05:22 PM

make grub boot from other partition --> only once
 
Hi,

I updated my mandrake version from 10.0 to 10.1 I thought it was time for a fresh install. I kept my /home/myname so all my settings were saved (other HD). My girlfriend hates the pinguin computer and she wants to use the 'normal one' with the START menu.

The mandrake 10.0 had the lilo bootloader as default which was ok. Mandrake 10.1 has the Grub bootloader, which is also ok. One thing i can't get done with grub:

Cause my girlfriend wants here START menu every time she uses the computer it needs a reboot to windows, no problemo. (VMWARE not an option)
lilo had this wonderfull function which was:
console:

# lilo -r windows (or something like it)

(put this little script under an icon with a windows logo on your desktop, everybody happy)

what made it reboot directly to windows and not the lilo menu with linux for default. So you dont need to sit next to your computer waiting to get it booted in Windows, in the time you wanted to go to the toilet or whatever.

How is this done with Grub? I tried to make another config file, but that did not work so well.
Installing LILO is too easy! therefor not an option :)

Help will be appreciated.

Greetings Bas


ps
(
opperator, aint it usefull to start a list with all kinds of usefull very small scripts? like:
while [ 1 ];smbstatus -i;sleep 5;done
i think there are a lot of usefull progs and scrips we never thought of.
)

Samsara 12-06-2004 06:14 PM

This has not afaik been implemented in GRUB. There was a hack to do this a while back, but I never tried this because it was being described to me as a "dirty hack", and at the time I hesitated to use it. Following this, I wrote a script that would change the grub config file and reboot grub, so it would reboot in windows. However, it would then boot windows every time. That problem could be solved in a very roundabout way by installing the ext3-Extension in Windows and having the reverse perl script there, using the ActivePerl implementation. Or keep using lilo. Or stick around while the machine boots. The sky's wide open...

HTH,

Samsara

PS: I'll try and find that grub hack.

Samsara 12-06-2004 06:18 PM

http://www.linuxquestions.org/questi...04/02/2/145115

Or this:

Code:

#!/usr/bin/perl
#--------------------------------------------------------------------
# Copyright (C) 2000, 2001, 2002 by MandrakeSoft,
# Pixel <pixel@mandrakesoft.com>,
# Chmouel Boudjnah <chmouel@mandrakesoft.com>,
# Redistribution of this file is permitted under the terms of the GNU
# Public License (GPL)
#--------------------------------------------------------------------
# $Id: rebootin,v 1.11 2001/12/04 14:22:45 chmouel Exp $
#--------------------------------------------------------------------
## description:
#                Reboot once on a specified image for grub or lilo

use strict;

my $lilo_conf = "/etc/lilo.conf";

my $grub_menu = "/boot/grub/menu.lst";
my $grub_once = "/boot/grub/menu.once";
my @entries;
my $bootloader  = `/usr/sbin/detectloader -q` or die "Can't detect your bootloader\n";chomp $bootloader;
my ($fastboot, $noreboot);

while ( $ARGV[0] =~ /^-/ ) {
    $_ = shift;
    if (/^-f/) {
        $fastboot++;
    } elsif (/^-n/) {
        $noreboot++;
    } else {
        die "Unknow switch $_\n";
    }
}

if ($bootloader =~ /GRUB/) {
    grub_conf();
} elsif ( $bootloader =~ /LILO/) {
    lilo_conf();
} elsif ( $bootloader =~ /YABOOT/) {
    die "Sorry, can't do this with yaboot...\n";
} else {
    die "Can't detect your bootloader\n";
}

sub lilo_conf {
    open F, $lilo_conf or die "lilo is not installed ($lilo_conf is missing)\n";
    @entries = map { /=(\S.*)/ } grep { /\s*label=\S*/ } <F>;
    @entries > 0 or die "Bad lilo.conf (no entry found)\n";
    usage() unless $ARGV[0];
    grep /^$ARGV[0]$/, @entries or usage();
    write_fast_boot() if $fastboot;
    system("lilo -R @ARGV"); die "error while wanting to reboot on $ARGV[0]\n" if $?;
    exec "reboot" unless $noreboot;
}

sub grub_conf {
    open F, $grub_menu or die "grub is not installed ($grub_menu is missing)\n";
    @entries = map { /\s(\S.*)/ } grep { /^title\s/ } my @l = <F>;

    grep { m|^altconfigfile\s.*grub/menu\.once| } @l or die "rebootin is of no use without altconfigfile\n";
    @entries > 0 or die "bad menu.lst (no entry found)\n";
    @ARGV == 1 or usage();

    for (my $i = 0; $i < @entries; $i++) {
        $ARGV[0] eq $entries[$i] and set_grub($i);
    }

    print STDERR "$ARGV[0] not found\n";
    usage(); # not found
}

sub set_grub {
    open F, ">$grub_once" or die "can't write rebootin file ($grub_once), verify the rights\n";
    print F "default $_[0]\ntimeout 0\n";
    write_fast_boot() if $fastboot;
    exec "reboot" unless $noreboot;
}

sub usage {
    die "usage: rebootin <label>\n  where <label> is one of " . join(", ", @entries) . "\n";
}

sub write_fast_boot {
    local *F; open F, ">/fastboot"; close F;
}

from http://linux.tuwien.ac.at/fwiso/CD-I.../sbin/rebootin

Edit: All untested by me, so use at your own risk!

Samsara


All times are GMT -5. The time now is 04:48 PM.