squashfs.img became larger after clean unused files

General support questions
Post Reply
if_else
Posts: 1
Joined: 2014/07/22 02:54:20

squashfs.img became larger after clean unused files

Post by if_else » 2014/07/22 03:25:05

hi guys

I have refered to the small ks config of cloud-kickstarts.git, cleaned unused locales and some static file:

https://git.fedorahosted.org/cgit/cloud ... mall-20.ks

After livemedia-creator generated squashfs.img, it was NOT slim but become larger.
my minimal ks config paste: http://ix.io/dvv
this was the difference ks config with before simplified ks config:

Code: Select all

+gzip -9 /usr/share/cracklib/pw_dict.pwd
+
+localedef --list-archive | grep -v en_US | xargs localedef --delete-from-archive
+mv -f /usr/lib/locale/locale-archive /usr/lib/locale/locale-archive.tmpl
+/usr/sbin/build-locale-archive
+mv -f /usr/share/locale/en /usr/share/locale/en_US /tmp
+rm -rf /usr/share/locale/*
+mv /tmp/en /tmp/en_US /usr/share/locale/
+mv /usr/share/i18n/locales/en_US /tmp
+rm -rf /usr/share/i18n/locales/*
+mv /tmp/en_US /usr/share/i18n/locales/
+echo '%_install_langs C:en:en_US:en_US.UTF-8' >> /etc/rpm/macros.imgcreate
+
+truncate -c -s 0 /var/log/lastlog

 rpm -qa|sort > /root/rpm-qa.txt
 yum clean all
 rm -f /etc/resolv.conf
 rm -f /var/lib/rpm/__db*
+rm -rf /tmp/*
+rm -fr /var/log/anaconda
 rm -fr /usr/share/doc/*
+rm -fr /usr/share/backgrounds/*
+rm -fr /usr/share/kde4/*
+rm -fr /var/lib/yum/yumdb/*
add these simplify operations:

- compress cracklib pw_dict
- clean unused locale files
- rm some static pictures and log files

I mounted the different squashfs.img file:

Code: Select all

# losetup -l
NAME       SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE
/dev/loop0         0      0         1  0 /var/tmp/tmp3vk1TM/LiveOS/squashfs.img
/dev/loop1         0      0         1  1 /mnt/1/LiveOS/rootfs.img
/dev/loop2         0      0         1  0 /var/tmp/tmpWRiKra/LiveOS/squashfs.img
/dev/loop3         0      0         1  1 /mnt/2/LiveOS/rootfs.img

# df -h
/dev/loop0      312M  312M     0 100% /mnt/1
/dev/loop1       21G  806M   20G   4% /media/1          <-- before clean
/dev/loop2      315M  315M     0 100% /mnt/2
/dev/loop3       21G  619M   21G   3% /media/2          <-- after clean
the installed rootfs size was saved 806M - 619M = 187M, but squashfs.img became larger : 315M - 312M = 3M
where has the spare space gone ?

Code: Select all

# du -sh /var/tmp/tmp3vk1TM/LiveOS/squashfs.img
312M    /var/tmp/tmp3vk1TM/LiveOS/squashfs.img

# du -sh /var/tmp/tmpWRiKra/LiveOS/squashfs.img
315M    /var/tmp/tmpWRiKra/LiveOS/squashfs.img

# find . -name rootfs.img|xargs du -sh
1.1G    ./1/LiveOS/rootfs.img
1.1G    ./2/LiveOS/rootfs.img
the different of mounted rootfs size was mainly locale directory:

Code: Select all

# du -sh /media/1/*|sort -hr                            # du -sh /media/2/*|sort -hr
727M    /media/1/usr            <-- cleaned -->         540M    /media/2/usr
42M     /media/1/boot                                   42M     /media/2/boot
21M     /media/1/var                                    21M     /media/2/var
9.6M    /media/1/etc                                    9.6M    /media/2/etc
3.2M    /media/1/opt                                    3.2M    /media/2/opt
144K    /media/1/root                                   144K    /media/2/root
12K     /media/1/lost+found                             12K     /media/2/lost+found
11K     /media/1/tmp                                    9.0K    /media/2/tmp
1.0K    /media/1/sys                                    1.0K    /media/2/sys
1.0K    /media/1/srv                                    1.0K    /media/2/srv
1.0K    /media/1/run                                    1.0K    /media/2/run
1.0K    /media/1/proc                                   1.0K    /media/2/proc
1.0K    /media/1/mnt                                    1.0K    /media/2/mnt
1.0K    /media/1/media                                  1.0K    /media/2/media
1.0K    /media/1/home                                   1.0K    /media/2/home
1.0K    /media/1/dev                                    1.0K    /media/2/dev
0       /media/1/sbin                                   0       /media/2/sbin
0       /media/1/lib64                                  0       /media/2/lib64
0       /media/1/lib                                    0       /media/2/lib
0       /media/1/bin                                    0       /media/2/bin
mainly cleaned file : /usr/lib/locale

Code: Select all

# du -sh /media/1/usr/lib/*|sort -hr|head               # du -sh /media/2/usr/lib/*|sort -hr|head
103M    /media/1/usr/lib/modules                        103M    /media/2/usr/lib/modules
102M    /media/1/usr/lib/locale       <-- locale -->    2.0M    /media/2/usr/lib/locale
52M     /media/1/usr/lib/firmware                       52M     /media/2/usr/lib/firmware
9.1M    /media/1/usr/lib/udev                           9.1M    /media/2/usr/lib/udev
8.1M    /media/1/usr/lib/python2.7                      8.1M    /media/2/usr/lib/python2.7
4.2M    /media/1/usr/lib/grub                           4.2M    /media/2/usr/lib/grub
3.9M    /media/1/usr/lib/systemd                        3.9M    /media/2/usr/lib/systemd
1.8M    /media/1/usr/lib/kbd                            1.8M    /media/2/usr/lib/kbd
710K    /media/1/usr/lib/dracut                         710K    /media/2/usr/lib/dracut
280K    /media/1/usr/lib/rpm                            280K    /media/2/usr/lib/rpm
mainly cleaned file : /usr/share/locale

Code: Select all

# du -sh /media/1/usr/share/*|sort -hr|head             # du -sh /media/2/usr/share/*|sort -hr|head
79M     /media/1/usr/share/locale     <-- locale -->    22M     /media/2/usr/share/vim
22M     /media/1/usr/share/vim                          17M     /media/2/usr/share/perl5
17M     /media/1/usr/share/perl5                        13M     /media/2/usr/share/nmap
13M     /media/1/usr/share/nmap                         13M     /media/2/usr/share/man
13M     /media/1/usr/share/man                          5.2M    /media/2/usr/share/hwdata
9.0M    /media/1/usr/share/cracklib                     4.3M    /media/2/usr/share/cracklib
8.6M    /media/1/usr/share/i18n                         4.2M    /media/2/usr/share/mime
5.2M    /media/1/usr/share/hwdata                       3.0M    /media/2/usr/share/i18n
4.2M    /media/1/usr/share/mime                         2.9M    /media/2/usr/share/misc
2.9M    /media/1/usr/share/misc                         2.7M    /media/2/usr/share/info
how could I optimize the cleaned spare space of squashfs.img

thanks

Post Reply

Return to “CentOS 7 - General Support”