From: Cong Wang <xiyou.wangcong@xxxxxxxxx> This is useful to analyse which files consume the space of initrd. Signed-off-by: Cong Wang <xiyou.wangcong@xxxxxxxxx> --- lsinitrd | 18 ++++++++++++++++-- 1 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lsinitrd b/lsinitrd index 7da9f61..ad7ece9 100755 --- a/lsinitrd +++ b/lsinitrd @@ -19,7 +19,17 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # -[[ $# -le 2 ]] || { echo "Usage: $(basename $0) [<initramfs file> [<filename>]]" ; exit 1 ; } +[[ $# -le 2 ]] || { echo "Usage: $(basename $0) [-s] [<initramfs file> [<filename>]]" ; exit 1 ; } + +sorted=0 +while getopts "s" opt; do + case $opt in + s) sorted=1;; + \?) exit 1;; + esac +done +shift $((OPTIND-1)) + image="${1:-/boot/initramfs-$(uname -r).img}" [[ -f "$image" ]] || { echo "$image does not exist" ; exit 1 ; } @@ -45,5 +55,9 @@ echo "$image: $(du -h $image | awk '{print $1}')" echo "========================================================================" $CAT "$image" | cpio --extract --verbose --quiet --to-stdout 'lib/dracut/dracut-*' 2>/dev/null echo "========================================================================" -$CAT "$image" | cpio --extract --verbose --quiet --list +if [ "$sorted" -eq 1 ]; then + $CAT "$image" | cpio --extract --verbose --quiet --list | sort -n -k5 +else + $CAT "$image" | cpio --extract --verbose --quiet --list +fi echo "========================================================================" -- 1.7.7.5 -- To unsubscribe from this list: send the line "unsubscribe initramfs" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html