How to strip a Linux system?

2

1

I've been building my own Linux distro, and I've stripped the binaries, etc. The system won't use GCC or development tools, as it will be a Chrome kiosk, so it would greatly help if I could strip down the system...

I was wondering, is there a way that I can delete all of the unused system files (like binaries, etc.) by watching what files/libraries are used during runtime? Maybe another method is preferred, but is there a way to accomplish something like this?

Blender

Posted 2010-12-09T16:01:31.967

Reputation: 596

It would probably be easier to do this by building up rather than stripping down. Also, you may be interested in http://www.busybox.net/

– zwol – 2010-12-09T16:04:14.457

1Just out of curiosity, why the nickname blender? – None – 2010-12-09T16:04:25.387

1Best place to ask is SuperUser.com – Robin Day – 2010-12-09T16:04:40.253

@The Elite Gentleman, http://www.blender.org/. I am an avid user!

– Blender – 2010-12-09T16:12:28.377

if you don't get answer here; try http://unix.stackexchange.com/

– bbaja42 – 2010-12-09T21:01:51.747

Answers

3

These are some things I would do:

  • Build my own kernel with no loadable modules. (Build in all the required modules.) Eliminates /lib/modules ..
  • Review the init scripts and drop any programs that are not required.
  • Use ldd on the programs that are run to identify the libaries that are required.
  • Identify which commands can be replaced by busybox, and build a custom busybox to supply only those commands.
  • Identify the programs required for support and add them in.

Consider looking at what is included in a distribution like OpenWRT to see what is required for a relatively base installation. Remove what your don't need, and add what your do. OpenWRT now has builder package which makes it easier to investigate the distribution.

BillThor

Posted 2010-12-09T16:01:31.967

Reputation: 9 384

Wow, thanks! I'll have to rethink the kernel, as my OS will have to run a bunch of different setups, but I'll definitely try ldd and BusyBox. Thanks! – Blender – 2010-12-09T18:46:47.390

It it needs to run on a bunch of setups you may want to build modules, but likely a limited set. In that case consider locking the module set during startup. – BillThor – 2010-12-10T05:25:34.720

2

debootstrap is the tool you want. http://www.debian-administration.org/articles/426 . It's much better to build up rather than strip down.

dan_waterworth

Posted 2010-12-09T16:01:31.967

Reputation: 120

Hmm, I'm building HLFS, so no Debian chroot jails for me! If I'm not mistaken, isn't this just a way to run a Debian install inside of a folder via chroot? – Blender – 2010-12-09T16:16:59.527

1

start from something like damn small Linux and build up from that. dsL image is at most 50 mb

bbaja42

Posted 2010-12-09T16:01:31.967

Reputation: 2 815

Thanks, but I've already got a working HLFS system. All I need to do is remove all of the unused binaries and libraries, as they take up a lot of space (which I am trying to save)... – Blender – 2010-12-09T16:32:23.813

0

For building your own Linux filesystem try Buildroot. There are a lot of tutorials on the Internet.

redbeam_

Posted 2010-12-09T16:01:31.967

Reputation: 532

-1

Why bother? Is it security you're worried about, or space/memory? I would recommend: if in doubt, don't spend the time on it.

Brian

Posted 2010-12-09T16:01:31.967

Reputation:

Note LFS is a learning tool. If you build everything as an individual, there's a chance of missing updates for system software bugs. LFS doesn't provide security support (the book points you to general sources like US CERT) or even use packages for clean updates (e.g. if files are removed)? ...ubuntu+apparmor isn't perfect but personally I've found tools around apt/dpkg quite useful for keeping a stripped-down system. 700MB doesn't sound wholly insane... I struggled to keep going on an EeePC 4GB.

– sourcejedi – 2015-05-26T19:56:31.987

Simplicity => Security. If I have no servers, no applications, nothing that can be targeted, I'm pretty safe. Also, I am keeping the security libraries, so don't worry. – Blender – 2010-12-09T16:14:00.140

As for space, it feels bloated; 700MB for just Chrome and XOrg? That is the size of Ubuntu's disk, and that has a ton more packages. – Blender – 2010-12-09T16:14:44.007

1That's likely compressed, though. – ceejayoz – 2010-12-09T16:17:23.430

A basic install of Ubuntu is ~ 1 GB, and I've seen Linux systems that are under 10 MB. It is compressed pretty well, though. – Blender – 2010-12-09T16:22:07.213