F.4 Modifying ZENworks Imaging Resource Files

From time to time you might want to modify an imaging distribution by adding your own files. These can be additional programs, scripts, data files, or updated Linux drivers.

You can use the following methods to update imaging resource files:

F.4.1 Adding Files to an Imaging Boot CD

If you have files to add to an imaging boot CD so they can be available for use when you get to the actual imaging process (such as scripts, but normally not driver modules), you can copy the files to the /addfiles directory on the imaging CD. This is an easy way to insert your script or other files into the distribution without modifying the initrd or root file systems. However, these files are not available during the boot and module loading phases.

The imaging boot CD has a directory named /addfiles where you can add files. They should be placed below this directory in their proper directory names. They are then available in this directory structure during the imaging process.

An example of how you can add files:

  1. If you want to execute your own script instead of the normal imaging process, create a script file named myscript.s and place it on the boot CD. For example, /addfiles/bin/myscript.s.

    IMPORTANT:The script file must have proper LF line terminators that Linux requires, not the DOS CR and LF end-of-line characters. In other words, you cannot use Notepad.exe to create the script; you must use a text editor compatible with Linux, such as TextPad.

  2. To place the following line in the settings.txt file, enter:

    export IMGCMD="/bin/myscript.s"
    

    When imaging is run, it runs /bin/myscript.s instead of using the normal img ‑auto command.

F.4.2 Adding Files to the Initrd or Root File Systems

This is the preferred method for updating imaging resource files, and must be performed in a Linux environment.

Before performing the procedures given below, make sure you have created backup copies of any files you plan to change, specifically the /srv/tftp/boot/initrd file. If you want to change the files on an imaging CD, you need an ISO editor or some other process for extracting and replacing the file in the bootcd.iso image file.

IMPORTANT:When updating or adding files and Linux drivers in the initrd or root file systems, document the changes you make. When you receive updated resource files from Novell, they do not contain your customized changes. If the kernel version has changed with the newer resource files from Novell, previously added drivers must be updated either by obtaining a new version from the manufacturer or recompiling the driver using the correct Linux kernel version source.

To add files to the root file system, you can also use the driverupdate file method described in Section F.4.3, Using the Driverupdate File Method.

Adding to Initrd

To modify the initrd file system:

  1. Using a Linux device, create a working directory and change to that directory.

  2. To copy initrd from the PXE server or the boot CD to the new working directory:

    • For PXE, copy /tftp/boot/initrd to the Linux workstation’s working directory.

    • For the CD, extract initrd from the /boot/i386/loader directory on the boot CD, then copy the extracted initrd to the Linux workstation’s working directory.

  3. To rename initrd to initrd.gz, enter:

    mv initrd initrd.gz
    
  4. To unzip the initrd.gz file, enter:

    gunzip initrd.gz
    
  5. To create another working directory for use as a mount point in the subsequent steps, enter:

    mkdir work
    
    cd work
    
  6. To extract initrd into the /work directory, enter:

    cpio -idmuv ../initrd >/dev/null 2>&1
    
  7. To copy your files or updated driver to the extracted initrd file system, enter:

    cp /your_path/module.ko work/lib/modules/2.6.5-override-default/initrd
    

    where your_path is the path to the module.ko file and module is the name of the module.

    Other files to be included in the initrd file system should be copied to the appropriate directory.

  8. To re-package the initrd file system, enter:

    cd work
    
    find . | cpio -quiet -o -H newc > ../initrd
    
    cd ..
    
  9. To zip the new initrd file, enter:

    gzip -v9c initrd > initrd.gz
    
  10. To rename initrd.gz back to initrd, enter:

    mv initrd.gz initrd
    
  11. To copy the file back:

    • For PXE, copy the updated initrd file to the /tftp/boot directory on the PXE server.

    • For the CD, copy the updated initrd file to the /boot/i386/loader directory on the boot CD.

Adding to Root

To modify the root file system:

  1. Using a Linux device, create a working directory and change to that directory.

  2. To copy initrd from the PXE server or the boot CD to the new working directory:

    • For PXE, copy /tftp/boot/initrd to the Linux workstation’s working directory.

    • For the CD, extract root from the /boot/i386/ directory on the boot CD, then copy the extracted root to the Linux workstation’s working directory.

  3. To rename root to root.gz, enter:

    mv root root.gz
    
  4. To unzip the root.gz file, enter:

    gunzip root.gz
    
  5. To create another working directory for use as a mount point in the subsequent steps, enter:

    mkdir work
    
  6. To mount the initrd file system to the /work directory, enter:

    mount -o loop root work
    
  7. To copy your files or updated driver to the mounted root file system, enter:

    cp /your_path/module.ko work/lib/modules/2.6.5-override-default/initrd
    

    where your_path is the path to the module.ko file and module is the name of the module.

    Other files to be included in the initrd file system should be copied to the appropriate directory.

  8. To unmount the root file system, enter:

    umount work
    
  9. To zip the new rrot file, enter:

    gzip -v9c root > root.gz
    
  10. To rename root.gz back to root, enter:

    mv root.gz root
    
  11. To copy the file back:

    • For PXE, copy the updated root file to the /tftp/boot directory on the PXE server.

    • For the CD, copy the updated root file to the /boot/i386/ directory on the boot CD.

F.4.3 Using the Driverupdate File Method

Another way to customize the Novell imaging distribution is to utilize the driver update mechanism that is built into all SUSE distributions. This entails modifying a file named driverupdate that is located in the /srv/tftp/boot directory on your Imaging Server or on the root (/) of an imaging boot CD.

This method is a little less intrusive than modifying the initrd or root file systems. You simply create an additional file that is incorporated into the imaging operating system during boot time.

There are three types of driver update operations that can be performed:

  • Install the kernel modules or hardware drivers

  • Install files and execute a script

  • Simply place files into the operating system

This section describes how to install files and execute a script. For information on the other two methods, see “Tech Talk #3 - Spittin’ Image” in the Novell Connection Magazine. Specifically, see the “SUSE Linux Driver Updates” and “Adding files to the distro "root" file” sections in the article.

The example in this section takes the program “tree” that is not currently available in the imaging distribution and installs it at boot time.

The driver update mechanism seeks the driverupdate file, which contains a directory structure that mimics the directory structure in the operating system after a device has booted with the ZENworks distribution. If it is present, linuxrc downloads it during booting and incorporates it into the operating system dynamically.

The driverupdate file is a file system file that can be of any file system type, such as EXT3 or REISER. For simplicity, we’ll use the CRAMFS file system in our example.

To place the tree program into the driverupdate file:

  1. Create a working directory on your Imaging Server, such as /work.

  2. If you are using the driverupdate file, download the driverupdate.tgz file into the /work directory, then untar it by entering:

    mkdir work
    cd work
    wget http://www.novell.com/connectionmagazine/2005/11/download/driverupdate.tgz
    tar -xzvf driverupdate.tgz
    

    The driverupdate.tgz file contains the same directory structure as is created in Step 3.

  3. If you are manually creating the directories, create the following structure under the /work directory:

    `-- linux
        `-- suse
            |-- i386-sles10
                |-- dud.config
                |-- inst-sys
                    `-- lib
                    `-- bin
                |-- adddir.s
    

    The contents of the dud.config file should contain lines similar to those listed below. You should maintain the keywords by supplying your own data. However, you can use the listed values:

    UpdateName:     ZENworks 10 Patch 1
    UpdateID:       a37f92556e4dd99e
    UpdatePriority: 100
    

    The adddir.s file should be an executable script that contains the following lines:

    echo "Processing: adddir.s" > /dev/tty3 2>&1
    # driver update: add files to inst-sys
    for i in /update/[0-9]*/inst-sys ; do
         [ -d "$i" ] && adddir "$i" /
    done
    
    # driver update: run update.pre scripts
    for i in /update/[0?9]*/install/update.pre ; do
         echo "Processing: $i" > /dev/tty3 2>&1
         [ -x "$i" ] && "$i"
    done
    
  4. To copy the tree program into the /bin directory, enter:

    cp /usr/bin/tree dirstruct/linux/suse/i386-9.2/inst-sys/bin/
    
  5. To create the CRAMFS file, enter:

    mkfs.cramfs work/ driverupdate
    

    The CRAMFS file is required by the SUSE distribution.

  6. To copy the driverupdate file into /srv/tftp/boot, enter:

    cp driverupdate /srv/tftp/boot
    
  7. Add the following lines to the end of the /srv/tftp/boot/settings.txt file:

    # SUSE driver update
    for i in /update/[0?9]*/install/adddir.s ; do
         [ -x "$i" ] && "$i"
         rm $i
    done
    

    This causes the adddir.s script to run, which creates soft links to all of the new files being copied.

    These lines might already be present in the settings.txt file.

  8. Reboot the PXE-enabled device.

    You should see the text “ZENworks 10 Patch 1” at the imaging maintenance mode prompt after the operating system has booted.

  9. Execute the tree program.

All of the files you put into the driverupdate file are now located under the /update directory in the operating system after booting. Then, the adddir.s script (or the code that you added to the settings.txt file in Step 7) creates soft links under the root file system that point to the corresponding files under the /update directory structure. You can verify this by running:

/# which tree
/bin/tree
/# ll /bin/tree
lrwxrwxrwx  1 root root 29 Aug 31 21:45 /bin/tree -> /update/000/inst-sys/bin/tree

If you want to simply include a new hardware driver or kernel module in the imaging operating system, an easier process might be to copy the .ko file into the /dirstruct/linux/suse/i386-9.2/modules/ directory. Then, the imaging operating system automatically loads any .ko files that are in this directory.