Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I've been building a 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?

share|improve this question
3  
Indeed you are in THE correct place this time :) –  phunehehe Dec 10 '10 at 3:56
2  
Now, might I ask, why is there a separate Ubuntu-based Stack Exchange site? I think they should merge with this site, because AFAICT, Ubuntu should be considered Linux/Unix, but I'm not too sure ;) If not, get ready for GentooOverflow and FedoraOverflow! –  Blender Dec 10 '10 at 16:43
3  
@Blender: This merge was considered and rejected. Look in the two sites' Meta for the history. –  Gilles Dec 10 '10 at 18:35
3  
I've found the ubuntu site is a lot more about gnome programs and user interface stuff. Here your answer will almost certainly be a terminal command. –  Falmarri Dec 10 '10 at 23:59
2  
My understanding is that AskUbuntu is to Unix and Linux as Unix and Linux is to SuperUser: if it's an ubuntu-specific question, it goes to AU; if it's otherwise *n*x-ish, it goes here; otherwise it goes to SU or to ServerFault. –  intuited Jan 6 '11 at 5:04
show 2 more comments

5 Answers

up vote 11 down vote accepted

There are programs like Bootchart that can be used to show what programs you ran during startup - you can probably keep it going after boot to see what's been invoked during a session.

A better solution may be to use remastering tools.

There are remastering tools for Fedora, Ubuntu, and others; you can use these to customize a distribution.

You might want to look at Tiny Core Linux. There is a guy working on a remaster script for that as well.

share|improve this answer
    
When I get home, I will definitely try Bootchart. I lied, though, as the system just finished compiling last night, so I'll have to really get it running in the next few days. I found TinyX (which is what I was looking for, as I can't figure out what XOrg modules I really need), but the website was down... Oh well, but thank you very much! –  Blender Dec 10 '10 at 15:22
    
Bootchart it is! I compiled it, ran it, and it gave me extremely verbose and useful results. I'm not going to strip the system just yet, as I'm going to implement a source-based package manager (Gentoo?), but I will definitely use this. Thanks! –  Blender Dec 13 '10 at 15:29
add comment

Amongst other things... if you want to remove everything you don't need. Make sure the filesystem has atime fully enabled, you can set this in /etc/fstab the current defaults is relatime but you want to use just atime. Everytime a file is access the timestamp will get updated. Then do some usage for a few days, to see which files have never had their atime updated. I would do all of this in a vm, and very carefully. because I imagine there are a few files that are read when the system is in read-only mode. note: set it to noatime once you're ready for production, otherwise you'll do a write everytime you read, this is inefficient.

Though to be honest, I'd look at Damn Small Linux do you really need to be smaller than that? build based on their distro and simply remove the window manager and a few extra programs.... leave all the command line tools, that way if you ever need to repair or reload you have the shell.

share|improve this answer
    
Thanks! I'm trying to do it myself, as I've never really gotten a fully usable LFS system running, but I've played with DLS before. I'm actually trying to build a ChromeOS clone that is not made with SuSEStudio (the one from chromium.org is), and is a bit smaller than 600MB ;) My goal is > 50MB, as DSL includes a ton of other software, but I'm only installing OpenBox, Chrome, and a custom-built Thunar (and some other goodies, of course). Thanks! –  Blender Dec 10 '10 at 15:23
add comment

Actively use your system for a while with file access times enabled. See what files never have their access time modified. These are candidates for deletion (but make sure there isn't a reason to keep them, e.g. because they're hardware drivers for hardware you don't have, or they're needed early in the boot process when the root partition is still mounted read-only).

Since you'll have few big applications, check what libraries are used by a single executable. Consider linking them statically.

ldd /bin/* /usr/bin/* |sed -n 's/^.* => \(.*\) (.*)$/\1/p' |sort |uniq -c
share|improve this answer
add comment

Where exactly are you starting from? Are you stripping an existing distro? Is there a reason you have to start with any distro?

You might want to consider building an embedded system from scratch and load only what you know you need.

share|improve this answer
    
I'm building off of a LFS install + Xorg, Python, and Google Chrome. Nothing fancy. –  Blender Dec 11 '10 at 4:47
    
It used GCC, Python, etc. to build, but they are now obsolete for my purposes. –  Blender Dec 11 '10 at 4:47
add comment

assuming you are using Debian or it's derivatives

After some days of (heavy) usage, run popularity-contest. It will display the oldest unused packages at the bottom. Uninstall those, but with a watchful eye on whether or not there's stuff depending on them installed.

Here's a snippet of the output:

1294222606 1292570417 vlc /usr/lib/vlc/plugins/gui/libqt4_plugin.so
1294222606 1292570109 xulrunner-1.9.2 /usr/share/xulrunner-1.9.2/chrome/classic.jar
1294222606 1292507839 ttf-dejavu-extra /usr/share/fonts/truetype/ttf-dejavu/DejaVuSans-Oblique.ttf
1294222606 1292507459 x11-utils /usr/bin/xprop

The colums mean atime, ctime, package-name, and file accessed.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.