Badri
Badri

Reputation: 2213

Optimizing an embedded linux system's root file system size

I am working on an embedded system which runs on linux. To reduce the boot time of the product (It is an IP net camera) I would like to reduce the root filesystem size. I already have a functional root filesystem and am currently manually removing portions and seeing if the root file system will mount. Is there a more logical approach to reducing file system size rather than the current trial and error method Updated with additional details: The original filesystem used on the target is a generic filesystem used across multiple embedded products in our organization. I want to strip down the filesystem to the bare minimum required to run my specific product .i.e IPNetCam. I want to know if there are any profiling methods hat can determine the exact set of files required to boot and run a particular application.

Upvotes: 2

Views: 2035

Answers (2)

jlliagre
jlliagre

Reputation: 30853

One way to list the files used by your OS and its application would be to:

  • turn on the atime flag on your file system (if not yet set)
  • reboot
  • after your application has run long enough, use atime to find out what files have been accessed after the last boot:

# last reboot | head -1
reboot   system boot  2.6.35-30-generi Sun May 20 10:08 - 10:48  (00:40)
# touch -d "2012-05-20 10:07" /tmp/ref
# find / -xdev -anewer /tmp/ref > /tmp/usedFiles

Of course, this method is ignoring files not accessed in your sample run but still necessary in infrequent or exceptional situations. You will also need to add files directly read by the boot loader or the OS in early stages when the file system is accessed in read-only mode.

Upvotes: 1

Mats Ekberg
Mats Ekberg

Reputation: 1675

If you are not already doing so, you should use a compressed file system such as SquashFS. That will drastically reduce the footprint of your boot image.

Upvotes: 3

Related Questions