Unpacking Oracle Patch and Install Media with cpio

Unpacking Oracle Patch and Install Media with cpio

Purpose

Before Oracle began shipping all patches as .zip files, the standard delivery format for Oracle install media and large patch bundles was cpio — a tape archive format that predates tar and is still the underlying format used inside every RPM package. DBAs working with Oracle 8i, 9i, and early 10g installations, or with older patch archives from Oracle MetaLink, received media on tape or in .cpio files and used cpio -idmv to stage it for installation.

This command, preserved in the shutdownabort.com DBA Quick Guides (Andrew Barry, 2007–2013, recovered via the Wayback Machine), remains relevant for DBAs who maintain legacy Oracle environments, need to extract individual files from Oracle Linux RPM packages without running the package manager, or encounter cpio-format archives in other Oracle tooling contexts. The rpm2cpio pattern — extracting a single file from an Oracle RPM — is a particularly useful technique that persists well beyond the era of tape-delivered install media.

Code

 1# Extract a cpio archive (preserving directory structure and timestamps)
 2cpio -idmv < oracle_media.cpio
 3
 4# From a tape device
 5cpio -idmv < /dev/tape
 6
 7# List the contents of a cpio archive without extracting
 8cpio -itv < oracle_media.cpio
 9
10# Create a cpio archive (inverse operation — useful for staging)
11find . -print | cpio -ovB > /backup/oracle_files.cpio
12
13# Extract a single file from an Oracle RPM without installing it
14rpm2cpio oracle-database-ee-19c-1.0-1.x86_64.rpm | cpio -idv --no-absolute-filenames \
15  ./usr/lib/oracle/19c/client64/lib/libclntsh.so.19.1

Code Breakdown

cpio -idmv < oracle_media.cpio

The four flags that Andrew Barry's guide used for Oracle media extraction:

-i — Extract mode (input). Reads the archive from stdin and extracts files to the current directory. cpio reads stdin by default; the < oracle_media.cpio redirect pipes the archive file into cpio's stdin.

-d — Create directories as needed. Without -d, cpio fails if a target path's parent directory does not already exist. Oracle archives have deeply nested directory trees (e.g., Disk1/stage/Components/oracle.rdbms/10.2.0.1.0/1/DataFiles/). -d creates all of them automatically. This flag is almost always required for Oracle archives.

-m — Preserve modification times. Extracted files retain their original timestamps from the archive rather than the current time. Oracle Universal Installer checks file modification times during installation validation — preserving them avoids spurious installer warnings.

-v — Verbose: print each filename as it is extracted. Remove for quiet extraction; keep it to monitor progress on large archives (a full Oracle Database install media is tens of thousands of files).

cpio -itv < oracle_media.cpio

List mode without extraction:

  • -i — Input/extract mode
  • -t — Table of contents: list only, do not extract
  • -v — Verbose: show size, date, and permissions alongside the filename

Use this to inspect an archive before committing to a full extraction, especially when the archive is hundreds of megabytes and the target filesystem is almost full.

find . -print | cpio -ovB > /backup/oracle_files.cpio

Creates a cpio archive. find . -print generates a newline-separated list of all files from the current directory; cpio -o reads that list from stdin and writes the archive to stdout; -v prints each filename; -B uses 5120-byte blocks for better streaming performance on tape or pipe output.

rpm2cpio ... | cpio -idv --no-absolute-filenames

Extracts a specific file from an Oracle RPM without installing the package.

rpm2cpio — Converts an RPM file to a cpio stream on stdout. Every RPM is a cpio archive with an RPM header prepended; rpm2cpio strips the header and hands the raw cpio stream to the next command.

--no-absolute-filenames — Prevents cpio from interpreting archive paths beginning with / as absolute paths on the current system. RPM archives use absolute paths (e.g., /usr/lib/oracle/...); without this flag, cpio would attempt to write to /usr/lib/oracle/ on the current system rather than ./usr/lib/oracle/ relative to the current directory.

Key Points

  • cpio is still inside every RPM on Oracle Linux. The rpm2cpio pattern works for any RPM, including Oracle Database, GI, and client RPMs. Use it to retrieve a single library or binary from a patch RPM without running the full package manager — invaluable for recovering from a failed partial patch that corrupted one file.
  • -d is almost always required for Oracle archives. Oracle installs have deeply nested directory structures. Omitting -d causes cpio to fail on the first path with a missing parent directory. Always include it.
  • Verify before extracting. cpio -itv < archive.cpio 2>&1 | wc -l counts the files. A 100,000-file archive takes roughly two minutes to extract on a fast server; knowing the count sets expectations for the staging wait.
  • Check disk space before extraction. cpio -itv < archive.cpio | awk '{sum+=$3} END {print sum/1024/1024, "MB uncompressed"}' estimates the uncompressed extraction size. Confirm the target filesystem has that plus 20% headroom before starting.
  • Run as the oracle user. Permissions on the extracted files will be owned by the running user. Running as root and changing ownership afterward works but is slower for large archives. Run as oracle from the start.

Insights and Best Practices

Modern Oracle patches ship as zip files — use unzip, not cpio

Oracle patches from Oracle Support (MOS) ship as .zip files since Oracle 10g patches and universally from Oracle 11g onwards. Extract these with unzip:

1cd /oracle/stage
2unzip p35742696_190000_Linux-x86-64.zip
3cd 35742696
4opatch apply

Reserve cpio for situations where you actually encounter a .cpio archive: legacy media from before 2005, RPM extraction via rpm2cpio, or archives created by Oracle tooling that still uses cpio format internally.

Extracting from a compressed cpio archive

Older Oracle media shipped as .cpio.gz (gzip-compressed cpio). Decompress and extract in one pipeline without creating a temporary uncompressed file:

1gunzip < oracle_media.cpio.gz | cpio -idmv
2# or equivalently:
3zcat oracle_media.cpio.gz | cpio -idmv

This is the same named-pipe principle as Oracle Export through gzip — stream the bytes, avoid staging the uncompressed intermediate.

Recovering a single file from a broken Oracle home

When a failed patch leaves one shared library corrupted:

 1# Find the RPM that owns the file
 2rpm -qf /u01/app/oracle/product/19c/db_1/lib/libclntsh.so.19.1
 3
 4# Extract only that file from the RPM
 5rpm2cpio oracle-database-ee-19c-1.0-1.x86_64.rpm \
 6  | cpio -idv --no-absolute-filenames \
 7    ./u01/app/oracle/product/19c/db_1/lib/libclntsh.so.19.1
 8
 9# Copy it back
10cp ./u01/app/oracle/product/19c/db_1/lib/libclntsh.so.19.1 \
11   /u01/app/oracle/product/19c/db_1/lib/

This recovers the exact original binary from the RPM without rolling back the entire package.

When to Run This

  • Staging Oracle 8i, 9i, or early 10g installation media delivered on tape or CD-ROM images
  • Extracting individual files from Oracle Linux RPM packages without running the package manager
  • Working with legacy .cpio format patch archives from Oracle MetaLink
  • Recovering a single corrupted file from an Oracle installation RPM after a failed patch
  • Transporting an Oracle home to an air-gapped server by creating a cpio archive of the directory tree

Troubleshooting Common Issues

If cpio aborts with Cannot make directory: File exists despite using -d, a regular file already exists where cpio wants to create a directory. Use cpio -itv < archive.cpio | head -50 to inspect the first 50 paths in the archive and identify the conflict with the existing filesystem layout.

If extraction appears to complete but some files are missing, check whether the archive requires elevated privileges for certain paths. Run cpio -idmv < archive.cpio 2>&1 | grep "Permission denied" to identify which paths the current user cannot write. Switch to the oracle OS user or use sudo.

If rpm2cpio is not installed, install it with yum install rpm on Oracle Linux/RHEL (it is part of the core rpm package, not a separate install). On minimal container images it may be absent.

References

Posts in this series