The autorun feature is supported in SystemRescueCd-5.x and SystemRescueCd-6.0.1 and more recent.
The autorun feature allows you to run scripts automatically at startup of the system. Each autorun script can manage a task. For example, you can create a backup script that makes a backup of a database, another for cleaning a system, …
By default, the autorun script(s) may be copied in the root of the CDRom, outside of the compressed loop image file (sysrcd.dat), but other sources are available : floppy disk, disk partition, network share, an HTTP web server.
The script may be named
autorun if alone. If many scripts have to be
chained, you may name them
autorun1,… . In this case,
specific autorun scripts may be allowed with an
option given at boot time prompt. For example, you may add
autoruns=2,3,4 to the boot command line.
If you want to use floppy or network source for autorun files, you will
have to specify the source using the
ar_source boot option. More on
this in next section.
You can use autorun to perform completely automatic tasks using SystemRescueCd. There is a dedicated chapter that explains How to use autorun to manage server that are in a remote datacenter.
These options may be used at boot time, on the boot command line.
/dev/sda1), an nfs share (
nfs://192.168.1.1:/path/to/scripts), a samba share (
smb://192.168.1.1/path/to/scripts), or an http directory (
autoruns=0,2,7then the following autorun scripts will be executed:
autoruns=noto disable all the autorun scripts with a number.
autorunscript will not be executed
At startup, a list of locations is checked against the presence of autorun files. They are, successively:
/mnt/autorun, allowing writing data into them if the device is not write-protected.
ar_source=/dev/sda2(autorun scripts in 2nd partition of 1st IDE hard disk)
ar_source=//samba-server/share(recommended without user/password).
If autorun files are found in some location, they are run and the process ends. Last two locations require rebuilding of SystemRescueCd and are to be used for advanced or test purposes.
In each source location, there are two possible modes of operation :
autorunis found, it is run
autorun#scripts are found (# is a digit from 0 to 9) and either
autoruns=boot parameter was NOT specified, or
autoruns=boot parameter value contains #
autoruns=0,1,4 In this example, only
autorun0, autorun1 or autorun4 scripts may be run if present. Other
scripts, such as autorun2, autorun3 and autorun5, will be ignored, then
authorized scripts are run in alphanumeric order. Whenever a script
returns a non-zero code, the processing stops and next scripts are not
run. You can prevent any
autorun\# execution with an autorun= boot
parameter without any digit, ex:
autoruns=no. This has no effect on
Although it is possible to put both
this should probably be avoided.
The script has to be any valid shell script. Perl, python, … etc. scripts are not supported at this time. Windows end-of-line terminators are translated to allow running shell scripts written with a MS editor.
#!/bin/bash ( ifconfig eth0 | head -n 3 fdisk -l /dev/sda ) | tee -a /mnt/autorun/report sync exit 0
In this script we assume that we have passed the floppy-disk as the
source of autorun with
ar_source=fd0 boot-parameter. It will
accumulate infos about eth0 network interface and disk partitions into a
report on the first floppy drive. The BIOS boot sequence
must specify the CD first, the diskette must be write-enabled, the CD
and diskette must be inserted at startup time. Hint: The parameter
after the command
tee has the following effect: the file is not
overwritten but the output is appended.
If network is automatically configured at boot (DHCP), you may send infos through an NFS or a samba share for example.
Do not forget to give the autorun location at startup. Say that you share
through NFS a writeable directory named
/nfs/backup on host myserver,
you have to specify:
at SystemRescueCd boot prompt and to put in the shared directory an
autorun script such as this one :
#!/bin/bash date=$(date +%Y%m%d) cat /dev/sda | gzip > /mnt/autorun/$date.sda.gz && exit 0 echo $date sda backup error exit 1
If sufficient space is provided in the NFS share, a compressed image of your first IDE disk will be copied there. Be aware that there may be a 2GB maximum file size when copying across the network or to a FAT filesystem.
You must ensure that name resolution works if you intend to access the NFS server by its name instead of its IP address.