My Linux computer was very slow to start up. It took approximately 4 minutes to get to the login prompt.
Before performing any of the steps below, take a backup of the data on the computer. Also, you follow the steps below at your own risk. No one is responsible for whatever you do with your system.
Below are the steps to fix the problem:
1. Find out which services or processes take a long time at boot.
2. Disable unwanted services.
3. Reduce the journal size if systemd-journal-flush.service is takes long to startup.
4. Remove any unwanted service packages, if needed.
Firstly, find out which processes or services take the longest time in milliseconds to start. To analyze what is the duration of start up services on a Linux computer, open a terminal window and enter below command:
$ sudo systemd-analyze blame <enter>
The output is similar to this:
Secondly, some steps can be taken to reduce the start up time by disabling unwanted services. In a terminal window and enter the following commands:
$ sudo systemctl disable ureadahead <enter>
$ sudo systemctl disable ModemManager <enter>
$ sudo systemctl disable plymouth <enter>
$ sudo systemctl disable systemd.networkd.service <enter>
Thirdly, to reduce the journal startup time and reduce journal size, in the terminal window, do the following steps:
Check if the journal is enabled:
$ sudo journalctl -b --unit systemd-journald <enter>
Next to optimize the journal, do the following:
$ sudo journalctl --vacuum-size=1G --vacuum-time=5d --vacuum-files=5 <enter>
The below content is displayed:
— Logs begin at Sat 2019-11-16 10:00:35 IST, end at Mon 2019-11-18 21:48:28 IST
Nov 18 19:31:07 rm01 systemd-journald: Journal started
Nov 18 19:31:07 rm01 systemd-journald: Runtime journal (/run/log/journal/82
Nov 18 19:31:08 rm01 systemd-journald: Time spent on flushing to /var is 99
Nov 18 19:31:08 rm01 systemd-journald: System journal (/var/log/journal/829
Check the size of the journal now:
sudo journalctl --disk-usage <enter>
The below message is displayed.
Archived and active journals take up 48.0M in the file system.
Right now it shows that the journal size has been reduced to 48.0M after optimization.
Fourthly, if needed, remove the unwanted service packages.
$ sudo apt-get remove networkd-dispatcher <enter>
$ sudo systemctl disable systemd-networkd.service <enter>
Restart the computer.