]> www.opopop.net Git - reminder/blob - Avoid_systemd_on_Debian_Jessie_with_Mate.mdwn
attachment upload
[reminder] / Avoid_systemd_on_Debian_Jessie_with_Mate.mdwn
1 # Debian Jessie with Mate and without systemd
2
3 ## Rationale
4
5 I am a Debian user and there are packages I don't like to be installed
6 on my computers.
7
8 The most visible one I skip is
9 [Gnome3](https://www.gnome.org/gnome-3/). I really tried to use it on
10 Wheezy. After a month of use, I expected a minimal "get it" moment
11 about that new system. Didn't happen. My workflow doesn't fit at all
12 with Gnome3, and it's a ressource hog on your computer. I am now a
13 [Mate](http://mate-desktop.org/) user.
14
15 I also remove routinely [Avahi](http://www.avahi.org/) (which only
16 merit seems to bring noise on your LAN) and
17 [PulseAudio](http://www.freedesktop.org/wiki/Software/PulseAudio/). This
18 last one is installed by default with Mate, but often gave me no sound
19 after a fresh install [^1]. When I replace it with Gstreamer, I get
20 sound automagically, and there is one less daemon filling my process
21 table.
22
23 [^1]: And yes, I did the obvious verifications: unmuting, chosing the
24 correct audio device...
25
26 On Jessie I tried also
27 [systemd](http://www.freedesktop.org/wiki/Software/systemd/) for a
28 while, read a bit of all the flamewars going on about it and here also
29 I decided it's not for me.
30
31 My arguments are the following:
32
33 1. The existing documentation about systemd is not usable to
34 understand how it works internally; and that is a precondition to be
35 able to debug problems confortably.
36 2. The claim at modularity from systemd proponents is
37 completely false: as all the various daemons and executables
38 comprising systemd share a huge common codebase, what you have in
39 reality is a monolitic system.
40
41 The above two facts are enough to stay away from systemd, whose main
42 programmer, surprise, was also the one involved in coding Avahi and
43 PulseAudio.
44
45 But my main grief about systemd is that it's actually less and less an
46 init system, so it may contaminate too much of your software in the
47 future. I would not object much to systemd if it was only a SysV init
48 replacement.
49
50 But Debian give it's users the choice to skip the init part of systemd
51 while keeping the problematic non-init part mandatory. 
52
53 So the topic of that article is to explain what you can do to limit
54 the use of systemd on your Jessie system, including the non-init
55 part. As I said above, I use Mate on Debian, so I will cover the use
56 of that desktop on that distribution.
57
58 ## Debian Jessie with Mate and systemd init
59
60 So, let's start with a fresh Jessie install. To avoid cluttering my
61 computers with packages I probably won't use, I chose to install only
62 the "standard system" from tasksel before the first reboot.
63
64 At that point, you will have systemd running, with the following
65 daemons:
66
67 * systemd (this is the process with PID 1)
68 * systemd-journal
69 * systemd-logind
70 * systemd-udevd (previously called "udevd")
71
72 For good measure, even it is only "recommended" by systemd, there is
73 also dbus-daemon running. We will need it anyway for a desktop GUI.
74
75 After the first reboot, I uncheck the "download recommended packages"
76 in [aptitude](https://wiki.debian.org/Aptitude) options, then proceed
77 to install Mate as a task [^2].
78
79 [^2]: And if Avahi-daemon is no more installed, the default for Mate
80 is still to use PulseAudio. You can get rid of the PulseAudio daemon
81 by replacing package *mate-settings-daemon-pulse* by package
82 *mate-settings-daemon-gstream*, then suppressing package *pulseaudio*.
83
84 The installed systemd related packages are then the following:
85
86 | Package          |  Installed size |  Number of files     | Mandatory dependencies | Remark |
87 | :-----------     | :-----------:   | :------------------: | :---: | -----: | 
88 | *systemd*        |     12MB        | 700                  |  20   |        |
89 | *libpam-systemd* |    300KB        | 15                   |  10   | Was installed by Mate |
90 | *systemd-sysv*   |     50KB        | 25                   |  10   |        |
91 | *libsystemd0*    |    200KB        | 10                   |  70   |        |
92 | *udev*           |      6MB        | 120                  |  85   |        |
93 | *libudev1*       |    100KB        | 10                   |  90   |        |
94
95 The mandatory dependencies figure is especially important for
96 *libsystemd0*, *libudev1* and *udev*. *libsystemd0* is mostly used to
97 ensure systemd is present, and the additional functionality offered in
98 that case is (for now...) limited. 
99
100 We have been living with *udev* since a long time and it is needed by 
101 *initramfs-tools* and several desktop packages, so it is difficult to 
102 get rid of it. The fact that *udev* development was taken over by 
103 systemd is the real trouble here; but more about that in the conclusion.
104
105 ## Debian Jessie with Mate and SysV init
106
107 Now let's try to replace systemd init by SysV init; this is done by
108 replacing *systemd-sysv* with package *sysvinit-core*. At reboot, from the
109 4 systemd related daemons present initially, there is only
110 systemd-logind left, and process with PID 1 is now the traditional
111 init.
112
113 But the 5 other packages related to systemd are still there! So you
114 can still execute commands like "journalctl" or "systemctl", just
115 these are now mostly empty operations. Only "systemd-cgls" and
116 "systemd-cgtop" still provide useful information.
117
118 So systemd is still sitting on your system, waiting for an upgrade to
119 pull in again *systemd-sysv* and recover its full functionality. At
120 this point, you can put *sysvinit-core* on hold in aptitude.
121
122 In addition, new packages *systemd-shim*, *cgmanager* (it launches a
123 daemon) and some dependencies have been installed on your system.
124
125 The following figure shows the dependencies between some packages in
126 our new configuration.
127
128 [[!img dep-systemd.png size=600x]]
129
130 ## Debian Jessie with Mate, SysV init and *consolekit*
131
132 *mate-power-manager* may not be installed on your host (it's mostly a laptop thing). 
133 In that case, you can skip that section.
134
135 Exploring the packages dependencies in
136 [aptitude](https://wiki.debian.org/Aptitude) gives you the following
137 alternative set of packages dependencies:
138
139 [[!img dep-consolekit.png size=600x]]
140
141 where package *consolekit* replaces *systemd* at several
142 places. Notice that it is not possible to change/suppress the
143 dependency of *udisks2* and *policykit-1*.
144
145 So let's go to change to the above figure by installing *consolekit* [^3],
146 as a first step to limit your systemd exposure.
147
148 [^3]: In the process of installing *consolekit*, you may have lost (or
149 not) the ability to resume/suspend from your Mate desktop; the
150 conditions under which it happens are not clear for me at the
151 moment. But continuing until the end what I suggest in this article
152 will recover eventually that functionality.
153
154 ## Debian Jessie with Mate, SysV init and a modified *libpam-systemd*
155
156 As *libpam-systemd* is the only package left depending on *systemd*,
157 the idea is here to modify *libpam-systemd* to get rid of it.
158
159 To do that, I took the Debian systemd source, which I modified to
160 build a new package *libpam-systemd*. The main steps were the
161 following:
162
163 1. In debian/control file, I only allow building of *libpam-systemd*,
164    and added that it breaks and replaces *systemd*
165 2. I deleted all source files not needed in the compilation of
166    the PAM module and the daemon "systemd-logind"
167 3. Some other tidying up was done (debian/rules, documentation...)
168
169 This results in a smaller source package (but not so much, which
170 contradicts the claim to systemd "modularity"). 
171
172 For your convenience, all of the source files and the .deb package
173 (for i386) are here:
174
175 [[systemd_215-17+deb8u7bu1.dsc]]
176
177 [[systemd_215-17+deb8u7bu1.tar.gz]]
178
179 [[systemd_215-17+deb8u7bu1_i386.changes]]
180
181 [[libpam-systemd_215-17+deb8u7bu1_i386.deb]]
182
183 If you have installed the needed development packages, it's easy to
184 rebuild file "libpam-systemd_215-17+deb8u7bu1_i386.deb" with these
185 simple commands:
186
187     # the 2 source files have to be downloaded in your current working directory
188     dpkg-source -x systemd_215-17+deb8u7bu1.dsc
189     cd systemd-215
190     dpkg-buildpackage -rfakeroot
191     cd ..
192
193 To install it, you will need some local package repository. An easy
194 method to do it is to run:
195
196     mkdir -p ~/my-repo/dists/jessie/main/binary-i386
197     mv libpam-systemd_215-17+deb8u7bu1_i386.deb ~/my-repo/
198     (cd ~/my-repo; dpkg-scanpackages . /dev/null | gzip > dists/jessie/main/binary-i386/Packages.gz)
199
200 Notice that "dpkg-scanpackages" is available through package
201 *dpkg-dev*.
202
203 Then add line (if you are user "joe"):
204
205     deb file:/home/joe/my-repo/ jessie main 
206
207 to /etc/apt/sources.list and update the available packages in aptitude
208 to take the content of your local repository into account.
209
210 You can then try to upgrade to the new *libpam-systemd*
211 with aptitude. You will get a conflict. Choose to solve it by
212 suppressing *systemd*, proceed with the upgrade and you are done!
213
214 Some people may ask why I haven't changed the name of the new package
215 replacing *libpam-systemd* and suppressed in it any reference to
216 systemd. First, its source code is still pure systemd at that
217 point. And secondly: not having string "systemd" in your computer will
218 not make that software vanish from the universe, like not saying
219 "Voldemort" doesn't make that guy disappear as by magic.
220
221 ## Final remarks
222
223 Installing the modified package *libpam-systemd* proposed above will
224 allow you to get rid of package *systemd*, while keeping your Mate
225 desktop fully functional.
226
227 On your computer there will be only packages *libpam-systemd*,
228 *libsystemd0* and *udev*.
229
230 As said above, there is (for now...) no more harm to continue using
231 packages dependent on *libsystemd0*, as there is to use packages
232 dependent on *libpulse0* (to access PulseAudio) or *libavahi-client3*
233 (to use Avahi), even if you don't have PulseAudio or Avahi daemons
234 running.
235
236 *udev* is a bit more annoying as its functionality has been used for a
237 long time, so it has penetrated deep in our Debian systems. Someone is
238 working on an independent replacement for *udev* called
239 [*vdev*](https://github.com/jcnelson/vdev). The work seems promising,
240 and I will at one point experience his work.
241
242 For a more organized solution to avoid systemd in Debian, you can also 
243 look at the [Devuan distribution](https://devuan.org/), a fork of Debian; 
244 *vdev* is here also a candidate for *udev* replacement.
245
246 Meanwhile, the last Devuan release has shipped with [*eudev*](https://wiki.gentoo.org/wiki/Eudev), 
247 a *udev* fork pushed mainly by Gentoo.