LinuxQuestions.org
Help answer threads with 0 replies.
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
 
LinkBack Search this Thread
Old 12-17-2012, 06:18 PM   #1
stoat
Member
 
Registered: May 2007
Distribution: LFS
Posts: 397

Rep: Reputation: 130Reputation: 130
Stripping the binaries and libraries in a finished BLFS system?


I am currently using a BLFS system built in September on top of an LFS 7.2 system. When I built the LFS system, I skipped stripping. Now I do want to strip the binaries and libraries. Is it possible/reasonable/acceptable to use the following find & strip command that I adapted from the one in chapter 6 of the LFS book to strip all of the binaries and libraries in a finished BLFS system? I know the binaries cannot be running at the time, so I would do this procedure from another system while the BLFS system is mounted at /mnt/temp. Of course, I will create a backup first. I don't expect a guarantee, just an opinion of the concept in a finished BLFS system.
Code:
su
cd /mnt/temp
/bin/find {,usr/}{bin,lib,sbin} -type f \
-exec /bin/strip --strip-debug '{}' ';'
The only difference from the book's is the cd to the mount point, the removal of "/tools" from the find and strip commands, and the removal of the leading "/". In my head this will work, and I know I could just try it and see, but I still would value some opinions.

P.S.: I wanted to ask this question at the blfs-support mailing list. But guess what. I don't know how mailing lists work. I mean, I read them all the time, but I never submit anything. I don't want to subscribe, just ask this question. Can somebody explain how? It says there how to email messages to all of the list members and gives an email address. Is that all I would do? Are those questions and replies merely email transactions that somehow get posted and ordered in those messages I see in the archives? I just don't want to look stupid over there. It's too late for that for me here.
 
Old 12-18-2012, 09:25 AM   #2
Keith Hedger
Member
 
Registered: Jun 2010
Location: Devon,UK
Distribution: Linux From Scratch, Slackware64,
Posts: 734

Rep: Reputation: 166Reputation: 166
looks OK you could also try some options
Code:
-s
--strip-all
   Remove all symbols.

-g
-S
-d
--strip-debug
    Remove debugging symbols only.

--strip-unneeded
    Remove all symbols that are not needed for relocation processing.
From the man-page/
I usually use "--strip-unneeded" when installing ne software.
 
Old 12-18-2012, 12:48 PM   #3
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371
Maybe this link can be of general use:

- 10 Linux Strip Command Examples

Goes beyond what is asked for in this thread, but does have nicely explained examples.
 
Old 12-18-2012, 02:49 PM   #4
stoat
Member
 
Registered: May 2007
Distribution: LFS
Posts: 397

Original Poster
Rep: Reputation: 130Reputation: 130
I went ahead with the strip --strip-debug thing I mentioned above on a cloned system that was mounted in a maintenance system. It ran through the designated directories and did its thing. The system rebooted and seems normal. I wasn't interested in this for disk space, but FWIW the system size was reduced by 800 MB (5.5 GB to 4.7 GB) and 5000+ files were changed according to Tripwire. I'm not recommending this to anyone. I merely am testing some things, wanted and opinion of this, and reported what happened.

Last edited by stoat; 12-18-2012 at 04:19 PM.
 
Old 12-19-2012, 02:51 PM   #5
re_nelson
Member
 
Registered: Oct 2011
Location: Texas, USA
Distribution: LFS-SVN, Gentoo-2.2 ~amd64, CentOS-6.5, Slackware64-current, FreeBSD-9.2-STABLE
Posts: 173

Rep: Reputation: Disabled
Quote:
Originally Posted by stoat View Post
I went ahead with the strip --strip-debug thing I mentioned above on a cloned system that was mounted in a maintenance system. It ran through the designated directories and did its thing. The system rebooted and seems normal. I wasn't interested in this for disk space, but FWIW the system size was reduced by 800 MB (5.5 GB to 4.7 GB) and 5000+ files were changed according to Tripwire. I'm not recommending this to anyone. I merely am testing some things, wanted and opinion of this, and reported what happened.
For what it's worth (with a host of caveats: don't try this on an important production system, YMMV and "it works for me" [TM]), I am very aggressive when it comes to stripping on my LFS system. It's not that space is a concern. I do it just to see what happens. And, I even do it on a live system! The only binary I've ever had a problem with is udevd. So I simply kill that process before doing the uber-stripping as explained here.

1). Strip the kernel modules:
Code:
find /lib/modules/*/ -name '*.ko' -type f -exec /tools/bin/strip -p -X -R .note -R .comment {} +
2). Strip static archives and objects:
Code:
find {/usr,}/lib/ -name '*.[ao]' -type f -exec /tools/bin/strip -p -x -R .note -R .comment {} +
3). Strip shared libraries and binaries:
Code:
find {/usr,}/{bin,sbin,lib}/ \( -name '*glib*' -o -name bash \) -type f -exec file {} + | awk -F: '/ELF .*(shared|executable)/ { print "/tools/bin/strip -p -s -R .note -R .comment", $1 }' | sh
I use the -p flag to keep the original modification times in place. The basis of this aggressive stripping (notably -R .note -R .comment
comes from reviewing Red Hat's brp-strip functionality which they apply to RPM packages. I may be on the edge having done something horrendous but as as longtime LFS user, aside from udevd, it hasn't broken anything...yet. I'd only give this a try solely to satisfy your curiosity.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] starting BLFS when finished LFS in Slackware & Please help me! Forget-Me-Not Linux From Scratch 19 11-16-2012 09:00 AM
starting BLFS when finished LFS in Slackware & Please help me! Forget-Me-Not Slackware 3 11-02-2012 06:10 AM
Stripping binaries hydraMax Programming 1 07-30-2011 01:49 PM
how to start blfs once lfs is finished bhismnarayan Linux From Scratch 5 03-14-2011 11:22 AM
Finished on LFS But how to continue in BLFS MajesticX Linux From Scratch 5 09-17-2008 07:12 AM


All times are GMT -5. The time now is 12:05 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration