LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 993|回复: 7

如何方便的重起机器到其他系统?

[复制链接]
发表于 2006-1-4 14:05:53 | 显示全部楼层 |阅读模式
我要用的服务器(测试服务器)上面装着4-5个系统,而且还没consle
我每次重起机器到别的系统就要跑过去,按键盘,选
有没有什么软件可以自动一点?:sleep
发表于 2006-1-4 21:38:27 | 显示全部楼层
Ha...Ha...I am doing the same things as you in the office.

I am not aware of any software in that sort.  Well, if you find one, please let me know.
回复 支持 反对

使用道具 举报

发表于 2006-1-5 00:10:23 | 显示全部楼层
重启之前修改/boot/grub/menu.lst……
或者省点事,写个脚本来修改menu.lst……
就是回到windows的话就没辙了……
回复 支持 反对

使用道具 举报

发表于 2006-1-5 10:09:27 | 显示全部楼层
用远程登录:
linux可以用ssh登录进去,然后重新启动,重新启动之前,你需要修改grub的配置文件(如果你安装的是grub启动器。)
windows可以安装终端服务。如果再安装一个可以修改linux分区中的文件的软件就可以修改下一次启动的系统了。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-1-5 10:21:49 | 显示全部楼层
我公司的一些机器可以用xyplex连上去,然后选择grub启动选相,但是我的测试机器没连着。。。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-1-10 09:24:57 | 显示全部楼层
Post by d00m3d
Ha...Ha...I am doing the same things as you in the office.

I am not aware of any software in that sort.  Well, if you find one, please let me know.

实在没找到什么好的软件来帮忙,自己写了一个
还是很麻烦,最好是要把所有的系统的boot/grub/menu.lst 都指向一个公共分区上的文件
而且系统负载很大的时候不要用,一旦menu.lst修改失败,就很麻烦了,其实最简单用shell写
几行就可以写完。

我还是继续走几步过去重起,不用这个脚本,怕menu.lst放在公共部分给别的人造成麻烦那:beat

[PHP]
#!/usr/bin/perl

# $id: auto rebooter 2006-01-09
#
# suport less then 10 boot opinion
# do not use this on important machines
# this may damage you box

#my $conf="/boot/grub/menu.lst";
my $conf="grub.conf";   ###修改这里
open (FD,"<$conf") || die "can not open grub config file!\n";

my @cont=<FD>;
close FD;

my $count=0;
my $posi =0;
my $i    =0;
my @list =();

if (!-f $conf.".baK"){
        print "backuping grub config file to $conf.baK....";
        open (FD2,"+>",$conf.".baK")||die "can not open $conf.baK!\n";
        print FD2 "@cont\n";
        close FD2;
        print "OK\n";
        }
my @cont2=@cont;
for $line (@cont){
        chomp $line;
        $i++;
        if ($line =~/^#/){
                next;
        }elsif ($line=~/default.*(\d)/){
                $def=$1;
                $posi=$i;
        }elsif($line=~s/.*title\s+//){
                push @list,$line;
                $count++;
        }
}

if ($count eq 0){
        print "no boot item found, please check your $conf\n";
        exit;
}
if (!(defined $def)){
        print "no default boot opinion found, please check your $conf\n";
        exit;
}

my $ret=0;
do{
        &printlist(\@list,$def);
}while(1);
sub cprint()
{
        my $head=shift;
        my $msg=shift;
        print "$head";
        printf "\x1b[7m%-54s\x1b[m|\n",$msg;
}

sub printlist()
{
        my($list,$def2)=@_;
        my $i=0;
        system("clear");
        print "\n\n\t+-------------------------------------------------------------+\n";


        for $os (@$list){
        chomp $os;
        if($i == $def2){
           &cprint("\t| $i\t",$os);
        }else{
           printf("\t| %d\t%-54s",$i,$os);
           print "|\n";
        }
           $i++;
        }
        print "\t+-------------------------------------------------------------+\n\n\n\n";

        print "[0-$#list] for OS, b to boot, q to cancel\n";
        #print "default boot is $def: @list[$def]\n";
        print "BOOT: $def>";
        &getcmd();
}

sub getcmd()
{
        my $c = getc(STDIN);
        if ($c =~ /q/i){
                exit;
        }elsif($c =~ /b/i){
                &boot();
        }else{
                my $t = ord $c;
                $t-=48;
                if ($t >=0 && $t <=$#list){
                        $def= $t;
                }
        }
}

sub boot()
{
        open (FD,">$conf")||die "can not open $conf!\n";
        @cont2[--$posi]="default $def\n";
        #print FD "@cont2\n";
        for (0..$#cont2){
                print FD "@cont2[$_]";
        }
        close FD;
        print "\nrebooting....\n";
        `shutdown -r -t0 now`;
        exit;
}


[/PHP]
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-1-10 09:36:36 | 显示全部楼层
屏 幕 的 截 图

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

发表于 2006-1-10 21:19:37 | 显示全部楼层
谢谢,有空试试:thank
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表