Devconf.US

Ed Chong


Session

08-15
15:20
35min
Accelerating Linux Boot Time: Techniques and Strategies for Optimal Performance
Eric Curtin, Ed Chong, Brian Masney

In this session, we will explore a variety of strategies and techniques
to optimize boot time, from measuring boot performance to specific
optimizations within systemd, kernel, and filesystem configurations.
We'll cover everything from the basics to advanced methods, ensuring
that by the end, you have a comprehensive understanding of how to
achieve faster boot times on your Linux systems.

1. Measuring Boot Performance

Before diving into optimizations, it's crucial to measure and
understand your current boot performance. This helps in identifying
bottlenecks and evaluating the impact of changes.

  • Tools:
  • systemd-analyze - Provides a detailed breakdown of the boot process.

  • Steps:

  • Use systemd-analyze time to get a high-level overview of the boot time.
  • systemd-analyze blame shows the time taken by each service.
  • systemd-analyze plot > boot.svg generates a graphical representation.

2. Optimizations in systemd

Systemd, being the init system and service manager, plays a
significant role in boot time. Optimizing systemd can lead to
substantial improvements.

  • Parallelization:
  • Enable parallel execution of units where possible using
    DefaultDependencies=no in unit files.

  • Service Optimization:

  • Disable unnecessary services with systemctl disable.
  • Use systemd-analyze critical-chain to identify and minimize the
    impact of critical services.
  • Implement on-demand services using socket activation.

3. Kernel and Initramfs Optimizations

Optimizing the components that are loaded during the early boot phase
can significantly reduce boot time.

  • Building Components:
  • Directly in the Kernel: Compiling essential components
    directly into the kernel (using make menuconfig) avoids the overhead
    of loading modules during boot.
  • As Modules in the initramfs: Use dracut to include only the
    necessary modules in the initramfs, reducing its size and load time.
  • Modules in the Rootfs: Delay the loading of non-critical
    modules until after the root filesystem is mounted to expedite early
    boot stages.

4. Expedited Read-Copy Update (RCU) Mechanisms

  • RCU Boosting:
  • Enable RCU boosting to prioritize RCU callback threads, reducing
    the time spent in the quiescent state.

5. Efficient Read-Only File System (erofs)

  • Advantages of erofs:
  • EROFS (Enhanced Read-Only File System) offers faster access times
    due to its optimized compression and reduced metadata overhead.

  • Implementation:

  • Convert static parts of your root filesystem to use EROFS,
    improving read performance during boot.

6. Initramfs Minimization

  • Size Reduction:
  • Minimize the initramfs size by stripping out unnecessary modules
    and files, using tools like dracut with the --omit and --add
    options.

Conclusion

Optimizing boot time requires a multi-faceted approach, involving
careful measurement, fine-tuning of systemd, strategic kernel and
initramfs configurations, and leveraging advanced filesystem
technologies. By systematically applying these techniques, you can
achieve a significant reduction in boot times, enhancing the overall
performance and responsiveness of your Linux systems.

Edge, Mobile, and Automotive
Metcalf Small Ballroom (capacity 100)