Gentoo Archives: gentoo-user

From: Grant Edwards <grant.b.edwards@×××××.com>
To: gentoo-user@l.g.o
Subject: [gentoo-user] How to copy gzip data from bytestream?
Date: Tue, 22 Feb 2022 01:29:22
Message-Id: sv1e96$5l6$1@ciao.gmane.io
1 I've got a "raw" USB flash drive containing a large chunk of gzipped
2 data. By "raw" I mean no partition table, now filesystem. Think of it
3 as a tape (if you're old enough).
4
5 gzip -tv is quite happy to validate the data and says it's OK, though
6 it says it ignored extra bytes after the end of the "file".
7
8 The flash drive size is 128GB, but the gzipped data is only maybe
9 20-30GB.
10
11 Question: is there a simple way to copy just the 'gzip' data from the
12 drive without copying the extra bytes after the end of the 'gzip'
13 data?
14
15 The only thing I can think of is:
16
17 $ zcat /dev/sdX | gzip -c > data.gz
18
19 But I was trying to figure out a way to do it without uncompressing
20 and recompressing the data. I had hoped that the gzip header would
21 contain a "length" field (so I would know how many bytes to copy using
22 dd), but it does not. Apparently, the only way to find the end of the
23 compressed data is to parse it using the proper algorithm (deflate, in
24 this case).
25
26 --
27 Grant

Replies

Subject Author
Re: [gentoo-user] How to copy gzip data from bytestream? Rich Freeman <rich0@g.o>
Re: [gentoo-user] How to copy gzip data from bytestream? Felix Kuperjans <felix@××××××××××××××.com>