Re: Getting a serial console to work on Jessie
On Wed, 02 Sep 2015 17:29:40 -0400 (EDT), Sven Hartge wrote:
> ...
>
> systemd provides a way to override or ammend parts of units.
> You do this by creating a directory structure like this:
>
> /etc/systemd/system/foo.service.d/
>
> This will contain all additional config files for the unit
> "foo.service".
>
> For example: I don't want systemd to clear the screen on tty1 when it
> starts a new getty. The unit responsible for this TTY is named
> "getty@tty1.service". I created
>
> /etc/systemd/system/getty@tty1.service.d
>
> and put a file named "noclear.conf" in it with this content:
>
> ,----
> | [Service]
> | TTYVTDisallocate=no
> `----
>
> This will add (or change) the TTYVTDisallocate option to the unit.
> The original path to the unit is "/lib/systemd/system/getty@.service"
> and if this file is changed by a package update, its new content will be
> used.
>
> If I had copied the _whole_ file to /etc/systemd/system then the new
> version of the unit in "/lib/systemd/system" would never get used, just
> my own version. This may be fine but may also cause major problems in
> the future.
>
> This is what I meant by "future changes are preserved" as you don't just
> clobber them with your own full copy of the (then) old unit file.
>
> You can check which files are used for a unit with systemctl:
>
> systemctl cat getty@tty1.service
>
> and you will get an output like this (a bit shortened by me for this
> mail):
>
> ,----
> | # /lib/systemd/system/getty@.service
> |
> | [Unit]
> | Description=Getty on %I
> | Documentation=man:agetty(8) man:systemd-getty-generator(8)
> | Documentation=http://0pointer.de/blog/projects/serial-console.html
> | After=systemd-user-sessions.service plymouth-quit-wait.service
> | <<----8<--->>
> | [Service]
> | # the VT is cleared by TTYVTDisallocate
> | TTYVTDisallocate=yes
> | KillMode=process
> | IgnoreSIGPIPE=no
> | SendSIGHUP=yes
> |
> | # Unset locale for the console getty since the console has problems
> | # displaying some internationalized messages.
> | Environment=LANG= LANGUAGE= LC_CTYPE= LC_NUMERIC= LC_TIME= LC_COLLATE=
> | LC_MONETARY= LC_MESSAGES= LC_
> |
> | [Install]
> | WantedBy=getty.target
> | DefaultInstance=tty1
> |
> | # /etc/systemd/system/getty@tty1.service.d/noclear.conf
> | [Service]
> | TTYVTDisallocate=no
> `----
>
> Note how my own addition shows up at the bottom.
>
> Also note how a later "TTYVTDisallocate=no" overrides the earlier
> "TTYVTDisallocate=yes".
>
> You can also use "systemd-delta" to check which units have overrides or
> extentions. And with newer systemd (Stretch and newer) you can even use
> "systemctl edit unitname" and it will create the needed directory
> structure in the correct place for you.
Thanks for the tip, Sven. I'll try to incorporate your suggestion in the
next revision of my serial console document. With luck, I may get to it
this weekend.
Do you know a similar technique for overriding individual udev rules in
a system-provided rules file?
--
.''`. Stephen Powell <zlinuxman@wowway.com>
: :' :
`. `'`
`-
Reply to: