2024-08-15 –, Metcalf Small Ballroom (capacity 100)
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 (usingmake 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 likedracut
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.
Software Engineer working on open-source things
Brian Masney has been a contributor and user of Linux and open source projects since 1996. He has 25 years of commercial experience, and has worked professionally on large distributed backend systems in userspace, automated large infrastructure in the cloud and data center, and is a contributor to the upstream Linux kernel. Brian currently works as a Principle Software Engineer at Red Hat on their kernel team.