LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch
User Name
Password
Linux From Scratch This Forum is for the discussion of LFS.
LFS is a project that provides you with the steps necessary to build your own custom Linux system.

Notices


Reply
  Search this Thread
Old 10-28-2013, 12:06 AM   #1
AN28
Member
 
Registered: Apr 2013
Posts: 93

Rep: Reputation: 0
Runtime size Optimization


Hi,

I am interested in reducing the size of my LFS build and have been reading up on possible options and hints.

In most articles they recommend UPX!

So i thought i to try it as well. However I have a small issue on which version to download.

My machine type is i686-32 bit and I would like to know which of the options available should I go ahead with.

Thanks in advance!
 
Old 10-28-2013, 12:52 AM   #2
AN28
Member
 
Registered: Apr 2013
Posts: 93

Original Poster
Rep: Reputation: 0
Quoting this article,
Quote:
Stripping binaries and libraries can free a lot of space. Use the instructions
provided in the LFS book to do this. To find out whether there are still
unstripped libraries or binaries, run the following command:
# find / -exec file {} \; | grep "not stripped"
These can be stripped as well.

Can someone please tell me how I can strip these binaries/libraries. When I run the command suggested as above I get a long list with majority ending in
Quote:
dynamically linked, for GNU/Linux 2.6.25, not stripped
 
Old 10-28-2013, 03:09 AM   #3
Lennie
Member
 
Registered: Aug 2012
Location: Sweden
Distribution: LFS, built with pacman
Posts: 374

Rep: Reputation: 85
It's in the book...
 
Old 10-28-2013, 03:10 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
there is a command, named strip to do that.
 
Old 10-28-2013, 05:07 AM   #5
AN28
Member
 
Registered: Apr 2013
Posts: 93

Original Poster
Rep: Reputation: 0
So is it ok to use the commands as given in LFS even after completing BLFS?
Also do you guys know about UPX?
 
Old 10-28-2013, 05:13 AM   #6
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
you can use strip any time, it will not affect the running system (you may have problems during troubleshooting).
you will need i386 version of upx.
 
1 members found this post helpful.
Old 10-28-2013, 05:48 AM   #7
AN28
Member
 
Registered: Apr 2013
Posts: 93

Original Poster
Rep: Reputation: 0
Thank You pan64
 
Old 10-28-2013, 10:33 PM   #8
AN28
Member
 
Registered: Apr 2013
Posts: 93

Original Poster
Rep: Reputation: 0
Hi again,

I used
Quote:
find / -exec file {} \; | grep "not stripped"
from a blog post article to find the unstripped executables but do not have a proper understanding on the sed notations.

Can I use
Quote:
strip --strip-unneeded -exec file {} \; | grep "not stripped"
to strip all the unneeded exec ??
 
Old 10-29-2013, 01:20 AM   #9
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
no, that won't work at all.
the command find / -exec file {} \; will print out all the files together with their types you have and grep will filter the result (will select only the lines containing "not stripped").
the command find has this special syntax (where you can specify what are you looking for), but you cannot use the same syntax with strip. Instead, you need to combine the two commands to achieve what you need.
that will look like:
Code:
# this will be a small shell script, named strip.sh
#!/bin/bash

F="$1"
file "$F" | grep -q 'not stripped' && strip --strip-unneeded "$F"
}
# end of script

# and now you can execute the find command:
find / -exec strip.sh {} \;
 
Old 10-29-2013, 03:35 AM   #10
AN28
Member
 
Registered: Apr 2013
Posts: 93

Original Poster
Rep: Reputation: 0
Thank You for the explanation but I have a few doubts though....

Quote:
file "$F" | grep -q 'not stripped' && strip --strip-unneeded "$F"
}
should there be a paranthesis on the new line? If so why?


should the find command be within the strip.sh file or is that just the command to run in the terminal.
Because when I run it from the terminal i get the error:
Quote:
find: `strip.sh': No such file or directory
despite the fact that I set permissions for the sh file.
 
Old 10-29-2013, 03:44 AM   #11
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
you may need to write ./strip.sh or <full path to>/strip.sh

} is a mistake, just a copy&paste error or something like that, please ignore that.
 
Old 10-29-2013, 04:02 AM   #12
AN28
Member
 
Registered: Apr 2013
Posts: 93

Original Poster
Rep: Reputation: 0
I replaced the find command with
Quote:
find / -exec ./strip.sh {} \;
and I get the recursive output
Quote:
./strip.sh: pipe error: Too many open files
 
Old 10-29-2013, 04:36 AM   #13
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
I do not know what have you actually done, how your strip.sh script looks like, therefore hard to say anything.
 
Old 10-29-2013, 04:59 AM   #14
AN28
Member
 
Registered: Apr 2013
Posts: 93

Original Poster
Rep: Reputation: 0
It is pretty much the same as what you suggested only corrected the mistakes of } and the path to strip.sh

Quote:
# this will be a small shell script, named strip.sh
#!/bin/bash

F="$1"
file "$F" | grep -q 'not stripped' && strip --strip-unneeded "$F"

# end of script

# and now you can execute the find command:
find / -exec ./strip.sh {} \;


---------- Post added 10-29-13 at 04:59 AM ----------

It is pretty much the same as what you suggested only corrected the mistakes of } and the path to strip.sh

Quote:
# this will be a small shell script, named strip.sh
#!/bin/bash

F="$1"
file "$F" | grep -q 'not stripped' && strip --strip-unneeded "$F"

# end of script

# and now you can execute the find command:
find / -exec ./strip.sh {} \;
 
Old 10-29-2013, 05:43 AM   #15
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
you should not include the find (in the script), that should be executed in a shell - see there is an end of script line!
 
  


Reply



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
Best optimization univofky Linux - Distributions 2 02-15-2012 03:52 PM
local dns server cache size optimization flux242 Linux - Networking 1 04-25-2011 01:22 PM
Mysql optimization fullgore Linux - Server 2 11-09-2006 11:24 AM
kde optimization? alaios Linux - General 2 09-14-2003 02:55 PM
partitioning optimization stram Linux - Software 2 11-06-2001 06:27 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch

All times are GMT -5. The time now is 07:42 PM.

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