The basic reference is systemd - Gentoo Wiki. But the instructions are too general for a running Gentoo system. Since I already have a working Gentoo installation, I will skip the general instructions and only mention the necessary steps to make
systemd work on existing system.
Nevertheless, my system is roughly able to work since I switched from OpenRC to systemd. So the steps may be incompelete.
The wiki has the best description for this part. All kernel configurations are necessary.
make /usr present at boot time
I just ran into this part when I read the wiki again. The possible reason is that the
systemd executable resides in
/usr directory and needs various service configurations in
The first thing is changing the system profile using
sudo eselect profile <list|set>. For my system, the option is
Then we need to instruct the kernel to use the
systemd executable as the
init process with pid 1.
/etc/default/grub and modify the
GRUB_CMDLINE_LINUX parameter. Like
sudo grub2-mkconfig -o /boot/grub2/grub.cfg it is almost finished.
After I rebooted the system, the first thing I found is that my hostname became
localhost. Use command
hostnamectl to change it.
hostnamectl set-hostname <HOSTNAME>
I found that most systemd commands are in the format of "xxxctl". I think it's more convenient to remember.
Handling of log files
I'm still not sure how systemd's
journalctl works. Since I already have
syslog-ng running on the system, I will probably remain with the two tools until I find out that
journalctl is superior.
systemd use the command
systemctl to manage all services. So the original start-stop script for OpenRC or other init systems don't work any more.
All pre-installed services are available in
/usr/lib/systemd/ and one way to view them is simply list the directory and another is
sudo systemctl --all --full
This command will display a summary of all running(?) services managed by
systemd. If you need more detail of the service,
sudo systemctl show sshd.service
Other useful commands:
# start a service daemon sudo systemctl start sshd.service # stop a service daemon sudo systemctl stop sshd.service # status of a service sudo systemctl status sshd.service # add a service to default sudo systemctl enable sshd.service
When I rebooted Gentoo with systemd for the first time, network is not available. So the first thing to do is configure network service which is a good start point towards learning systemd.
First of all, one thing we need to know is that the network service is a built-in service shipped with
systemd installation so we only need to enable it and
systemctl will automatically make a soft link for us. Then all we need to configure is create a new file under
/etc/systemd/network/, for example(you will need commands like
ip addr to get the interface name of your NIC):
# This is /etc/systemd/network/enp2s0.network # For more detail of the configuration, use 'man systemd-networkd.service' [Match] Name=enp2s0 [Network] DHCP=yes
More detail please refer to systemd-networkd - ArchWiki.
Then enable the service and start it.
sudo systemctl enable systemd-networkd.service sudo systemctl start systemd-networkd.service