LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices


Reply
  Search this Thread
Old 01-11-2019, 01:40 AM   #1
OkCalis
Member
 
Registered: Dec 2017
Posts: 34

Rep: Reputation: Disabled
Question How can I shrink a working root file system for embedded Linux


Hello,

I have a JFFS2 root file system that takes about 20MB on the NAND flash of my ARM9 processor, and it is working fine with Linux 3.2 (Ångström distro).

I want to convert the JFFS2 into a RAM file system, but before that, I must minimize its size so that it won't make the overall kernel too large. The problem is, I don't know how to do that.

This forum thread explains the necessary components of a root file system pretty well. It suggests, for instance, that the /lib directory is needed only if the executables are linked dynamically.

I build my executable with
Code:
gcc -static ...
so I expect it to be statically linked only. When I issue the
Code:
ldd <program>.out
command, I get: "not a dynamic executable". However, if I type:
Code:
file <program>.out
I get:
Code:
ELF 32-bit LSB executable, ARM, EABI5, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.3, for GNU/Linux 2.6.16, not stripped
So does my program need any shared object in the /lib directory (like pthread, for example)?

I tried removing all shared objects in the /lib directory, which resulted in all programs (including shell commands) malfunctioning, stating that needed shared libraries are missing.

Long story short, how can I know which files in my 20-MB root file system (not just library files, but files of any kind) are expendable?

Thanks in advance,
OkCalis

Last edited by OkCalis; 01-11-2019 at 01:43 AM. Reason: Clarification
 
Old 01-11-2019, 03:00 AM   #2
ehartman
Senior Member
 
Registered: Jul 2007
Location: Delft, The Netherlands
Distribution: Slackware
Posts: 1,674

Rep: Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888
Quote:
Originally Posted by OkCalis View Post
Code:
ELF 32-bit LSB executable, ARM, EABI5, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.3, for GNU/Linux 2.6.16, not stripped
So does my program need any shared object in the /lib directory (like pthread, for example)?
No, but as the file command shows, the shared library loader (/lib/ld-linux.so.3) is needed for your program, even though it has nothing to do.

Quote:
I tried removing all shared objects in the /lib directory, which resulted in all programs (including shell commands) malfunctioning, stating that needed shared libraries are missing.

Long story short, how can I know which files in my 20-MB root file system (not just library files, but files of any kind) are expendable?
Mostly by trial and error. Most of the supplied system binaries in /*bin will be shared executables so most of the basic /lib (and probably /usr/lib) libraries will be needed for them. But most savings can be made in the /usr tree (and luckily that mostly is the largest one). But then again, 20MB is already quite small, my /lib is about 250 MB

BTW: not using shared libraries will increase the size of your own executables by quite a bit, so maybe you should experiment with NOT compiling them as static executables.
One of the reasons for shared executables is that one time all functions takes up less space then all of the executables having separate copies of some of those functions.
Of course, this does depend on how many executables you build, but as most shared libraries are there anyway, why not use them?

Last edited by ehartman; 01-14-2019 at 07:29 AM. Reason: explanation about shared objects
 
1 members found this post helpful.
Old 01-14-2019, 05:21 AM   #3
OkCalis
Member
 
Registered: Dec 2017
Posts: 34

Original Poster
Rep: Reputation: Disabled
Thanks, Ehartman, your explanation was very useful.
I'm going to remove the /bin and /sbin executables step by step until I see something goes wrong.
Also, I'll remove the "-static" option from my makefile, since it does not seem to offer any advantages.

Have a good day,
OkCalis
 
  


Reply

Tags
dynamic linking, initramfs, rootfs, shared object



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to shrink root file system (LVM) in Linux Fedora 9? ravisingh1 Linux - Laptop and Netbook 16 05-16-2013 10:23 AM
[SOLVED] Starting File System .. Starting File System .. Starting File System .. Starting File rmknox Linux - Newbie 3 08-15-2010 11:30 PM
Xpert in 8-16 bit microcontroller embedded system now inclining toward embedded linux priyadarshan Linux - Embedded & Single-board computer 2 02-12-2009 04:28 AM
shrink file system with out unmounting ravikumarG AIX 2 06-29-2005 08:48 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 04:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration