In short:
How to extract the VERSION, SUBVERSION and PATCHLEVEl numbers from a system backup .img
? ideally without root permissions.
Extended:
From the following page:
https://www.raspberrypi.org/downloads/raspbian/
It is provided a Debian zip
extracted as .img
, which represents a full system backup of a Debian/Raspian system for arm architecture.
For the generation of a custom kernel, it is required to know the VERSION, SUBVERSION and PATCHLEVEL of the system, equivalent to what is provided by the typical
$ uname -r
4.9.0-3-amd64
The easiest way is to load the system directly and run the command, but that is not applicable in this case.
Goal:
The kernel of the image need to be patched and cross-compiled. My intention is to create a script for this process, so it may be "easily" applied further when kernel updates come.
Best Answer
This seems to work on the
2017-09-07-raspbian-stretch-lite.img
image at that site:(where
\37\213\10\0
identifies the start of gzipped data).As non-root, and assuming the first partition is always 4MiB within the image, using the GNU
mtools
to extract thekernel.img
from that vfat partition:If not, on systems with
/dev/fd
support (and GNUgrep
):(on other systems, use
file="2017-09-07-raspbian-stretch-lite.img"
, the/dev/fd/4
is just for making it easier to adapt to arbitrary file names)From, the zip file, you should be able to get away without extracting the whole image, just the first partition with: