Visualizing the Rootfs
An important aspect in working on an embedded OS is keeping the size of our updates down which usually entails keeping the size of the OS image down. If left unchecked, the OS image will increase steadily. In order to help developers track down where space is going we created a tool cros_tree_map that helps developers figure out where our precious space is going.
In order to use, you need to have:
- an OS image (the .bin file).
- at least a mini-layout checkout of the code.
- mount the image onto a directory -- you can do this easily with
~/src/scripts). You should use the
--safeoption to ensure you do not make accidental changes to the Root FS. By default it will mount the rootfs onto
/tmp/m. You can use the
--from=<path to .bin file>
- Run du:
sudo du -xB 1 /tmp/m > du.out(
du.outis your output file).
- Use cros_tree_map to create a json report:
~/chromite/contrib/cros_tree_map du --du-output du.out --strip-prefix /tmp/m > image_size.json
At this point you will have a json file with all the directory information. To visualize this info, you can use webtree map here: https://github.com/martine/webtreemap. You can then view the html file from your trusty web browser.
Here's an example snapshot of a Chrome OS image (note: yours will be interactive so you can dig in to different areas).