-
Notifications
You must be signed in to change notification settings - Fork 0
/
minimize-initial-snapshot
executable file
·57 lines (56 loc) · 1.88 KB
/
minimize-initial-snapshot
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
set -e
set -x
export LC_ALL=C
if [ "$build_dir" = "" ]; then
build_dir="."
fi
sudo chroot $build_dir/fs/snapshot/0 apt-get clean
sudo rm -f $build_dir/fs/snapshot/0/var/lib/apt/lists/*Packages
sudo rm -fr $build_dir/fs/snapshot/0/var/cache/apt
sudo mkdir $build_dir/fs/snapshot/0/var/cache/apt
sudo rm -fr $build_dir/fs/snapshot/0/usr/share/locale
sudo mkdir $build_dir/fs/snapshot/0/usr/share/locale
sudo rm -fr $build_dir/fs/snapshot/0/usr/share/doc
sudo mkdir $build_dir/fs/snapshot/0/usr/share/doc
sudo rm -fr $build_dir/fs/snapshot/0/usr/share/man/??
sudo rm -fr $build_dir/fs/snapshot/0/usr/share/man/??_*
sudo rm -fr $build_dir/fs/snapshot/0/lib/modules/*/kernel/{sound,drivers/media,drivers/isdn,drivers/video,drivers/gpu}
sudo rm -fr $build_dir/fs/snasphot/0/boot/System.map-*
set +x
for i in \
fs/xfs/xfs.ko \
fs/btrfs/btrfs.ko \
fs/ocfs2/ocfs2.ko \
drivers/scsi/lpfc/lpfc.ko \
lib/test_bpf.ko \
drivers/scsi/qla2xxx/qla2xxx.ko \
drivers/infiniband/hw/hfi1/hfi1.ko \
drivers/scsi/bfa/bfa.ko \
fs/f2fs/f2fs.ko \
fs/ceph/ceph.ko \
drivers/block/drbd/drbd.ko \
fs/ubifs/ubifs.ko \
net/sctp/sctp.ko \
drivers/infiniband/hw/qib/ib_qib.ko \
net/ceph/libceph.ko \
fs/nilfs2/nilfs2.ko \
fs/reiserfs/reiserfs.ko \
drivers/infiniband/hw/cxgb4/iw_cxgb4.ko \
fs/afs/kafs.ko \
fs/ocfs2/dlm/ocfs2_dlm.ko \
fs/dlm/dlm.ko \
drivers/infiniband/hw/i40iw/i40iw.ko \
fs/jfs/jfs.ko \
drivers/mtd/ubi/ubi.ko \
drivers/infiniband/hw/nes/iw_nes.ko; do
sudo rm -f $build_dir/fs/snapshot/0/lib/modules/*/kernel/$i
done
(
for i in $(find $build_dir/fs/snapshot/0/lib/modules -name "*.ko"); do
if [ "$(file "$i"|grep ELF)" != "" ]; then
echo "$i"
fi
done
) | sudo sh -c 'while read i; do xz -9 $i; mv -i $i.xz $i; done'
sudo chroot $build_dir/fs/snapshot/0 update-initramfs -k all -c -t