cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
thenumberdevil
Explorer
Explorer
843 Views
Registered: ‎04-21-2020

Optimizing rootfs

Hi All,

            I currently having a rootfs which is 410 mb in size. I have stripped off as many libraries as possible from rootfs. Still I could see such a huge rootfs system.

How should I tune the system. What are the points which I have to look in to. 

Please do provide me with pointers for the same.

Even after removing most of the things through root.config ,It is still prevalent

 

1016K ./usr/lib/libgio-2.0.so.0.5800.0
1004K ./lib/modules/4.19.0-xilinx/kernel/net
1000K ./usr/share/fonts/X11
996K ./usr/sbin/.debug
996K ./usr/lib/libstdc++.so.6.0.25
980K ./usr/src/debug/glibc/2.28-r0/git/elf
972K ./usr/libexec/installed-tests/glib/.debug/gdbus-test-codegen
968K ./usr/share/icons/Adwaita/48x48/status
960K ./usr/libexec/installed-tests/glib/.debug/gdbus-test-codegen-old
952K ./usr/share/icons/Adwaita/24x24/status
952K ./usr/share/icons/Adwaita/16x16/status
940K ./usr/share/icons/Adwaita/32x32/status
908K ./usr/lib/libX11.so.6.3.0
904K ./lib/libc-2.28.so
896K ./usr/include/X11/extensions
880K ./usr/src/debug/glibc/2.28-r0/git/posix
876K ./usr/lib/perl/5.24.4/CORE/charclass_invlists.h
872K ./usr/libexec/installed-tests/gdk-pixbuf
868K ./usr/share/icons/Adwaita/512x512/mimetypes
868K ./usr/lib/gobject-introspection/giscanner/__pycache__
868K ./usr/libexec/installed-tests/gdk-pixbuf/.debug
864K ./usr/include/c++/8.2.0/tr1
836K ./usr/lib/python3.5/lib-dynload/unicodedata.cpython-35m-arm-linux-gnueabihf.so
836K ./usr/lib/libxml2.so.2.9.8
836K ./usr/lib/libglib-2.0.so.0.5800.0
812K ./usr/src/debug/glibc/2.28-r0/git/libio
804K ./usr/share/icons/Adwaita/256x256/emotes
792K ./usr/include/glib-2.0/glib
780K ./usr/include/python3.5m
776K ./usr/share/fonts/X11/encodings
764K ./usr/share/icons/Adwaita/256x256/devices
760K ./usr/lib/opkg
756K ./usr/lib/opkg/alternatives
756K ./etc
748K ./usr/share/icons/Adwaita/256x256/apps
748K ./usr/sbin/.debug/nscd
748K ./usr/lib/.debug/libpng16.so.16.35.0
744K ./usr/src/debug/glibc/2.28-r0/git/stdlib
744K ./usr/lib/libdb-5.3.so
740K ./usr/share/gir-1.0/GObject-2.0.gir
728K ./usr/share/cracklib
724K ./usr/share/xcb
720K ./usr/lib/libcairo.so.2.11400.12
716K ./bin/bash.bash
704K ./usr/lib/girepository-1.0
692K ./usr/include/python2.7
648K ./lib/.debug/libnsl-2.28.so
640K ./usr/lib/gdk-pixbuf-2.0
632K ./usr/src/debug/glibc/2.28-r0/git/sunrpc
632K ./usr/src/debug/glibc/2.28-r0/git/locale
632K ./usr/share/fonts/X11/encodings/large
632K ./lib/modules/4.19.0-xilinx/kernel/drivers/media/tuners
624K ./usr/bin/btrfs
612K ./usr/src/debug/glibc/2.28-r0/git/resolv
612K ./usr/share/icons/Adwaita/256x256/actions
612K ./usr/include/c++/8.2.0/parallel
608K ./usr/share/icons/Adwaita/96x96/actions
608K ./usr/share/icons/Adwaita/64x64/actions
604K ./usr/src/debug/zlib
604K ./usr/share/icons/Adwaita/96x96/status
604K ./usr/share/icons/Adwaita/64x64/status
600K ./usr/src/debug/zlib/1.2.11-r0
600K ./usr/src/debug/glibc/2.28-r0/git/math
596K ./usr/src/debug/zlib/1.2.11-r0/zlib-1.2.11
596K ./usr/src/debug/glib-2.0/1_2.58.0-r0/glib-2.58.0/glib/gunidecomp.h
592K ./usr/lib/gdk-pixbuf-2.0/2.10.0
584K ./usr/lib/gdk-pixbuf-2.0/2.10.0/loaders
580K ./usr/lib/gdk-pixbuf-2.0/2.10.0/loaders/.debug
572K ./usr/lib/python3.5/xml/dom
556K ./usr/src/debug/glibc/2.28-r0/git/sysdeps/ieee754/dbl-64/uatan.tbl
548K ./lib/.debug/libthread_db-1.0.so
544K ./usr/lib/arm-xilinx-linux-gnueabi/8.2.0/libgcov.a
536K ./usr/src/debug/glibc/2.28-r0/git/include
536K ./lib/modules/4.19.0-xilinx/kernel/net/bluetooth
532K ./usr/lib/.debug/libgdk_pixbuf-2.0.so.0.3611.0
524K ./usr/lib/libsqlite3.so.0.8.6
524K ./usr/include/libxml2
520K ./usr/include/sqlite3.h
520K ./usr/include/libxml2/libxml
520K ./usr/include/c++/8.2.0/debug
516K ./usr/lib/zlib
516K ./lib/modules/4.19.0-xilinx/kernel/drivers/usb
512K ./usr/share/gobject-introspection-1.0
512K ./usr/lib/zlib/ptest
508K ./usr/lib/zlib/ptest/.debug
500K ./usr/lib/.debug/libpcre.so.1.2.10
484K ./usr/share/icons/Adwaita/22x22/actions
484K ./usr/share/gobject-introspection-1.0/tests
480K ./usr/share/mime/text
476K ./usr/share/icons/Adwaita/512x512/actions
468K ./usr/src/debug/glibc/2.28-r0/git/sysdeps/ieee754/dbl-64/upow.tbl
468K ./usr/share/cracklib/cracklib-small
464K ./usr/include/sys
452K ./usr/lib/libpcre
448K ./usr/src/debug/glibc/2.28-r0/git/sysdeps/arm
448K ./usr/lib/libpcre/ptest
444K ./usr/src/debug/glib-2.0/1_2.58.0-r0/glib-2.58.0/tests
444K ./usr/lib/libpcre/ptest/.debug
440K ./usr/src/debug/glibc/2.28-r0/git/malloc
440K ./usr/lib/python3.5/importlib
440K ./usr/include/linux/netfilter
436K ./usr/src/debug/glibc/2.28-r0/git/stdio-common
428K ./usr/libexec/installed-tests/glib/.debug/gdatetime
420K ./usr/lib/python3.5/xml/dom/__pycache__
420K ./usr/libexec/installed-tests/glib/.debug/regex
420K ./usr/include/drm
420K ./lib/libm-2.28.so
412K ./usr/src/debug/glibc/2.28-r0/git/nss
412K ./usr/lib/libpixman-1.so.0.34.0
412K ./usr/bin/gawk
412K ./lib/udev
408K ./lib/modules/4.19.0-xilinx/kernel/net/bluetooth/bluetooth.ko
400K ./usr/share/icons/Adwaita/48x48/devices
400K ./usr/lib/libfreetype.so.6.16.1
400K ./usr/libexec/installed-tests/glib/.debug/onceinit
396K ./usr/src/debug/glibc/2.28-r0/git/nscd
396K ./usr/share/icons/Adwaita/512x512/apps
396K ./usr/share/icons/Adwaita/32x32/devices
396K ./usr/share/icons/Adwaita/24x24/devices
396K ./usr/share/icons/Adwaita/16x16/devices
396K ./lib/.debug/librt-2.28.so
392K ./usr/include/bash
384K ./usr/src/debug/glib-2.0/1_2.58.0-r0/glib-2.58.0/glib/valgrind.h
384K ./sbin/ldconfig
380K ./usr/src/debug/glibc/2.28-r0/git/sysdeps/ieee754/flt-32
380K ./usr/share/mime/image
380K ./usr/share/fonts/ttf/LiberationSerif-Regular.ttf
380K ./usr/include/xcb/xproto.h
368K ./usr/lib/pkgconfig
364K ./usr/src/debug/glibc/2.28-r0/git/nis
364K ./usr/share/fonts/ttf/LiberationSerif-Italic.ttf
364K ./usr/share/fonts/ttf/LiberationSerif-BoldItalic.ttf
364K ./lib/.debug/libresolv-2.28.so
360K ./usr/src/debug/glibc/2.28-r0/git/string
360K ./usr/share/fonts/ttf/LiberationSerif-Bold.ttf
356K ./usr/src/debug/libpcre/8.42-r0/pcre-8.42/pcre_jit_compile.c
352K ./usr/src/debug/glibc/2.28-r0/git/sysdeps/posix
352K ./usr/src/debug/glibc/2.28-r0/git/debug
352K ./usr/bin/btrfs-convert
348K ./usr/share/icons/Adwaita/22x22/status
348K ./usr/share/fonts/ttf/LiberationSans-Italic.ttf
348K ./usr/share/fonts/ttf/LiberationSans-Bold.ttf
348K ./usr/bin/mkfs.btrfs
348K ./usr/bin/btrfs-image
344K ./usr/share/fonts/ttf/LiberationSans-Regular.ttf
344K ./usr/share/fonts/ttf/LiberationSans-BoldItalic.ttf
344K ./usr/include/c++/8.2.0/profile
340K ./usr/lib/girepository-1.0/Gio-2.0.typelib
340K ./usr/include/glib-2.0/gobject
336K ./usr/lib/libssl.so.1.1
336K ./usr/include/c++/8.2.0/experimental
336K ./lib/.debug/libnss_files-2.28.so
328K ./usr/src/debug/libffi
328K ./usr/bin/btrfstune
328K ./usr/bin/btrfs-select-super
328K ./usr/bin/btrfs-map-logical
328K ./usr/bin/btrfs-find-root
324K ./usr/src/debug/libffi/3.2.1-r0
323M total
323M .

 

0 Kudos
14 Replies
thenumberdevil
Explorer
Explorer
793 Views
Registered: ‎04-21-2020

Hi @sandeepg ,

         In my rootconfig, I have set the configuration as

#
# python
#

#
# python
#
# CONFIG_python is not set
# CONFIG_python-dbg is not set
# CONFIG_python-mailbox is not set
# CONFIG_python-resource is not set
# CONFIG_python-compile is not set
# CONFIG_python-math is not set
# CONFIG_python-difflib is not set
# CONFIG_python-gdbm is not set
# CONFIG_python-image is not set
# CONFIG_python-fcntl is not set
# CONFIG_python-2to3 is not set
# CONFIG_python-distutils is not set
# CONFIG_python-terminal is not set
# CONFIG_python-profile is not set
# CONFIG_python-mmap is not set
# CONFIG_python-robotparser is not set
# CONFIG_python-threading is not set
# CONFIG_python-zlib is not set
# CONFIG_python-pickle is not set
# CONFIG_python-xml is not set
# CONFIG_python-lang is not set
# CONFIG_python-email is not set
# CONFIG_python-contextlib is not set
# CONFIG_python-netclient is not set
# CONFIG_python-dev is not set
# CONFIG_python-idle is not set
# CONFIG_python-modules is not set
# CONFIG_python-logging is not set
# CONFIG_python-xmlrpc is not set
# CONFIG_python-codecs is not set
# CONFIG_python-stringold is not set
# CONFIG_python-argparse is not set
# CONFIG_python-numbers is not set
# CONFIG_python-debugger is not set
# CONFIG_python-html is not set
# CONFIG_python-shell is not set
# CONFIG_python-tkinter is not set
# CONFIG_python-textutils is not set
# CONFIG_python-compression is not set
# CONFIG_python-hotshot is not set
# CONFIG_python-core is not set
# CONFIG_python-json is not set
# CONFIG_python-sqlite3 is not set
# CONFIG_python-plistlib is not set
# CONFIG_python-curses is not set
# CONFIG_python-misc is not set
# CONFIG_python-tests is not set
# CONFIG_python-netserver is not set
# CONFIG_python-multiprocessing is not set
# CONFIG_python-syslog is not set
# CONFIG_python-pprint is not set
# CONFIG_python-pkgutil is not set
# CONFIG_python-mime is not set
# CONFIG_libpython2 is not set
# CONFIG_python-smtpd is not set
# CONFIG_python-pydoc is not set
# CONFIG_python-bsddb is not set
# CONFIG_python-re is not set
# CONFIG_python-ctypes is not set
# CONFIG_python-compiler is not set
# CONFIG_python-unittest is not set
# CONFIG_python-db is not set
# CONFIG_python-io is not set
# CONFIG_python-unixadmin is not set
# CONFIG_python-datetime is not set
# CONFIG_python-subprocess is not set
# CONFIG_python-audio is not set
# CONFIG_python-crypt is not set

#
# python-nose
#
# CONFIG_python-nose is not set
# CONFIG_python-nose-dbg is not set
# CONFIG_python-nose-dev is not set

#
# python-numpy
#
# CONFIG_python-numpy is not set
# CONFIG_python-numpy-dev is not set
# CONFIG_python-numpy-dbg is not set

#
# python-scons
#
# CONFIG_python-scons is not set
# CONFIG_python-scons-dev is not set
# CONFIG_python-scons-dbg is not set

#
# python3-dbus
#
# CONFIG_python3-dbus is not set
# CONFIG_python3-dbus-dbg is not set
# CONFIG_python3-dbus-dev is not set

#
# python3-pygobject
#
# CONFIG_python3-pygobject is not set
# CONFIG_python3-pygobject-dbg is not set
# CONFIG_python3-pygobject-dev is not set

But still seeing the phython in the library. Could you please let me know how to remove them?

 

 

0 Kudos
thenumberdevil
Explorer
Explorer
779 Views
Registered: ‎04-21-2020

Hi,

       How to setup the petalinux configuration in such a way that we get the minimal rootfs possible.

 

0 Kudos
rfs613
Scholar
Scholar
773 Views
Registered: ‎05-28-2013

I cannot explain why your rootfs is so large. Perhaps you are using a pre-built image with a full desktop environment?

For comparison, with "default" settings in a newly created project, the rootfs is around 6.6MB, and contains no python, no X11, no fonts, etc.
The rootfs_config file for this project has everything commented out, except for CONFIG_ROOTFS_ROOT_PASSWD setting.

I would suggest that you try creating a new project as per UG1144 for your board.

0 Kudos
thenumberdevil
Explorer
Explorer
766 Views
Registered: ‎04-21-2020

Hi  @rfs613 ,

                     Thank you for the response. Is it possible to strip of the image by using some macros in our project environment?. The project has grown a bit out of hand. 

So is there a way to reduce this?.

Yes you are correct. I have switched off everythig.But still I see all libraries loaded in to the system. Is there a possibility control or configure the same.

 

0 Kudos
rfs613
Scholar
Scholar
758 Views
Registered: ‎05-28-2013

> Is it possible to strip of the image by using some macros in our project environment?

It is possible to take the rootfs, unpack it, modify (add/remove files), and pack it back up. There are no specific macros for this task. You will face the question of which files can be removed safely, which ones are necessary, etc. Also this is a manual process, you will need to repeat it every time you rebuild. So I would not recommend this approach.

Instead I would build up a new project in parallel to your existing one. Start with default settings in petalinux, this should produce a small image. Ensure that you can boot this image on your hardware.

Then figure out what functionality is missing, compared to your "big" image. Enable the missing functionality one step at a time, so you can determine where the large size is coming from. Once you know what is contributing to the size, you can then evaluate if it is necessary, what alternatives exist, etc.

There seems to be a mismatch currently between your configuration ("I have switched off everything") and your resulting rootfs. Please ensure you are following the correct sequence for petalinux-config, petalinux-build, etc as per UG1144 guide.

0 Kudos
thenumberdevil
Explorer
Explorer
750 Views
Registered: ‎04-21-2020

Hi @rfs613 ,

                          Thank you for the response. I see the point. I will tryout building a new system as per your direction.

 

0 Kudos
thenumberdevil
Explorer
Explorer
658 Views
Registered: ‎04-21-2020

Hi @rfs613 ,

                     I have build the system, And these are the results I see currently

petalinux-create --type project --template zynq --name project
cd project-spec/
petalinux-config --get-hw-description /home/zoidharm/work/stable/PS_PetaLinux/fpga/zynq_1.2
petalinux-build

With this bare minimum build I could see a rootfs  of size

425M Jan 28 19:59 rootfs.ext4

 

Am I missing something.

 

 

0 Kudos
rfs613
Scholar
Scholar
653 Views
Registered: ‎05-28-2013

One potential difference is that I used a reference BSP rather than a template config:

    petalinux-create -t project -s $HOME/petalinux/xilinx-zc702-v2019.2-final.bsp -n myproject

Another difference is that I am not building an ext4 image. Perhaps the ext4 is larger due to a configuration setting? It might be "reserving" space for use at run-time. My images/linux folder has rootfs.cpio, jffs2 and tar formats. These are in the ~10MB size range, and smaller when compressed (rootfs.tar.gz is 6.6MB).

Edit to add: you could try loopback mounting the rootfs.ext4, and then use "df" command to see how full it actually is.

0 Kudos
thenumberdevil
Explorer
Explorer
638 Views
Registered: ‎04-21-2020

Hi @rfs613 ,

                       Thank you for your response. Please find the result for your reference. I build the project using  the bsp mentioned by you. But still I get such a large  rootfs. IN addition to that I expected it to compile out of box,

But after enabling some libraries I could get it working. While compilation I noted that we have the python library  included . For your reference adding the rootfs. config which got generated.

drwxrwxr-x 2 zoidharm zoidharm 4.0K Jan 28 23:51 .
drwxrwxr-x 3 zoidharm zoidharm 4.0K Jan 28 23:51 ..
-rw-r--r-- 1 zoidharm zoidharm 92M Jan 28 23:50 image.ub
-rw-r--r-- 1 zoidharm zoidharm 286M Jan 28 23:49 rootfs.cpio
-rw-r--r-- 1 zoidharm zoidharm 77M Jan 28 23:49 rootfs.cpio.bz2
-rw-r--r-- 1 zoidharm zoidharm 88M Jan 28 23:49 rootfs.cpio.gz
-rw-r--r-- 1 zoidharm zoidharm 88M Jan 28 23:49 rootfs.cpio.gz.u-boot
-rw-r--r-- 1 zoidharm zoidharm 428M Jan 28 23:49 rootfs.ext3
-rw-r--r-- 1 zoidharm zoidharm 78M Jan 28 23:49 rootfs.ext3.bz2
-rw-r--r-- 1 zoidharm zoidharm 428M Jan 28 23:49 rootfs.ext4
-rw-r--r-- 1 zoidharm zoidharm 88M Jan 28 23:49 rootfs.ext4.gz
-rw-r--r-- 1 zoidharm zoidharm 134M Jan 28 23:49 rootfs.jffs2
-rw-r--r-- 1 zoidharm zoidharm 18K Jan 28 23:49 rootfs.manifest
-rw-rw-r-- 1 zoidharm zoidharm 957 Jan 28 23:49 rootfs.qemuboot.conf
-rw-r--r-- 1 zoidharm zoidharm 78M Jan 28 23:49 rootfs.tar.bz2
-rw-r--r-- 1 zoidharm zoidharm 88M Jan 28 23:49 rootfs.tar.gz
-rw-r--r-- 1 zoidharm zoidharm 512K Jan 28 23:49 rootfs.testdata.json
-rw-r--r-- 1 zoidharm zoidharm 3.9M Jan 28 23:25 system.bit
-rw-r--r-- 1 zoidharm zoidharm 26K Jan 28 23:28 system.dtb
-rw-r--r-- 1 zoidharm zoidharm 2.0M Jan 28 23:50 System.map.linux
-rw-r--r-- 1 zoidharm zoidharm 576K Jan 28 23:29 u-boot.bin
-rw-r--r-- 1 zoidharm zoidharm 641K Jan 28 23:29 u-boot.elf
-rw-r--r-- 1 zoidharm zoidharm 92M Jan 28 23:50 uImage
-rw-r--r-- 1 zoidharm zoidharm 298M Jan 28 23:50 vmlinux
-rw-r--r-- 1 zoidharm zoidharm 92M Jan 28 23:50 zImage
-rw-r--r-- 1 zoidharm zoidharm 548K Jan 28 23:29 zynq_fsbl.elf

0 Kudos
rfs613
Scholar
Scholar
611 Views
Registered: ‎05-28-2013

It should compile out of the box, without having to enable additional packages.

Comparing your rootfs_config to mine, the differences are that you have enabled several graphics-related items:
adawaita-icon-themes, cantrell-fonts, liberation-fonts, fontconfig, font-util, gdk-pixbuf.
Do you actually need fonts, icons? Most embedded devices do not need these, unless they are driving a monitor via HDMI or similar.

As well, for many of those packages, the -dev and -dbg versions are also enabled. This will add considerably to your size.

You mentioned python library, but your config does not seem to have any python packages enabled.

0 Kudos
thenumberdevil
Explorer
Explorer
575 Views
Registered: ‎04-21-2020

Hi @rfs613 ,

                       It was surprising to see that system did not compile out box. I have to add these components to get it up and running. I can remove the dev and and dbg versions.

I have not added the python library to the system. But while compiling I could see that python libraries being compiled in.

This is the error which I get if I am not enabling the gdk_pixbuf.

 

ERROR: petalinux-user-image-1.0-r0 do_rootfs: The postinstall intercept hook 'update_pixbuf_cache' failed, details in /home/zoidharm/work/new/2delhi/build/tmp/work/zc702_zynq7-xilinx-linux-gnueabi/petalinux-user-image/1.0-r0/temp/log.do_rootfs
ERROR: petalinux-user-image-1.0-r0 do_rootfs: Function failed: do_rootfs
ERROR: Logfile of failure stored in: /home/zoidharm/work/new/2delhi/build/tmp/work/zc702_zynq7-xilinx-linux-gnueabi/petalinux-user-image/1.0-r0/temp/log.do_rootfs.20170
ERROR: Task (/home/zoidharm/work/new/2delhi/project-spec/meta-plnx-generated/recipes-core/images/petalinux-user-image.bb:do_rootfs) failed with exit code '1'
NOTE: Tasks Summary: Attempted 3736 tasks of which 3730 didn't need to be rerun and 1 failed.

 

 

 

0 Kudos
rfs613
Scholar
Scholar
547 Views
Registered: ‎05-28-2013

The same error message was reported here: https://forums.xilinx.com/t5/Embedded-Linux/petalinux-2017-1-postinstall-hook-failed/td-p/779738
Are you using 2017.1 version? If so, it seems this was fixed in 2017.2.

 

0 Kudos
thenumberdevil
Explorer
Explorer
429 Views
Registered: ‎04-21-2020

Hi  @rfs613 ,

                       I am using v2019.1 for building it up. But could not understand why I am not able to control python and other components  entering in to the rootfs using rootconfig

I will be super happy If I could build such a 6.5 mb rootfs

 

0 Kudos
rfs613
Scholar
Scholar
416 Views
Registered: ‎05-28-2013

Hmm, so I am using 2019.2 rather than 2019.1. For comparison, I just tried with the following steps:

petalinux-create -t project -s /home/ralphs/fpga/xilinx/xilinx-zc702-v2019.2-final.bsp -n test2
cd test2
petalinux-build

About 5 minutes later, the build finishes, with a bunch of errors like "Nothing PROVIDES 'numactl-ptest'...". Despite those apparent errors, a reasonably-sized rootfs has been created:

ls -lh images/linux/rootfs.tar.gz
-rw-r--r-- 1 ralphs ralphs 6.6M Jan 31 21:30 images/linux/rootfs.tar.gz

There is no python in the image:

tar tvf images/linux/rootfs.tar.gz | grep python    # nothing found

Also there are no fonts, pixbuf, etc.

0 Kudos