Convert CPIO to CPIO.GZ Online (Adding Gzip's RFC 1952 Compression)
What actually happens when an uncompressed cpio container gets wrapped in gzip's formally specified compression layer for the first time.
- Add a file Choose or drop it here
- Pick the format Change it whenever needed
- Download the result After conversion completes
CPIO-TO-TAR.GZ — Adding Gzip's RFC 1952 Wrapper to an Uncompressed CPIO
A plain .cpio file bundles files using 512-byte header blocks, a structure standardized as USCPIO in POSIX.1-1988, but has no compression built into it at all — a folder of files wrapped in a .cpio comes out close to the same total size as the originals, plus a small amount of header overhead. Converting that CPIO into a CPIO.GZ means wrapping the entire cpio stream in gzip, whose container structure is precisely defined in RFC 1952, a separate specification from DEFLATE, the actual compression algorithm gzip uses underneath, which has its own specification in RFC 1951.
RFC 1952's header begins with two fixed identification bytes (0x1F and 0x8B), followed by a compression-method byte and a flags byte controlling which optional fields appear, such as the original filename or a comment. None of that outer gzip structure touches or reinterprets anything inside the cpio stream it wraps — the 512-byte cpio headers underneath remain exactly as they were, just compressed rather than stored directly.
That separation between the two layers is precisely why the conversion never has to inspect what's inside the cpio archive at all. Gzip doesn't know or care whether the stream it's compressing contains one file or thousands, what their permissions are, or how deeply nested their paths are — it simply reads bytes in, applies DEFLATE, and writes compressed bytes out, leaving every detail of cpio's own internal structure to be reconstructed later, once the gzip layer comes back off during extraction.
CPIO-TO-TAR.GZ — Why Gzip Compresses an Existing CPIO Stream Differently Than Bzip2 Would
DEFLATE, the algorithm inside gzip, uses a 32 KB sliding window and looks for repeated byte sequences within that limited span, combined with Huffman coding on the result. Applied to a cpio stream specifically, this means DEFLATE can only find and exploit repetition between bytes that are close together in the stream — a repeated filename or permission pattern in a header, for instance, compresses well only if it recurs within roughly 32 KB of its previous occurrence, a real, concrete limitation compared to the much wider spans other compressors can reference.
What DEFLATE trades away in reach, it gains back in speed: its simpler pattern-matching approach runs considerably faster in both directions than the Burrows-Wheeler transform bzip2 would apply to the same cpio stream, which is the core, well-documented reason gzip remains the default choice in many pipelines even where it doesn't produce the smallest possible result. At the very end of the gzip stream, an ISIZE field records the original uncompressed size — but that field is only 32 bits wide, storing the size modulo 2^32 per RFC 1952, meaning any cpio stream 4 GB or larger produces a wrapped-around, inaccurate reported size in that trailer even though the cpio data itself extracts perfectly correctly.
CPIO-TO-TAR.GZ — What Compressing a CPIO Into CPIO.GZ Gains and Costs
- Gain — real size reduction with fast turnaround: text-based content shrinks meaningfully, and DEFLATE's speed means the compression step itself adds relatively little time compared to heavier algorithms.
- Gain — a formally specified container: RFC 1952 defines gzip's header and trailer precisely, so any RFC-compliant gzip reader can decompress the result predictably.
- Gain — parallel compression through pigz: a multithreaded gzip reimplementation can spread the work of compressing a large cpio stream across multiple CPU cores, producing standard gzip output any ordinary tool reads normally.
- Lose — accurate size reporting past 4 GB: the ISIZE trailer's 32-bit width cannot represent the true uncompressed size of a very large cpio stream without wraparound.
- Lose — some compression ratio versus wider-window alternatives: bzip2's larger blocks and xz's much bigger dictionary both commonly out-compress gzip's fixed 32 KB window on repetitive, text-heavy cpio contents.
- Lose — near-zero shrinkage on already-compressed content: if the original CPIO mostly held JPEG, MP4, or MP3 files, DEFLATE finds little repetition left to exploit, the same limitation shared by essentially every general-purpose compressor.
CPIO-TO-TAR.GZ — Software That Turns a Plain CPIO Into Gzip-Compressed Output
GNU cpio performs this exact conversion directly with its -z flag (or --gzip), reading an existing cpio stream and piping it through gzip in a single command; BSD cpio, the default on macOS, supports the same flag. Both ship by default on essentially every Linux distribution and on macOS, meaning this specific conversion requires no additional installation on either platform.
Windows has included cpio.exe, based on libarchive's bsdcpio, since Windows 10 build 1803, capable of the same gzip compression from the command line, and Windows 11's 24H2 update added native File Explorer support for opening .cpio.gz archives directly, built on that same open-source libarchive project — support that simply didn't exist a few years earlier, when this conversion on Windows meant installing 7-Zip or a similar third-party tool specifically.
Pigz, the parallel gzip implementation written by Mark Adler (one of gzip's own original authors), divides input into 128 KB chunks and compresses them across multiple CPU cores at once; documented benchmarks show a multi-gigabyte cpio stream compressing in a small fraction of the time single-threaded gzip needs on the same multi-core hardware, though pigz's own documentation notes decompression isn't parallelized nearly as much, since DEFLATE decoding is inherently more sequential than encoding.
On the graphical side, 7-Zip and PeaZip on Windows both accept an existing .cpio file as input and can apply gzip compression to it directly. 7-Zip's own creation dialog treats this as a distinct step over an already-built cpio archive rather than a single combined "cpio.gz" option in its main archive-type list, which mirrors the same two-stage reality that GNU cpio's -z flag simply automates behind one command.
CPIO-TO-TAR.GZ — Real Problems Reported When Adding Gzip Compression to a CPIO
A documented issue reported on several bug trackers involves a tool displaying an obviously wrong, sometimes negative, uncompressed size for a newly compressed CPIO.GZ built from a very large original cpio stream — tracing directly back to ISIZE's 32-bit width, and in some implementations, to that value being read as signed rather than unsigned. The reliable fix reported in these threads is decompressing the file and counting bytes directly rather than trusting any tool's reported size for cpio streams anywhere near or beyond 4 GB.
A second recurring pattern involves someone compressing a folder that mixes source code with large media files into one CPIO.GZ, expecting the combined result to shrink close to what the text portion alone would achieve, then being surprised when the overall reduction is much smaller — the media files dominate the total size and barely compress at all, dragging down the average regardless of how well the text-based portion compressed on its own.
A third documented complaint involves expecting pigz to meaningfully speed up decompressing an existing CPIO.GZ the same way it speeds up creating one, then finding decompression times barely change — pigz's own documentation addresses this directly, since a single DEFLATE stream's decoding is a more inherently sequential process than encoding is, limiting how much decompression parallelism is actually possible.
CPIO-TO-TAR.GZ — Plain CPIO Compared With Its Gzip-Compressed Counterpart
| Feature | Plain CPIO | CPIO.GZ |
|---|---|---|
| Compression | None | Gzip (DEFLATE), RFC 1951/1952 |
| Compression speed | N/A | Fast, 32 KB sliding window |
| Typical size vs. original | ~100% (plus small header overhead) | Smaller on text; minimal gain on media |
| Uncompressed-size field limit | N/A | 32-bit, wraps past 4 GB |
| Parallel compression tool | N/A | pigz (chunk-independent) |
| Windows GUI support | Native since Windows 11 24H2 | Native since Windows 11 24H2 |
CPIO-TO-TAR.GZ — Questions About Compressing a CPIO Archive With Gzip
Will converting my CPIO to CPIO.GZ always shrink it noticeably?
Usually, since the original CPIO had zero compression, but the actual reduction depends on content — text and source code shrink meaningfully, while already-compressed media like JPEG or MP4 files shrink very little.
Does adding gzip compression change the files themselves?
No. Gzip compresses the cpio stream as a whole; the individual files come out byte-for-byte identical once the archive is decompressed and extracted.
Why does my file manager show an odd uncompressed size for a large CPIO.GZ?
Gzip's ISIZE trailer field is only 32 bits wide and stores the original size modulo 2^32 per RFC 1952 — a documented format limitation for anything 4 GB or larger, not a bug in a specific tool.
Is gzip or bzip2 the better choice for compressing a plain CPIO?
It depends on priorities: gzip compresses and decompresses considerably faster, while bzip2 often produces a smaller file on text-heavy content thanks to its wider block size.
Do I need extra software to compress a CPIO into CPIO.GZ?
Not on Linux or macOS, where GNU cpio and BSD cpio both support gzip compression directly via the -z flag. On Windows, cpio.exe (build 1803 and later) supports the same flag from the command line, and no separate installation is required.