In modern Debian systems (including Squeeze and later), systemd manages service startup. To inspect the boot sequence, we'll primarily use systemd-analyze
and related tools.
systemctl list-unit-files --state=enabled
This command shows all enabled services that start at boot. For more detailed information including dependencies:
systemd-analyze dot | dot -Tsvg > boot_sequence.svg
Note: You'll need Graphviz installed for the dot
command.
To see the exact boot sequence with timing information:
systemd-analyze critical-chain
For a specific service:
systemd-analyze critical-chain apache2.service
For systems still using SysVinit, check the traditional boot sequence:
ls -l /etc/rc*.d/
To see the exact order for a specific runlevel (e.g., 2):
ls -l /etc/rc2.d/
When debugging why service A starts before service B:
systemd-analyze verify A.service B.service
systemd-analyze dump | grep -A 10 "Unit A.service"
systemd-analyze plot > boot_plot.svg
To modify the startup sequence, create or edit service dependencies:
[Unit]
Description=My Custom Service
After=network.target
Requires=postgresql.service
For graphical analysis:
sudo apt install bootchart
bootchart
This provides a visual timeline of all processes during boot.
Modern Debian systems (since Jessie) use systemd, while older releases like Squeeze use SysV init. Let's cover both approaches.
# List all enabled services with their dependencies
systemd-analyze dot | dot -Tsvg > boot_sequence.svg
# View boot performance metrics
systemd-analyze critical-chain
# List all units and their activation time
systemd-analyze plot > boot_timeline.svg
Check the traditional init.d scripts:
# View boot order in /etc/rc*
ls -l /etc/rc*.d/
# Alternative method using readlink
find /etc/rc*.d/ -name "S*" -exec readlink -f {} \; | sort
# For detailed execution order
cat /var/log/boot.log
For deeper inspection in Squeeze:
# Install bootchart if not present
apt-get install bootchart
# After reboot, analyze the chart
bootchart /var/log/bootchart.tgz
# Alternative using sysv-rc-conf
sysv-rc-conf --list
Suppose you need to verify Apache starts after networking:
# In systemd:
systemctl list-dependencies apache2.service
# In SysV init:
grep -r "Required-Start" /etc/init.d/apache2
For automated reporting:
#!/bin/bash
# Generate boot service report
{
echo "=== Boot Services Report ==="
date
echo -e "\nEnabled Services:"
if which systemctl >/dev/null; then
systemctl list-unit-files --state=enabled | grep service
else
find /etc/rc*.d/ -name "S*" | sort
fi
} > boot_services_report.txt