]> www.opopop.net Git - reminder/blob - Avoid_systemd_on_Debian_Jessie_with_Mate.mdwn
(no commit message)
[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. The lack of functionality is
99 probably higher if *libudev1* is present but not *udev*, as we have
100 been living with *udev* since a long time.
101
102 So *udev* development taken over by systemd is the real trouble here;
103 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. *mate-power-manager* may not be an installed
127 package on a desktop machine.
128
129 [[!img dep-systemd.png size=600x]]
130
131 ## Debian Jessie with Mate, SysV init and *consolekit*
132
133 Exploring the packages dependencies in
134 [aptitude](https://wiki.debian.org/Aptitude) gives you the following
135 alternative set of packages dependencies:
136
137 [[!img dep-consolekit.png size=600x]]
138
139 where package *consolekit* replaces *systemd* at several
140 places. Notice that it is not possible to change/suppress the
141 dependency of *udisks2* and *policykit-1*.
142
143 So let's go to change to the above figure by installing *consolekit* [^3],
144 as a first step to limit your systemd exposure.
145
146 [^3]: In the process of installing *consolekit*, you may have lost (or
147 not) the ability to resume/suspend from your Mate desktop; the
148 conditions under which it happens are not clear for me at the
149 moment. But continuing until the end what I suggest in this article
150 will recover eventually that functionality.
151
152 ## Debian Jessie with Mate, SysV init and a modified *libpam-systemd*
153
154 As *libpam-systemd* is the only package left depending on *systemd*,
155 the idea is here to modify *libpam-systemd* to:
156
157 1. Restore resume/suspend functionality if it's lost
158 2. Make the new package depend no more on package *systemd*, so you
159    can get rid of it
160
161 To do that, I took the Debian systemd source, which I modified to
162 build a new package *libpam-systemd*. The main steps were the
163 following:
164
165 1. In debian/control file, I only allow building of *libpam-systemd*,
166    and added that it breaks and replaces *systemd*
167 2. I deleted all source files not needed in the compilation of
168    the PAM module and the daemon "systemd-logind"
169 3. Some other tidying up was done (debian/rules, documentation...)
170
171 This results in a smaller source package (but not so much, which
172 contradicts the claim to systemd "modularity"). 
173
174 For your convenience, all of the source files and the .deb package
175 (for i386) are here:
176
177  [[systemd_215-17+deb8u2bu1.dsc]]
178
179 [[systemd_215-17+deb8u2bu1_i386.changes]]
180
181 [[systemd_215-17+deb8u2bu1.tar.gz]]
182
183 [[libpam-systemd_215-17+deb8u2bu1_i386.deb]]
184
185 If you have installed the needed development packages, it's easy to
186 rebuild file "libpam-systemd_215-17+deb8u2bu1_i386.deb" with these
187 simple commands:
188
189     # the 3 source files have to be downloaded in your current working directory
190     dpkg-source -x systemd_215-17+deb8u2bu1.dsc
191     cd systemd-215
192     dpkg-buildpackage -rfakeroot
193     cd ..
194
195 To install it, you will need some local package repository. An easy
196 method to do it is to run:
197
198     mkdir -p ~/my-repo/dists/jessie/main/binary-i386
199     mv libpam-systemd_215-17+deb8u2bu1_i386.deb ~/my-repo/
200     dpkg-scanpackages ~/my-repo /dev/null | gzip > ~/my-repo/dists/jessie/main/binary-i386/Packages.gz
201
202 Notice that "dpkg-scanpackages" is available through package
203 *dpkg-dev*.
204
205 Then add line (if you are user "joe"):
206
207     deb file:/home/joe/my-repo/ jessie main 
208
209 to /etc/apt/sources.list and update the available packages in aptitude
210 to take the content of your local repository into account.
211
212 You can then try to upgrade to the new *libpam-systemd*
213 with aptitude. You will get a conflict. Choose to solve it by
214 suppressing *systemd*, proceed with the upgrade and you are done!
215
216 Some people may ask why I haven't changed the name of the new package
217 replacing *libpam-systemd* and suppressed in it any reference to
218 systemd. First, its source code is still pure systemd at that
219 point. And secondly: not having string "systemd" in your computer will
220 not make that software vanish from the universe, like not saying
221 "Voldemort" doesn't make that guy disappear as by magic.
222
223 ## Final remarks
224
225 Installing the modified package *libpam-systemd* proposed above will
226 alow you to get rid of package *systemd*, while keeping your Mate
227 desktop fully functional.
228
229 On your computer there will be only packages *libpam-systemd*,
230 *libsystemd0* and *udev*.
231
232 As said above, there is (for now...) no more harm to continue using
233 packages dependent on *libsystemd0*, as there is to use packages
234 dependent on *libpulse0* (to access PulseAudio) or *libavahi-client3*
235 (to use Avahi), even if you don't have PulseAudio or Avahi daemons
236 running.
237
238 *udev* is a bit more annoying as its functionality has been used for a
239 long time, so it has penetrated deep in our Debian systems. Someone is
240 working on an independent replacement for *udev* called
241 [*vdev*](https://github.com/jcnelson/vdev). The work seems promising,
242 and I will at one point experience his work.