跳过导览列.
首页
做最好的Linux技术文档网站

How do I manually update a Driver Update Disk?

To build a Driver Update Disk (DUD) for use when installing Red Hat Enterprise Linux 4 and newer (2.6 kernels), you should first try to use ddiskit from http://dup.et.redhat.com/ddiskit/.  If, however, you need to manually modify a DUD or create one from scratch, or if you're just curious, below is a description of the contents of a DUD.

 

A DUD contains the following files:

 

File Description
modinfo driver info (name, hardware class, text description)
modules.alias map of PCI IDs to driver names
modules.cgz a gzip'ed cpio archive of the drivers
modules.dep list of driver dependencies
modules.pcimap another map of PCI IDs to driver names
pcitable yet another map of PCI IDs to driver names
rhdd a text description of the driver disk

 

A DUD is usually distributed as an ext2 filesystem image.  Create an image and mount it with:

 

<!--[CodeBlockStart:f4b2bdb2-8016-45c0-9a24-15ecb2357ebe]-->
dd if=/dev/zero of=/tmp/dud.img bs=1k count=1440
mkfs -t ext2 /tmp/dud.img
mkdir /mnt/dud
mount -o loop /tmp/dud.img /mnt/dud

<!--[CodeBlockEnd:f4b2bdb2-8016-45c0-9a24-15ecb2357ebe]-->

 

To generate the above files for our DUD, let's assume we're working with the 2.6.18-128.el5 kernel on x86_64, and we have an updated cciss.ko driver for the HP Smart Array CCISS RAID controller that's already been compiled for this kernel.  Make the following directory structure and copy the updated driver into it.

 

<!--[CodeBlockStart:10d73abd-fc1e-48d2-8bba-a86bee13d06b]-->
mkdir -p /tmp/2.6.18-128.el5/x86_64
cp /path/to/updated/cciss.ko /tmp/2.6.18-128.el5/x86_64

<!--[CodeBlockEnd:10d73abd-fc1e-48d2-8bba-a86bee13d06b]-->

 

Now let's create the modinfo, modules.alias, and other files for the DUD.

 

modinfo

This file is generated manually.  The first line is almost always "Version 0".  The rest of the file is just a list of the drivers on the DUD followed by 2 tab-indented lines: the first is a driver class (usually scsi or eth), and the second is a short text description of the hardware.  For example:

 

<!--[CodeBlockStart:ce0a85bf-5b0a-4842-be1e-431bcad60c78]-->
Version 0
cciss
        scsi
        "Update HP CCISS driver"
tg3
        eth
        "Update Broadcom tg3 gigabit ethernet driver"

<!--[CodeBlockEnd:ce0a85bf-5b0a-4842-be1e-431bcad60c78]-->

 

modules.alias

This file maps, or aliases, a driver to the PCI device data.  It takes the format "alias pci-data driver", for example:

 

<!--[CodeBlockStart:88412ec6-7ed2-434b-9a3e-da1c9aa8442b]-->
alias pci:v00000E11d00000046sv00000E11sd00004091bc*sc*i* cciss
alias pci:v00000E11d00000046sv00000E11sd0000409Abc*sc*i* cciss
alias pci:v00000E11d00000046sv00000E11sd0000409Bbc*sc*i* cciss
...
alias pci:v0000103Cd0000323Asv0000103Csd0000324Abc*sc*i* cciss
alias pci:v0000103Cd0000323Asv0000103Csd0000324Bbc*sc*i* cciss
alias pci:v0000103Cd*sv*sd*bc01sc04i* cciss

<!--[CodeBlockEnd:88412ec6-7ed2-434b-9a3e-da1c9aa8442b]-->

 

This file is generated by the depmod tool along with modules.dep, modules.pcimap, modules.usbmap and a number of other files.  Unfortunately, depmod wants to write this file into /lib/modules/VERSION which requires root privileges  and there's no command line option to override this, and furthermore we don't want to modify this file on a running system.  As an  alternative, we can use the dry-run feature (the -n command line flag) which sends all output to stdout, but then we have to manually split this output into the various files.

 

<!--[CodeBlockStart:470d19d8-479f-4096-890c-100c3d7c22bd]-->
depmod -b /tmp -n /tmp/2.6.18-128.el5/x86_64/cciss.ko > /tmp/depmod.out
grep ^alias /tmp/depmod.out > /mnt/dud/modules.alias

<!--[CodeBlockEnd:470d19d8-479f-4096-890c-100c3d7c22bd]-->

 

An alternative method to generating the modules.alias file for driver.ko can be done with the modinfo tool.

 

<!--[CodeBlockStart:084a18cd-81a9-4031-909e-b9b67263743e]-->
modinfo -F alias driver.ko | sed -e 's/^/alias /' -e 's/$/ driver/' > /mnt/dud/modules.alias

<!--[CodeBlockEnd:084a18cd-81a9-4031-909e-b9b67263743e]-->

 

On a side-note, the long string of gibberish in the middle of the line is actually a number of fields delimited by lower case letters.  Using the first line from the example above for the cciss driver, we can see:

 

Delimiter Field Value
v Vendor ID 00000E11
d Device ID 00000046
sv Sub-Vendor ID 00000E11
sd Sub-Device ID 00004091
bc Device Base Class * (wildcard)
sc Device Sub-Class * (wildcard)
i Programming Interface * (wildcard)

 

Hardware vendors are assigned a 16-bit vendor ID by the PCI SIG.  In the above example, Hewlett-Packard (actually, Compaq) has 0x0E11.  You can look up vendor IDs in the file /usr/share/hwdata/pci.ids or at http://www.pcidatabase.com/  The device ID is assigned by the hardware vendor.  In the above example, 0x0046 is one of the device IDs for HP's Smart Array CCISS RAID controllers.

 

The sub-vendor ID and sub-device ID fields are used for more specific identification of a device.  These may be used to indicate a minor hardware revision, or if the device is an interface to other devices, they may indicate which sub-device you're talking to.

 

The base class is a generic class of devices, for example, storage or network.  The sub-class is more specific; for storage devices, it may be SCSI or IDE, or for network devices, it may be Ethernet or Token Ring.  A list of PCI classes is available at http://pciids.sourceforge.net/

 

Finally, the programming interface can be used for devices that have more than one way to talk to them, and the interface value tells you which method to use.

 

modules.cgz

This is simply a gzip'ed cpio archive — crc format — of the actual drivers (*.ko files).

 

<!--[CodeBlockStart:4b3d182f-d96d-4049-8d6b-37bf520fd53d]-->
cd /tmp
find 2.6.18-128.el5 | cpio -o -H crc | gzip -9 > /mnt/dud/modules.cgz

<!--[CodeBlockEnd:4b3d182f-d96d-4049-8d6b-37bf520fd53d]-->

 

The -9 flag for gzip tells it to compress as much as possible so we can squeeze everything onto a 1.44MB floppy.

 

modules.dep

This file lists dependencies that modules may have, for example, the cciss module requires the generic scsi_mod driver to be loaded first.  The format is simple: the driver name with a colon followed by a space delimited list of other drivers.

 

<!--[CodeBlockStart:0f75b07d-d127-4b6f-a0bd-55d97edbd69c]-->
cciss: scsi_mod
8139too: mii

<!--[CodeBlockEnd:0f75b07d-d127-4b6f-a0bd-55d97edbd69c]-->

 

This file is the first generated by the depmod tool, so it should be right at the top of the /tmp/depmod.out we generated earlier for modules.alias, however, it will contain the full path to the driver.  Strip the full path and leave just the driver name.

 

You can also manually build  a list of the dependencies using the modinfo tool:

 

<!--[CodeBlockStart:48b53c19-2e4d-453f-919a-c4cb760d0f5a]-->
modinfo -F depends driver.ko

<!--[CodeBlockEnd:48b53c19-2e4d-453f-919a-c4cb760d0f5a]-->

 

modules.pcimap

This file contains similar information to modules.alias but in a different format: the driver name followed by the 7 fields shown above in modules.alias.  The base-class and sub-class fields are combined into the single class field, and the class_mask indicates which bits are relevant.  The driver_data field is the programming interface.  Instead of a * for a wildcard, this file uses 0xffffffff.  For example:

 

<!--[CodeBlockStart:5bd9c993-f632-4389-aec9-7f74e56c92e8]-->
# pci module         vendor     device     subvendor  subdevice  class      class_mask driver_data
cciss                0x00000e11 0x0000b060 0x00000e11 0x00004070 0x00000000 0x00000000 0x0
cciss                0x00000e11 0x0000b178 0x00000e11 0x00004080 0x00000000 0x00000000 0x0
cciss                0x00000e11 0x0000b178 0x00000e11 0x00004082 0x00000000 0x00000000 0x0
...
cciss                0x0000103c 0x0000323a 0x0000103c 0x0000324a 0x00000000 0x00000000 0x0
cciss                0x0000103c 0x0000323a 0x0000103c 0x0000324b 0x00000000 0x00000000 0x0
cciss                0x0000103c 0xffffffff 0xffffffff 0xffffffff 0x00010400 0x00ffff00 0x0

<!--[CodeBlockEnd:5bd9c993-f632-4389-aec9-7f74e56c92e8]-->

 

Again, using the /tmp/depmod.out that we generated earlier for modules.alias, copy and paste the relevant lines into modules.pcimap.

pcitable

This file also contains similar information to modules.alias and modules.pcimap, but it is not used as much anymore since it's maintained by hand, whereas modules.alias and modules.pcimap can be generated automatically.  This file lists the vendor and device IDs, the driver name, and a text description.

<!--[CodeBlockStart:a4ed8c22-55e2-4c89-a139-0d4f638051ac]-->
0x0e11  0x4070  "cciss" "Compaq|Smart Array 5300 Controller"
0x0e11  0x4080  "cciss" "Compaq|Smart Array 5i Controller"
0x0e11  0x4082  "cciss" "Compaq|Smart Array 532 Controller"
...

<!--[CodeBlockEnd:a4ed8c22-55e2-4c89-a139-0d4f638051ac]-->

 

rhdd

A short description of the driver disk, for example:

<!--[CodeBlockStart:1d95fb2e-59c0-4f6e-8429-00fc18d63d5f]-->
HP cciss drivers update disk