[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

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.
> 
> But you are also correct that this "override feature" is a bit different
> than the normal proceedings during upgrades and dealing with
> .dpkg-{old,new,dist}.
> 
> But it is the way systemd is designed and you can either work with it or
> fight it every centimeter of the way.
> 

Well, Sven, that's a nice idea, but I can't get it to work for me in this
situation.  I issued

   systemctl edit serial-getty@ttyS0.service

and placed the following two lines into the file:

   [Service]
   ExecStart=-/sbin/agetty -8 --noclear %I 38400 ibm3151

But when I restart the service, I get the following error:

systemd[1]: serial-getty@ttyS0.service: Service has more than one ExecStart= setting, which is only allowed for Type=oneshot services. Refusing.

I want to override "ExecStart", not add a new one.  What am I doing wrong?

-- 
  .''`.     Stephen Powell    <zlinuxman@wowway.com>
 : :'  :
 `. `'`
   `-


Reply to: