Fenrir ID:
systemd
Branch:systemd
Points:45
|
Important
|
Be careful when experimenting with systemd! Use fenrir env to enter a sandbox: it does not protect against all the potential errors, however, it effectively reduces the risk of making them.
|
Put all the systemd unit files in the systemd directory:
[folder] ...
├─ [folder] systemd
│ ├─ [file text] ...
│ ├─ [file text] teardown.sh
│ └─ [file text] setup.sh
└─ [folder] .gitAdd a setup.sh script which installs and activates your systemd units.
Add a teardown.sh script which removes and deactivates your systemd units.
Both scripts will be executed under sudo. The username is fikus.
If you see an error sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set when starting the env, add these lines to the file ~/.fenrir/repo/systemd/env.up:
docker exec -u root "$(fenrir-main-cont)" chown root:root /usr/bin/sudo
docker exec -u root "$(fenrir-main-cont)" chmod 4755 /usr/bin/sudoSince we create a sub-systemd, that service takes control under your current session. Restarting the computer fixes all the problems.
However, when starting the fenrir env your desktop environment may start to malfunction. People often see the login screen as if they have logged out. Do not enter the GUI again, instead, switch to another tty (e.g. kbd:[Ctrl+Alt+F5]). You should see a black screen with something like this:
Ubuntu 26.04.1 LTS ... tty5
8629ae81c29d login:Log in as the fikus user: use breach password. Run export FENRIR_IN_ENV=1 and try running fenrir i. Use must see a red note: You are inside env now!.
|
Note
|
We suggest rebooting the computer after you finish the task. |
WSL allows you to access the Windows filesystem from a Linux OS. This task focuses on reimplementing that feature by using systemd. We’ll use Ubuntu as the host system.
NTFS is a low-level (like ext4 or btrfs in Linux) filesystem which is used in Windows. On a real computer with Windows you might have a separate device (e.g. /dev/nvme0n1p3) which corresponds to the NTFS fs. We are to use /dev/loop67 to mock that ntfs partition. Your task is to set up systemd the way that /dev/loop67 is automatically mounted at the /mnt/c.
For a long time Ubuntu has avoided mounting tmpfs on /tmp. To fix that you had to either set up the /etc/fstab or systemd. We are to choose the second option. Set up systemd to automatically mount tmpfs on /temp.
|
Caution
|
We use /temp instead of /tmp!!!
|
Remember to add nodev and nosuid options. The size of /temp must be 2MB.
Docker is a client-server application which uses the /var/run/docker.sock file to connect. Both the server and the socket are usually managed by systemd. You are to reimplement this mechanism. We’ll use name reckod instead of docker. A system-wide group reckod is already created.
If you have Linux with systemd and docker is installed use systemctl to find the unit file which manages the docker.sock file.
Hint for macOS
See that
Create a similar unit file for the /var/run/reckod.sock file.
To start the server use /usr/bin/server. Create systemd unit which automatically starts the server. Make sure that the program’s logs are accessible through journalctl.
To test the server you can use /usr/bin/client. Try invoking the client 10 times: what happens? Use journalctl to investigate the problem.
-
How to see all mounts within a system? how much free space they have?
-
Which mode should
/tmphave? Why? -
What is the
nodevmount option? -
How to inspect journald logs?
-
What is the difference between
systemctl enableandsystemctl start? -
How to print a loaded systemd unit file?
-
What is
systemctl daemon-reload? -
What is the difference between
newgrpandusermod -a -G?
The project is licensed under the terms of the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
© 2026-present Iwan Kalinin <koefic.cien@gmail.com>