3 # Copyright 2005-2010 Harald Hoyer <harald@redhat.com>
4 # Copyright 2005-2010 Red Hat, Inc. All rights reserved.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
23 echo "Usage: ${0##*/} [options] [<initramfs file> [<filename> [<filename> [...] ]]]"
24 echo "Usage: ${0##*/} [options] -k <kernel version>"
26 echo "-h, --help print a help message and exit."
27 echo "-s, --size sort the contents of the initramfs by size."
28 echo "-m, --mod list modules."
29 echo "-f, --file <filename> print the contents of <filename>."
30 echo "-k, --kver <kernel version> inspect the initramfs of <kernel version>."
36 [[ $dracutbasedir ]] || dracutbasedir
=/usr
/lib
/dracut
52 if (( $?
!= 0 )); then
61 -k|
--kver) KERNEL_VERSION
="$2"; shift;;
62 -f|
--file) filenames
[${2#/}]=1; shift;;
64 -h|
--help) usage
; exit 0;;
72 [[ $KERNEL_VERSION ]] || KERNEL_VERSION
="$(uname -r)"
76 if ! [[ -f "$image" ]]; then
78 echo "$image does not exist"
85 [[ -f /etc
/machine-id
]] && read MACHINE_ID
< /etc
/machine-id
87 if [[ -d /boot
/loader
/entries ||
-L /boot
/loader
/entries
]] \
88 && [[ $MACHINE_ID ]] \
89 && [[ -d /boot
/${MACHINE_ID} ||
-L /boot
/${MACHINE_ID} ]] ; then
90 image
="/boot/${MACHINE_ID}/${KERNEL_VERSION}/initrd"
92 image
="/boot/initramfs-${KERNEL_VERSION}.img"
102 if ! [[ -f "$image" ]]; then
104 echo "No <initramfs file> specified and the default image '$image' cannot be accessed!"
113 (( ${#filenames[@]} == 1 )) && nofileinfo
=1
114 for f
in ${!filenames[@]}; do
115 [[ $nofileinfo ]] ||
echo "initramfs:/$f"
116 [[ $nofileinfo ]] ||
echo "========================================================================"
117 $CAT $image |
cpio --extract --verbose --quiet --to-stdout $f 2>/dev
/null
119 [[ $nofileinfo ]] ||
echo "========================================================================"
120 [[ $nofileinfo ]] ||
echo
126 echo "dracut modules:"
127 $CAT "$image" |
cpio --extract --verbose --quiet --to-stdout -- 'lib/dracut/modules.txt' 'usr/lib/dracut/modules.txt' 2>/dev
/null
133 echo "========================================================================"
134 if [ "$sorted" -eq 1 ]; then
135 $CAT "$image" |
cpio --extract --verbose --quiet --list |
sort -n -k5
137 $CAT "$image" |
cpio --extract --verbose --quiet --list |
sort -k9
140 echo "========================================================================"
144 if (( ${#filenames[@]} <= 0 )); then
145 echo "Image: $image: $(du -h $image | while read a b; do echo $a;done)"
146 echo "========================================================================"
149 read -N 6 bin
< "$image"
153 is_early
=$
(cpio --extract --verbose --quiet --to-stdout -- 'early_cpio' < "$image" 2>/dev
/null
)
154 if [[ "$is_early" ]]; then
155 if (( ${#filenames[@]} > 0 )); then
158 echo "Early CPIO image"
161 SKIP
="$dracutbasedir/skipcpio"
162 if ! [[ -x $SKIP ]]; then
164 echo "'$SKIP' not found, cannot display remaining contents!" >&2
196 if echo "test"|xz|xzcat
--single-stream >/dev
/null
2>&1; then
197 echo "xzcat --single-stream --"
207 $SKIP "$@" |
$ORIG_CAT
217 if (( ${#filenames[@]} > 0 )); then
220 version
=$
($CAT "$image" |
cpio --extract --verbose --quiet --to-stdout -- 'lib/dracut/dracut-*' 'usr/lib/dracut/dracut-*' 2>/dev
/null
)
222 echo "Version: $version"
224 if [ "$modules" -eq 1 ]; then
226 echo "========================================================================"
228 echo -n "Arguments: "
229 $CAT "$image" |
cpio --extract --verbose --quiet --to-stdout -- 'lib/dracut/build-parameter.txt' 'usr/lib/dracut/build-parameter.txt' 2>/dev
/null