Make CD-ROM Recovery (mkCDrec)
Internals Explained
mkcdrec logo

Copyright (c) 2000-2001 - Gratien D'haese - IT3 Consultants
 

Index



Introduction

Make CD-ROM Recovery (mkCDrec) consists out of 2 big pieces, namely "making the bootable CD image(s)", and the "restore/rescue/clone part" in case one needs it.


In this article we will try to explain both parts in more detail.
The question why mkCDrec is the best suitable tool for your backups is not on its place as mkCDrec never claimed to be a backup tool anyway! One has to see it as a "disaster recovery" tool which is not yet standard available in any linux distribution. Until this situation is corrected mkCDrec can be of assistance ;-)
A word of caution: do not trust blindly that mkCDrec will do its job without errors, therefore, please test it on a test-and-burn system which is more or less equivalent to your production system.
In case you stumble over a bug, mail me a bug report!


Configuring mkCDrec

After downloading the latest release of the main website (http://mkcdrec.ota.be/download.html) and installing it in some directory one can start customizing the behavior of mkCDrec by editing the Config.sh file.
For more details on all changeable items go and read the config.html web-page.
A rule of dumb, do not change a line if you're not sure what it means, instead ask me so I can clarify the web pages (and documentation) if needed.

The make process

When you would like to make an ISO9660 image of your system you have to do it via a "make" command. A simple make command drives the whole process of gathering system information, making backups (if asked for), and creating ISO9660 images.
After typing make you will see the following menu:

Before we go in more detail in above menu lets discuss the makefile in more detail.

Design Goals

The reason why we choose to drive the complete process of making a bootable El Torito CD-ROM from a simple "make" command was for simplicity towards end-users.
In worst case the users have to edit the "Config.sh" file which contains directory paths where images will be stored and so on (see Config.sh page for more in-depth details).

The Makefile itself

The "Makefile" which is read by the make command can be found in the top directory of mkCDrec. The following table shows the Makefile of mkCDrec v0.4.7:

 
 
# Copyright (c) 2000-2001 Gratien D'haese 
# Please read LICENSE in the source directory 

VPATH=.:isofs:./bin 

DISKNAMES=rd-base 
SHFILES=$(addsuffix .sh,$(DISKNAMES)) 
BZ2FILES=$(addsuffix .img.bz2,$(DISKNAMES)) 

# local dirs 
MKCDREC_DIR := $(shell pwd) 
SCRIPTS=$(MKCDREC_DIR)/scripts 
BIN_DIR=$(MKCDREC_DIR)/bin 
UTILITIES=utilities 

# some packages used by mkCDrec (may be replaced by higher versions) 
SYSLINUX_DIR := $(shell ls -d syslinux*) 
BUSYBOX_DIR := $(shell ls -d busybox*) 
TINYLOGIN_DIR := $(shell ls -d tinylogin*) 
SFDISK_DIR := $(shell ls -d sfdisk*) 
CUTSTREAM_DIR := $(shell ls -d cutstream*) 
PASTESTREAM_DIR := $(shell ls -d pastestream*) 
CKSFV_DIR := $(shell ls -d cksfv*) 


SAFE_SYSLINUX=false 
DATE := $(shell date +%d.%m.%Y) 
ISOFS_DIR := $(shell grep ISOFS_DIR= Config.sh |grep -v ^\# | cut -d= -f 2) 
VERSION := $(shell cat VERSION) 
CDREC_ISO_DIR := $(shell grep CDREC_ISO_DIR= Config.sh |grep -v ^\#|cut -d= -f2) 

all: devs dirs mformat mkmakeISO9660 $(BZ2FILES) bootflop.img Backup_Finished 
    @echo Done. 

mkmakeISO9660: $(SCRIPTS)/makeISO9660.in 
    $(SCRIPTS)/mkmakeISO9660.sh 

CDrec.iso: $(BZ2FILES) bootflop.img Backup_Finished 
  mkisofs -J -r -P "$(VERSION)" -V "CDrec-$(DATE)" -o $(CDREC_ISO_DIR)/$@ -b bootflop.img isofs/ 

$(BZ2FILES): %.img.bz2: $(SCRIPTS)/%.sh 
      $< 

bootflop.img: $(SCRIPTS)/bootflop.sh initrd.img.gz syslinux 
 $(SCRIPTS)/bootflop.sh $(SAFE_SYSLINUX) 

initrd.img.gz: $(SCRIPTS)/initrd.sh linuxrc 
      $(SCRIPTS)/initrd.sh 

syslinux
      (cd $(SYSLINUX_DIR); make) 
      cp $(SYSLINUX_DIR)/syslinux ./bin/syslinux 

mformat
     ( objcopy -S /usr/local/bin/mformat $(BIN_DIR)/mformat 2> /dev/null || \ 
     objcopy -S /usr/bin/mformat $(BIN_DIR)/mformat 2> /dev/null || \ 
    @echo No mformat found on this system. Use ours instead. ) 

dirs
     mkdir -p $(ISOFS_DIR) stage tmp 

devs: /dev/initrd /dev/fd0u1722 
    @echo Device check OK 

/dev/initrd
     mknod /dev/initrd b 1 250 
     chmod 400 /dev/initrd 

/dev/fd0u1722
     mknod /dev/fd0u1722 b 2 60 
    chmod 666 /dev/fd0u1722 

Backup_Finished
     $(SCRIPTS)/tar-it.sh 

clean
    -umount stage 
    rm -f *.img 
    rm -f initrd.img.gz 
    rm -rf $(ISOFS_DIR) 
    rm -rf tmp 
    rm -f isofs 
    rm -rf bootflop 
    rm -f *.log 
    rm -f $(CDREC_ISO_DIR)/*.iso 

distclean: clean 
    (cd $(SYSLINUX_DIR); make clean) 
    (cd $(BUSYBOX_DIR); make clean) 
    (cd $(TINYLOGIN_DIR); make clean) 
    (cd $(SFDISK_DIR); make clean) 
    (cd $(CUTSTREAM_DIR); make clean) 
    (cd $(PASTESTREAM_DIR); make clean) 
    (cd $(CKSFV_DIR); make clean) 

dist: distclean 
    (cd ..; tar --file mk$(VERSION).tar.gz --create --gzip --verbose --exclude CDrec* --exclude stage --exclude tmp --exclude isofs --exclude OLD --exclude utilities mkcdrec ) 

utils
    (tar --create --gzip --verbose --file ../mk$(VERSION)_utils.tar.gz $(UTILITIES) ) 

test: $(SCRIPTS)/test.sh 
     $(SCRIPTS)/test.sh


All the bold items in the Makefile are headers which can be invoked separately. The most common make commands an user can use are:

Running the make command

The make command on itself will use the "all" header to do its thing:
 
all: devs dirs mformat mkmakeISO9660 $(BZ2FILES) bootflop.img Backup_Finished

The "all" will execute in order the above items. The "devs" will check if the device /dev/initrd exists, and if not, it will make it automatically. Thereafter, "dirs" will create the necessary temporary directories, such as ISOFS_DIR, stage and tmp. With a "make clean" those directories are removed again (be careful with images residing in ISOFS_DIR!). Mformat checks id the executable mformat in installed on your system, if not, then mkCDrec will use its mformat utility (in bin/ directory).
The "mkmakeISO9660" will create a shell script in scripts/ directory called "makeISO9660.sh" from the input file "makeISO9660.in" file and merging some variables from "Config.sh" file needed later on to create an ISO9660 images called by the cutstream program of tar-it.sh script depending on being a multi-volume CD-ROM backup or not.
The BZ2FILES does only contain one file, namely rd-base! Therefore, this line will execute the rd-base.sh script (all scripts are located in the scripts/ directory). rd-base-sh script is responsible for making the root ram disk which will be loaded after the inital bootloader.
The "bootflop.img" is responsible for making the initial ram disk (initrd.sh), the syslinux boot loader, and finally the El-Torito bootfloppy (which contains the linux kernel, syslinux boot loader and the compressed initrd images).
Finally, Backup_Finished will execute the tar-it.sh script to make (or skip) the tar backups of your file systems. Tar-it.sh script will always call the makeISO9660.sh script to produce the ISO9660 image on hard disk (file called CDrec.iso) or burn it directory on a CD-R when chosen for it in the Config.sh file).
We will try to explain all the steps in more detail following the flowchart design:

mkmakeISO9660.sh

The sole purpose of this small script is to merge some variable settings from Config.sh into makeISO9660.sh. Therefore, it will merge the file makeISO9660.in and the correct variable settings of Config.sh. Correct settings have to be edited manually into Config.sh (sorry, no GUI yet) - see also config.html file in doc/ directory.
The reason we have to do this is that in some circumstances the makeISO9660.sh script will be called in an isolated enviroment where mkCDrec settings are unset, therefore, we have to hardcode some variables into this script - that's all.
 

rd-base.sh

The rd-base.sh script is responsible for building the main root file system that will be active during the restore or cloning process.

Restore your system

 

 
 
 
 
 
 


Last changed on 12 March 2001 by Gratien D'haese