Can't I run myScript by appending a line to the entry of Linux in /boot/grub/menu.lst as:
title Ubuntu 9.04, kernel 2.6.28-11-generic
uuid b开发者_JAVA百科20f1720-b3f5-4162-bc92-ab2deb8d5d04
#kernel /boot/vmlinuz-2.6.28-11-generic root=UUID=b20f1720-b3f5-4162-kernel/boot/vmlinuz-2.6.28-11-generic root=UUID=b20f1720-b3f5-4162-bc92-ab2deb8d5d04 ro
initrd /boot/initrd.img-2.6.28-11-generic
/home/baltoros/Desktop/myScript
Is it even possible to run myScript at this point of time?
In the odd cases where you need the kernel to load something other than 'init' (which in turn, invokes the rc scripts), you can append an init=/path/to/program
on the kernel
line in grub, which tells the kernel the first program to run.
For instance:
kernel /boot/vmlinuz-2.6.xx root=/dev/sda3 ro init=/bin/bash
... would run bash instead of init, meaning no rc scripts would be run. Bash would have PID 1, just like init
normally does.
This is useful for kiosks, mobile devices and other things that manage their services independently (or, none at all).
Otherwise, as others have said, just write an init script and name it to coincide with what point in the boot process you wish it to run.
If you want to run a script as part of the boot process, you want to do that with init.
In the appropriate runlevel (most likely 5 if you are run a GUI, but 3 if you are only booting to the command line) directory, you will want to add an S## script.
On my main system, that would be:
/etc/rc.d/rc5.d/S00whatever
and add your script commands there. Because I used a number of 00, your script will be run very early in the boot process. Because of this, very few services will have started (for example, the network will not have been initialized). If you just want to run the script as part of booting and don't really need it early in the boot process, you'd want to use a higher number:
/etc/rc.d/rc5.d/S98whatever
精彩评论