|
Harald Hoyer |
83ebbb |
From 3ea5d2e28fe0e5790594d036c430dbad4e903186 Mon Sep 17 00:00:00 2001
|
|
Harald Hoyer |
83ebbb |
From: Cong Wang <xiyou.wangcong@gmail.com>
|
|
Harald Hoyer |
83ebbb |
Date: Tue, 10 Jan 2012 22:45:45 +0800
|
|
Harald Hoyer |
83ebbb |
Subject: [PATCH] lsinitrd: add '-s' option to sort the initrd output by file
|
|
Harald Hoyer |
83ebbb |
size
|
|
Harald Hoyer |
83ebbb |
|
|
Harald Hoyer |
83ebbb |
This is useful to analyse which files consume the space of initrd.
|
|
Harald Hoyer |
83ebbb |
|
|
Harald Hoyer |
83ebbb |
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
|
|
Harald Hoyer |
83ebbb |
---
|
|
Harald Hoyer |
83ebbb |
lsinitrd | 18 ++++++++++++++++--
|
|
Harald Hoyer |
83ebbb |
1 files changed, 16 insertions(+), 2 deletions(-)
|
|
Harald Hoyer |
83ebbb |
|
|
Harald Hoyer |
83ebbb |
diff --git a/lsinitrd b/lsinitrd
|
|
Harald Hoyer |
83ebbb |
index 7da9f61..ad7ece9 100755
|
|
Harald Hoyer |
83ebbb |
--- a/lsinitrd
|
|
Harald Hoyer |
83ebbb |
+++ b/lsinitrd
|
|
Harald Hoyer |
83ebbb |
@@ -19,7 +19,17 @@
|
|
Harald Hoyer |
83ebbb |
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
Harald Hoyer |
83ebbb |
#
|
|
Harald Hoyer |
83ebbb |
|
|
Harald Hoyer |
83ebbb |
-[[ $# -le 2 ]] || { echo "Usage: $(basename $0) [<initramfs file> [<filename>]]" ; exit 1 ; }
|
|
Harald Hoyer |
83ebbb |
+[[ $# -le 2 ]] || { echo "Usage: $(basename $0) [-s] [<initramfs file> [<filename>]]" ; exit 1 ; }
|
|
Harald Hoyer |
83ebbb |
+
|
|
Harald Hoyer |
83ebbb |
+sorted=0
|
|
Harald Hoyer |
83ebbb |
+while getopts "s" opt; do
|
|
Harald Hoyer |
83ebbb |
+ case $opt in
|
|
Harald Hoyer |
83ebbb |
+ s) sorted=1;;
|
|
Harald Hoyer |
83ebbb |
+ \?) exit 1;;
|
|
Harald Hoyer |
83ebbb |
+ esac
|
|
Harald Hoyer |
83ebbb |
+done
|
|
Harald Hoyer |
83ebbb |
+shift $((OPTIND-1))
|
|
Harald Hoyer |
83ebbb |
+
|
|
Harald Hoyer |
83ebbb |
image="${1:-/boot/initramfs-$(uname -r).img}"
|
|
Harald Hoyer |
83ebbb |
[[ -f "$image" ]] || { echo "$image does not exist" ; exit 1 ; }
|
|
Harald Hoyer |
83ebbb |
|
|
Harald Hoyer |
83ebbb |
@@ -45,5 +55,9 @@ echo "$image: $(du -h $image | awk '{print $1}')"
|
|
Harald Hoyer |
83ebbb |
echo "========================================================================"
|
|
Harald Hoyer |
83ebbb |
$CAT "$image" | cpio --extract --verbose --quiet --to-stdout 'lib/dracut/dracut-*' 2>/dev/null
|
|
Harald Hoyer |
83ebbb |
echo "========================================================================"
|
|
Harald Hoyer |
83ebbb |
-$CAT "$image" | cpio --extract --verbose --quiet --list
|
|
Harald Hoyer |
83ebbb |
+if [ "$sorted" -eq 1 ]; then
|
|
Harald Hoyer |
83ebbb |
+ $CAT "$image" | cpio --extract --verbose --quiet --list | sort -n -k5
|
|
Harald Hoyer |
83ebbb |
+else
|
|
Harald Hoyer |
83ebbb |
+ $CAT "$image" | cpio --extract --verbose --quiet --list
|
|
Harald Hoyer |
83ebbb |
+fi
|
|
Harald Hoyer |
83ebbb |
echo "========================================================================"
|