disk-space.rst 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. .. SPDX-License-Identifier: CC-BY-SA-2.0-UK
  2. Conserving Disk Space
  3. *********************
  4. Conserving Disk Space During Builds
  5. ===================================
  6. To help conserve disk space during builds, you can add the following
  7. statement to your project's ``local.conf`` configuration file found in
  8. the :term:`Build Directory`::
  9. INHERIT += "rm_work"
  10. Adding this statement deletes the work directory used for
  11. building a recipe once the recipe is built. For more information on
  12. "rm_work", see the :ref:`ref-classes-rm-work` class in the
  13. Yocto Project Reference Manual.
  14. When you inherit this class and build a ``core-image-sato`` image for a
  15. ``qemux86-64`` machine from an Ubuntu 22.04 x86-64 system, you end up with a
  16. final disk usage of 22 Gbytes instead of &MIN_DISK_SPACE; Gbytes. However,
  17. &MIN_DISK_SPACE_RM_WORK; Gbytes of initial free disk space are still needed to
  18. create temporary files before they can be deleted.
  19. Purging Obsolete Shared State Cache Files
  20. =========================================
  21. After multiple build iterations, the Shared State (sstate) cache can contain
  22. multiple cache files for a given package, consuming a substantial amount of
  23. disk space. However, only the most recent ones are likely to be reused.
  24. The following command is a quick way to purge all the cache files which
  25. haven't been used for a least a specified number of days::
  26. find build/sstate-cache -type f -mtime +$DAYS -delete
  27. The above command relies on the fact that BitBake touches the sstate cache
  28. files as it accesses them, when it has write access to the cache.
  29. You could use ``-atime`` instead of ``-mtime`` if the partition isn't mounted
  30. with the ``noatime`` option for a read only cache.
  31. For more advanced needs, OpenEmbedded-Core also offers a more elaborate
  32. command. It has the ability to purge all but the newest cache files on each
  33. architecture, and also to remove files that it considers unreachable by
  34. exploring a set of build configurations. However, this command
  35. requires a full build environment to be available and doesn't work well
  36. covering multiple releases. It won't work either on limited environments
  37. such as BSD based NAS::
  38. sstate-cache-management.py --remove-duplicated --cache-dir=sstate-cache
  39. This command will ask you to confirm the deletions it identifies.
  40. Run ``sstate-cache-management.sh`` for more details about this script.
  41. .. note::
  42. As this command is much more cautious and selective, removing only cache files,
  43. it will execute much slower than the simple ``find`` command described above.
  44. Therefore, it may not be your best option to trim huge cache directories.