CLUG 2010 09 - systemd - the new init system

1,398 views
1,282 views

Published on

A simple presentation on systemd, the new init system written by Lennart Poettering. This was a fairly basic talk and was aimed at general users.

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,398
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
61
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

CLUG 2010 09 - systemd - the new init system

  1. 1. systemd
  2. 2. systemd <ul><li>A new init system for Linux </li></ul>
  3. 3. systemd <ul><li>A new init system for Linux </li><ul><li>Makes booting faster </li></ul></ul>
  4. 4. systemd <ul><li>A new init system for Linux </li><ul><li>Makes booting faster
  5. 5. How? </li></ul></ul>
  6. 6. systemd <ul><li>How does init work anyway? </li></ul>
  7. 7. System V init <ul><li>The init process is started by the kernel </li></ul>
  8. 8. System V init <ul><li>The init process is started by the kernel
  9. 9. It reads /etc/inittab to find the default run level (initdefault) [root@tachyon ~]# grep initdefault /etc/inittab id:5:initdefault: </li></ul>
  10. 10. System V init <ul><li>The init process is started by the kernel
  11. 11. It reads /etc/inittab to find the default run level (initdefault)
  12. 12. It then reads the files starting with S in /etc/rc.d/rc${initdefault}.d [root@tachyon ~]# ls -1 /etc/rc.d/rc5.d/S* /etc/rc.d/rc5.d/S02lvm2-monitor /etc/rc.d/rc5.d/S08ip6tables /etc/rc.d/rc5.d/S08iptables /etc/rc.d/rc5.d/S11auditd /etc/rc.d/rc5.d/S11portreserve ... </li></ul>
  13. 13. System V init <ul><li>The init process is started by the kernel
  14. 14. It reads /etc/inittab to find the default run level (initdefault)
  15. 15. It then reads the files starting with S in /etc/rc.d/rc${initdefault}.d
  16. 16. It executes each one in order, one at a time. </li></ul>
  17. 17. systemd <ul><li>A new init system for Linux </li><ul><li>Makes booting faster
  18. 18. Do it in parallel? </li></ul></ul>
  19. 19. systemd <ul><li>A new init system for Linux </li><ul><li>Makes booting faster
  20. 20. Do it in parallel? </li><ul><li>Dependencies! </li></ul></ul></ul>
  21. 21. upstart <ul><li>A new init system for Linux </li></ul>
  22. 22. upstart <ul><li>A new init system for Linux </li><ul><li>Makes booting faster by encoding dependencies between modules </li></ul></ul>
  23. 23. upstart <ul><li>A new init system for Linux </li><ul><li>Makes booting faster by encoding dependencies between modules
  24. 24. upstart then resolves these dependencies and starts up as many things as it can in parallel </li></ul></ul>
  25. 25. upstart <ul><li>Then everyone gets kittens! </li></ul>
  26. 26. upstart <ul><li>A new init system for Linux </li><ul><li>Makes booting faster by encoding dependencies between modules
  27. 27. upstart then resolves these dependencies and starts up as many things as it can in parallel </li></ul><li>Only problem is... </li></ul>
  28. 28. upstart <ul><li>A new init system for Linux </li><ul><li>Makes booting faster by encoding dependencies between modules
  29. 29. upstart then resolves these dependencies and starts up as many things as it can in parallel </li></ul><li>Only problem is... </li><ul><li>Encoding the dependencies. </li></ul></ul>
  30. 30. upstart <ul><li>A new init system for Linux </li><ul><li>Makes booting faster by encoding dependencies between modules
  31. 31. upstart then resolves these dependencies and starts up as many things as it can in parallel </li></ul><li>Only problem is... </li><ul><li>Domain-specific language required... </li></ul></ul>
  32. 32. upstart <ul><li>A new init system for Linux </li><ul><li>Makes booting faster by encoding dependencies between modules
  33. 33. upstart then resolves these dependencies and starts up as many things as it can in parallel </li></ul><li>Only problem is... </li><ul><li>We're still starting too much... </li></ul></ul>
  34. 34. Booting a system <ul><li>What actually needs to get started? </li></ul>
  35. 35. Booting a system <ul><li>What actually needs to get started? </li><ul><li>System V init: </li><ul><li>Try to think of everything and boot it in what we hope is the right order... </li></ul></ul></ul>
  36. 36. Booting a system <ul><li>What actually needs to get started? </li><ul><li>System V init: </li><ul><li>Try to think of everything and boot it in what we hope is the right order... </li></ul><li>upstart: </li><ul><li>Try to think of everything, resolve dependencies and hope that works... </li></ul></ul></ul>
  37. 37. Booting a system <ul><li>How do we know what needs to get started? </li></ul>
  38. 38. Booting a system <ul><li>How do we know what needs to get started? </li><ul><li>We wait for something to use it! </li></ul></ul>
  39. 39. Booting a system <ul><li>How do we know what needs to get started? </li><ul><li>We wait for something to use it!
  40. 40. Then we catch the request and start the daemon. </li></ul></ul>
  41. 41. Booting a system <ul><li>How do we know what needs to get started? </li><ul><li>We wait for something to use it!
  42. 42. Then we catch the request and start the daemon. </li></ul><li>Is there something that already works like this? </li></ul>
  43. 43. Booting a system <ul><li>How do we know what needs to get started? </li><ul><li>We wait for something to use it!
  44. 44. Then we catch the request and start the daemon. </li></ul><li>Is there something that already works like this? </li><ul><li>Yes: </li></ul></ul>
  45. 45. Booting a system <ul><li>How do we know what needs to get started? </li><ul><li>We wait for something to use it!
  46. 46. Then we catch the request and start the daemon. </li></ul><li>Is there something that already works like this? </li><ul><li>Yes: xinetd </li></ul></ul>
  47. 47. xinetd <ul><li>List of sockets </li></ul>
  48. 48. xinetd <ul><li>List of sockets
  49. 49. When a connection is made, start the related daemon </li></ul>
  50. 50. xinetd <ul><li>List of sockets
  51. 51. When a connection is made, start the related daemon </li><ul><li>Per-socket startup – e.g. rsync, nrpe </li></ul></ul>
  52. 52. xinetd <ul><li>List of sockets
  53. 53. When a connection is made, start the related daemon </li><ul><li>Per-socket startup – e.g. rsync, nrpe
  54. 54. Hand socket to daemon – 'wait' option </li></ul></ul>
  55. 55. Sockets in startup <ul><li>Lots of services use sockets </li></ul>
  56. 56. Sockets in startup <ul><li>Lots of services use sockets </li><ul><li>/var/run/cups/cups.sock </li></ul></ul>
  57. 57. Sockets in startup <ul><li>Lots of services use sockets </li><ul><li>/var/run/cups/cups.sock
  58. 58. /var/run/dbus/system_bus_socket </li></ul></ul>
  59. 59. Sockets in startup <ul><li>Lots of services use sockets </li><ul><li>/var/run/cups/cups.sock
  60. 60. /var/run/dbus/system_bus_socket
  61. 61. /var/run/rpcbind.sock </li></ul></ul>
  62. 62. Sockets in startup <ul><li>Lots of services use sockets </li><ul><li>/var/run/cups/cups.sock
  63. 63. /var/run/dbus/system_bus_socket
  64. 64. /var/run/rpcbind.sock
  65. 65. /dev/log </li></ul></ul>
  66. 66. systemd - sockets <ul><li>Work out what sockets we need to set up </li></ul>
  67. 67. systemd - sockets <ul><li>Work out what sockets we need to set up
  68. 68. Set them all up in parallel </li></ul>
  69. 69. systemd - sockets <ul><li>Work out what sockets we need to set up
  70. 70. Set them all up in parallel
  71. 71. When the socket is opened, start up its related daemon </li></ul>
  72. 72. systemd - sockets <ul><li>Work out what sockets we need to set up
  73. 73. Set them all up in parallel
  74. 74. When the socket is opened, start up its related daemon and hand the socket to it </li></ul>
  75. 75. systemd - sockets <ul><li>Work out what sockets we need to set up
  76. 76. Set them all up in parallel
  77. 77. When the socket is opened, start up its related daemon and hand the socket to it </li><ul><li>Only that application gets paused </li></ul></ul>
  78. 78. systemd - sockets <ul><li>Work out what sockets we need to set up
  79. 79. Set them all up in parallel
  80. 80. When the socket is opened, start up its related daemon and hand the socket to it </li><ul><li>Only that application gets paused
  81. 81. Only for that request </li></ul></ul>
  82. 82. systemd - sockets <ul><li>Work out what sockets we need to set up
  83. 83. Set them all up in parallel
  84. 84. When the socket is opened, start up its related daemon and hand the socket to it
  85. 85. Same logic for D-Bus </li></ul>
  86. 86. systemd - sockets <ul><li>Work out what sockets we need to set up
  87. 87. Set them all up in parallel
  88. 88. When the socket is opened, start up its related daemon and hand the socket to it
  89. 89. Same logic for D-Bus
  90. 90. Same logic for filesystems </li></ul>
  91. 91. systemd - sockets <ul><li>Work out what sockets we need to set up
  92. 92. Set them all up in parallel
  93. 93. When the socket is opened, start up its related daemon and hand the socket to it
  94. 94. Same logic for D-Bus
  95. 95. Same logic for filesystems </li><ul><li>autofs! </li></ul></ul>
  96. 96. systemd – and others... <ul><li>This isn't actually new </li></ul>
  97. 97. systemd – and others... <ul><li>This isn't actually new </li><ul><li>Mac OS X - launchd </li></ul></ul>
  98. 98. systemd – and others... <ul><li>This isn't actually new </li><ul><li>Mac OS X – launchd
  99. 99. xinetd! </li></ul></ul>
  100. 100. systemd <ul><li>A new init system for Linux </li><ul><li>Makes booting faster </li></ul></ul>
  101. 101. systemd <ul><li>A new init system for Linux </li><ul><li>Makes booting faster </li><ul><li>Start processes in parallel </li></ul></ul></ul>
  102. 102. systemd <ul><li>A new init system for Linux </li><ul><li>Makes booting faster </li><ul><li>Start processes in parallel
  103. 103. Start fewer processes </li></ul></ul></ul>
  104. 104. systemd – results so far <ul><li>System V init: </li><ul><li>[paulway@tachyon ~]$ echo $$ 2440 </li></ul></ul>
  105. 105. systemd – results so far <ul><li>System V init: </li><ul><li>[paulway@tachyon ~]$ echo $$ 2440 </li></ul><li>MacOS: </li><ul><li>154 </li></ul></ul>
  106. 106. systemd – results so far <ul><li>System V init: </li><ul><li>[paulway@tachyon ~]$ echo $$ 2440
  107. 107. Lennart's system: </li><ul><li>grep: 77 times </li></ul></ul><li>MacOS: </li><ul><li>154 </li></ul></ul>
  108. 108. systemd – results so far <ul><li>System V init: </li><ul><li>[paulway@tachyon ~]$ echo $$ 2440
  109. 109. Lennart's system: </li><ul><li>grep: 77 times
  110. 110. awk: 92 times </li></ul></ul><li>MacOS: </li><ul><li>154 </li></ul></ul>
  111. 111. systemd – results so far <ul><li>System V init: </li><ul><li>[paulway@tachyon ~]$ echo $$ 2440
  112. 112. Lennart's system: </li><ul><li>grep: 77 times
  113. 113. awk: 92 times
  114. 114. sed: 74 times </li></ul></ul><li>MacOS: </li><ul><li>154 </li></ul></ul>
  115. 115. systemd – managing processes <ul><li>System V init also restarts things </li></ul>
  116. 116. systemd – managing processes <ul><li>System V init also restarts things
  117. 117. Then they go off and do what they like </li></ul>
  118. 118. systemd – managing processes <ul><li>Manage daemon processes </li></ul>
  119. 119. systemd – managing processes <ul><li>Manage daemon processes </li><ul><li>startup </li></ul></ul>
  120. 120. systemd – managing processes <ul><li>Manage daemon processes </li><ul><li>startup
  121. 121. shutdown </li></ul></ul>
  122. 122. systemd – managing processes <ul><li>Manage daemon processes </li><ul><li>startup
  123. 123. shutdown
  124. 124. log on failure </li></ul></ul>
  125. 125. systemd – managing processes <ul><li>Manage daemon processes </li><ul><li>startup
  126. 126. shutdown
  127. 127. log on failure
  128. 128. maintain their resources </li></ul></ul>
  129. 129. systemd – managing processes <ul><li>Manage daemon processes </li><ul><li>startup
  130. 130. shutdown
  131. 131. log on failure
  132. 132. maintain their resources </li></ul><li>What about rogue processes? </li></ul>
  133. 133. systemd – managing processes <ul><li>Kernel cgroups (Control Groups) </li></ul>
  134. 134. systemd – managing processes <ul><li>Kernel cgroups (Control Groups) </li><ul><li>cgroup inheritance </li></ul></ul>
  135. 135. systemd – managing processes <ul><li>Kernel cgroups (Control Groups) </li><ul><li>cgroup inheritance
  136. 136. Info via /proc/$$/cgroup </li></ul></ul>
  137. 137. systemd – managing processes <ul><li>Kernel cgroups (Control Groups) </li><ul><li>cgroup inheritance
  138. 138. Info via /proc/$$/cgroup
  139. 139. Notify when cgroup is empty </li></ul></ul>
  140. 140. systemd – managing processes <ul><li>Kernel cgroups (Control Groups) </li><ul><li>cgroup inheritance
  141. 141. Info via /proc/$$/cgroup
  142. 142. Notify when cgroup is empty
  143. 143. Resource limits for entire group </li></ul></ul>
  144. 144. systemd - units <ul><li>Units </li></ul>
  145. 145. systemd - units <ul><li>Units </li><ul><li>Service – standard daemon </li></ul></ul>
  146. 146. systemd - units <ul><li>Units </li><ul><li>Service – standard daemon
  147. 147. Socket – unix, internet, fifo </li></ul></ul>
  148. 148. systemd - units <ul><li>Units </li><ul><li>Service – standard daemon
  149. 149. Socket – unix, internet, fifo
  150. 150. Device – from udev </li></ul></ul>
  151. 151. systemd - units <ul><li>Units </li><ul><li>Service – standard daemon
  152. 152. Socket – unix, internet, fifo
  153. 153. Device – from udev
  154. 154. Mount – standard filesystem mount </li></ul></ul>
  155. 155. systemd - units <ul><li>Units </li><ul><li>Service – standard daemon
  156. 156. Socket – unix, internet, fifo
  157. 157. Device – from udev
  158. 158. Mount – standard filesystem mount
  159. 159. Automount – paired with mount </li></ul></ul>
  160. 160. systemd - units <ul><li>Units </li><ul><li>Service – standard daemon
  161. 161. Socket – unix, internet, fifo
  162. 162. Device – from udev
  163. 163. Mount – standard filesystem mount
  164. 164. Automount – paired with mount
  165. 165. Target – logical group of units </li></ul></ul>
  166. 166. systemd - units <ul><li>Units </li><ul><li>Service – standard daemon
  167. 167. Socket – unix, internet, fifo
  168. 168. Device – from udev
  169. 169. Mount – standard filesystem mount
  170. 170. Automount – paired with mount
  171. 171. Target – logical group of units
  172. 172. Snapshot – save and restore state </li></ul></ul>
  173. 173. systemd - units <ul><li>Units - configuration </li><ul><li>Service
  174. 174. Socket
  175. 175. Device
  176. 176. Mount
  177. 177. Automount
  178. 178. Target
  179. 179. Snapshot </li></ul></ul>
  180. 180. systemd - units <ul><li>Units - configuration </li><ul><li>Service – System V init file
  181. 181. Socket
  182. 182. Device
  183. 183. Mount
  184. 184. Automount
  185. 185. Target
  186. 186. Snapshot </li></ul></ul>
  187. 187. systemd - units <ul><li>Units - configuration </li><ul><li>Service – System V init file - LSB
  188. 188. Socket
  189. 189. Device
  190. 190. Mount
  191. 191. Automount
  192. 192. Target
  193. 193. Snapshot </li></ul></ul>
  194. 194. systemd - units <ul><li>Units - configuration </li><ul><li>Service – System V init file - LSB
  195. 195. Socket – cups.socket
  196. 196. Device
  197. 197. Mount
  198. 198. Automount
  199. 199. Target
  200. 200. Snapshot </li></ul></ul>
  201. 201. systemd - units <ul><li>Units - configuration </li><ul><li>Service – System V init file - LSB
  202. 202. Socket – cups.socket
  203. 203. Device – udev
  204. 204. Mount
  205. 205. Automount
  206. 206. Target
  207. 207. Snapshot </li></ul></ul>
  208. 208. systemd - units <ul><li>Units - configuration </li><ul><li>Service – System V init file - LSB
  209. 209. Socket – cups.socket
  210. 210. Device – udev
  211. 211. Mount – /etc/fstab
  212. 212. Automount
  213. 213. Target
  214. 214. Snapshot </li></ul></ul>
  215. 215. systemd - units <ul><li>Units - configuration </li><ul><li>Service – System V init file - LSB
  216. 216. Socket – cups.socket
  217. 217. Device – udev
  218. 218. Mount – /etc/fstab
  219. 219. Automount – home.automount
  220. 220. Target – multi-user.target
  221. 221. Snapshot – suspend.snapshot </li></ul></ul>
  222. 222. systemd – other features <ul><li>Units all have dependencies </li></ul>
  223. 223. systemd – other features <ul><li>Units all have dependencies
  224. 224. Fully compatible with System V init scripts </li></ul>
  225. 225. systemd – other features <ul><li>Units all have dependencies
  226. 226. Fully compatible with System V init scripts, /etc/fstab and other files </li></ul>
  227. 227. systemd – other features <ul><li>Units all have dependencies
  228. 228. Fully compatible with System V init scripts, /etc/fstab and other files
  229. 229. Native config overrides legacy config </li></ul>
  230. 230. systemd – other features <ul><li>Units all have dependencies
  231. 231. Fully compatible with System V init scripts, /etc/fstab and other files
  232. 232. Native config overrides legacy config
  233. 233. Templating / instance mechanism </li></ul>
  234. 234. systemd – other features <ul><li>Units all have dependencies
  235. 235. Fully compatible with System V init scripts, /etc/fstab and other files
  236. 236. Native config overrides legacy config
  237. 237. Templating / instance mechanism </li><ul><li>getty </li></ul></ul>
  238. 238. systemd – other features <ul><li>Units all have dependencies
  239. 239. Fully compatible with System V init scripts, /etc/fstab and other files
  240. 240. Native config overrides legacy config
  241. 241. Templating / instance mechanism </li><ul><li>getty
  242. 242. Ethernet control units </li></ul></ul>
  243. 243. systemd – other features <ul><li>Units all have dependencies
  244. 244. Fully compatible with System V init scripts, /etc/fstab and other files
  245. 245. Native config overrides legacy config
  246. 246. Templating / instance mechanism
  247. 247. Arbitrary number of sockets on launch </li></ul>
  248. 248. systemd – other features <ul><li>Units all have dependencies
  249. 249. Fully compatible with System V init scripts, /etc/fstab and other files
  250. 250. Native config overrides legacy config
  251. 251. Templating / instance mechanism
  252. 252. Arbitrary number of sockets on launch
  253. 253. Supplies /dev/initctl and wtmp/utmp </li></ul>
  254. 254. systemd – more features <ul><li>Transaction system </li></ul>
  255. 255. systemd – more features <ul><li>Transaction system
  256. 256. Start/exit time of each daemon </li></ul>
  257. 257. systemd – more features <ul><li>Transaction system
  258. 258. Start/exit time of each daemon
  259. 259. Full restart of init at any time </li></ul>
  260. 260. systemd – more features <ul><li>Transaction system
  261. 261. Start/exit time of each daemon
  262. 262. Full restart of init at any time
  263. 263. Basic daemon startup coded in C </li></ul>
  264. 264. systemd – more features <ul><li>Transaction system
  265. 265. Start/exit time of each daemon
  266. 266. Full restart of init at any time
  267. 267. Basic daemon startup coded in C
  268. 268. Full Dbus introspection </li></ul>
  269. 269. systemd - when? <ul><li>Coming soon to a distro near you! </li></ul>
  270. 270. systemd - when? <ul><li>Coming soon to a distro near you! </li><ul><li>Fedora 14 </li></ul></ul>
  271. 271. systemd - when? <ul><li>Coming soon to a distro near you! </li><ul><li>Fedora 1 5 </li></ul></ul>
  272. 272. systemd - when? <ul><li>Coming soon to a distro near you! </li><ul><li>Fedora 1 5
  273. 273. OpenSuSE </li></ul></ul>
  274. 274. systemd - when? <ul><li>Coming soon to a distro near you! </li><ul><li>Fedora 1 5
  275. 275. OpenSuSE
  276. 276. Debian </li></ul></ul>
  277. 277. systemd - when? <ul><li>Coming soon to a distro near you! </li><ul><li>Fedora 1 5
  278. 278. OpenSuSE
  279. 279. Debian
  280. 280. Gentoo
  281. 281. ArchLinux </li></ul></ul>
  282. 282. systemd - when? <ul><li>Coming soon to a distro near you! </li><ul><li>Fedora 1 5
  283. 283. OpenSuSE
  284. 284. Debian
  285. 285. Gentoo </li></ul></ul>
  286. 286. systemd - when? <ul><li>Coming soon to a distro near you! </li><ul><li>Fedora 1 5
  287. 287. OpenSuSE
  288. 288. Debian
  289. 289. Gentoo </li><ul><li>No packages for Ubuntu?! </li></ul></ul></ul>
  290. 290. Your daemon and systemd <ul><li>Your daemon now has to: </li></ul>
  291. 291. Your daemon and systemd <ul><li>Your daemon now has to do a lot less </li></ul>
  292. 292. Your daemon and systemd <ul><li>Your daemon now has to do a lot less </li><ul><li>Don't fork or double-fork </li></ul></ul>
  293. 293. Your daemon and systemd <ul><li>Your daemon now has to do a lot less </li><ul><li>Don't fork or double-fork
  294. 294. Don't drop user privileges </li></ul></ul>
  295. 295. Your daemon and systemd <ul><li>Your daemon now has to do a lot less </li><ul><li>Don't fork or double-fork
  296. 296. Don't drop user privileges
  297. 297. Don't write PID files </li></ul></ul>
  298. 298. Your daemon and systemd <ul><li>Your daemon now has to do a lot less </li><ul><li>Don't fork or double-fork
  299. 299. Don't drop user privileges
  300. 300. Don't write PID files </li></ul><li>Things become easier </li></ul>
  301. 301. Your daemon and systemd <ul><li>Your daemon now has to do a lot less </li><ul><li>Don't fork or double-fork
  302. 302. Don't drop user privileges
  303. 303. Don't write PID files </li></ul><li>Things become easier </li><ul><li>Write error to stderr </li></ul></ul>
  304. 304. Your daemon and systemd <ul><li>Your daemon now has to do a lot less </li><ul><li>Don't fork or double-fork
  305. 305. Don't drop user privileges
  306. 306. Don't write PID files </li></ul><li>Things become easier </li><ul><li>Write error to stderr
  307. 307. Sockets and stuff in unit file </li></ul></ul>
  308. 308. systemd
  309. 309. systemd Don't be afraid ☺

×