Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Script to automatically reboot to newly compiled kernel with fallback Post 302382982 by tridus_08 on Sunday 27th of December 2009 09:16:45 PM
Old 12-27-2009
Script to automatically reboot to newly compiled kernel with fallback

Hi,
I'm new here. Just started playing around with kernel compilation.
I need a little bit of advice.
I'm trying to do a bash script to automatically compile a kernel package and reboot to that new kernel by default, with fallback to the old kernel.
So far, I'm getting stuck at the part where I need to reboot and load the new kernel as default.
I'm intending for this script to be used on systems using grub (legacy).

If I'm not wrong, I would need to change the menu.lst file to something like this:
Code:
default saved
fallback 1
timeout 5

title New, kernel 2.x.xa
root (hd0,0)
kernel /new root=/dev/sda1
initrd /boot/initrd.img-2.x.xa
savedefault 1

title Orig, kernel 2.x.xb
root (hd0,0)
kernel /old root=/dev/sda1
initrd /boot/initrd.img-2.x.xb

title Other, kernel 2.x.xc
root (hd0,0)
kernel /old root=/dev/sda1
initrd /boot/initrd.img-2.x.xc

If so, how should I go about to manipulate the menu.lst file?
I'm guessing that I might need to use awk to parse through the file, count the entries to get the entry number of the new kernel and the original kernel.
If that is the case, how can I do that with awk? (Not too good with awk, I usually use sed. )
Or are there better alternatives to this?
Thanks in advance.

Last edited by pludi; 12-28-2009 at 02:42 AM.. Reason: code tags, please...
 

10 More Discussions You Might Find Interesting

1. AIX

Automatically mounting a filesystem after a reboot

Hi All, I am new to AIX. I am having problems mounting a filesystem after a system reboot. Steps: 1. Create and Map LUN to host 2. On the host, to detect/configure the LUN: /usr/sbin/cfgmgr 3. Create a filesystem: mkfs -V vxfs /dev/hdisk757 4. Create a mountpoint: mkdir -p... (3 Replies)
Discussion started by: austin4397
3 Replies

2. Red Hat

Kernel panic after hard reboot and fsck

Could you please help with problem with megaraid controller and Dell PowerEdge 2850, all that I can see on thi screenshot: All drives successfuly passed verifing from LSI controllers (Ctrl+A at startup), also I tried to boot from rescue llive cd and mount all the morrored drives and check... (22 Replies)
Discussion started by: nikkadim
22 Replies

3. UNIX for Dummies Questions & Answers

Make sure kernel was compiled with NFS server support

Hi there, I have a Debian Squeeze server. How can I check if my kernel was compiled with NFS server support? Extra question: if it is not, how do I enable NFS support in my kernel? Thanks for your help. Santiago (3 Replies)
Discussion started by: chebarbudo
3 Replies

4. Solaris

Newly Compiled GCC 4.4.4 on Solaris sparc gives problem with -m32/-m64 flags

Hello experts, This issue has kept me busy all day long. It started off with openssl compilation which was giving linking error with following message: /usr/local/bin/ld: target elf32-sparc not found collect2: ld returned 1 exit status I tried every step possible thing that I could think... (2 Replies)
Discussion started by: d_shanke
2 Replies

5. Shell Programming and Scripting

How to run script automatically on reboot as root user?

Hi friends,,, I am running one server on Ubuntu 12.04 LTS 32-bit, some times my pc restarts automatically, with no reason, I have a script to start server which requires root password. in this directory /myserver/start_server.sh How can I do this ? and some scripts I am having that I... (1 Reply)
Discussion started by: Akshay Hegde
1 Replies

6. AIX

Loading AIX kernel extensions on reboot

Greetings, Does anyone know how to load AIX kernel extensions on reboot? I know that Oracle loads it's postwait kernel extension via a executable in /etc/inittab. I'm assuming this executable calls the "sysconfig" system call and loads it. What if I wrote my own? What is the proper way in AIX to... (3 Replies)
Discussion started by: jbleistein
3 Replies

7. AIX

How can we re-mount the RAM disk automatically after the reboot on AIX?

Hi All, I was trying to know more about RAM disk concept in AIX. I found something on IBM site. I was able to create and use/delete RAM disk as per IBM instructions. But as you guys know, this RAM disk is a temporary storage. (*when ever we reboot the AIX LPAR, content/RAM disk will be... (4 Replies)
Discussion started by: System Admin 77
4 Replies

8. IP Networking

[ipv6_test] Kernel is not compiled with IPv6 support

Hello, i tried to enable IPv6 networking and after service network restart i seen these messages: FATAL: Error inserting ipv6 (/lib/modules/2.6.18-348.16.1.el5.028stab108.1/kernel/net/ipv6/ipv6.ko): Device or resource busy CRITICAL : Kernel is not compiled with IPv6 support Bringing up... (6 Replies)
Discussion started by: postcd
6 Replies

9. Red Hat

Update kernel Linux without reboot?!

Hi Is it a way ? When Linux kernel updated that don't want reboot it means without reboot the new kernel performances Thanks (7 Replies)
Discussion started by: mnnn
7 Replies

10. Shell Programming and Scripting

Run a script before and after reboot automatically and send output to two locations.

Hello Team . I am working a health check script ( bash) to run on linux server ( RedHat) and requirements are 1. The o/p of script need to be send to two diff files . I am testing with tee command . But I am not successful yet , any recommendations if that is the right approach ? 2. The same... (2 Replies)
Discussion started by: Varja
2 Replies
reboot(3C)																reboot(3C)

NAME
reboot - reboot system or halt processor SYNOPSIS
#include <sys/reboot.h> int reboot(int howto, char *bootargs); The reboot() function reboots the system. The howto argument specifies the behavior of the system while rebooting and is a mask con- structed by a bitwise-inclusive-OR of flags from the following list: RB_AUTOBOOT The machine is rebooted from the root filesystem on the default boot device. This is the default behavior. See boot(1M) and kernel(1M). RB_HALT The processor is simply halted; no reboot takes place. This option should be used with caution. RB_ASKNAME Interpreted by the bootstrap program and kernel, causing the user to be asked for pathnames during the bootstrap. RB_DUMP The system is forced to panic immediately without any further processing and a crash dump is written to the dump device (see dumpadm(1M)) before rebooting. Any other howto argument causes the kernel file to boot. The interpretation of the bootargs argument is platform-dependent. Upon successful completion, reboot() never returns. Otherwise, -1 is returned and errno is set to indicate the error. The reboot() function will fail if: EPERM The {PRIV_SYS_CONFIG} privilege is not asserted in the effective set of the calling process. intro(1M), boot(1M), dumpadm(1M), halt(1M), init(1M), kernel(1M), reboot(1M), uadmin(2) 22 Mar 2004 reboot(3C)
All times are GMT -4. The time now is 11:35 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy