Elogind dan Cgroup di Slackware 14.2

Submitted by w41lf0x on Sun, 07/31/2016 - 14:11

gnome-logo-hitamPada tulisan saya sebelumnya, WLSBuild Untuk GNOME 3.18, sudah terbukti bahwa GNOME3 dapat berjalan normal di Slackware 14.2. Yang belum saya tulis adalah bagaimana cara saya menjalankan servis logind dari elogind yang merupakan percabangan dari pengembangan systemd untuk sistem yang membutuhkan komponen logind tetapi tidak ingin memasang systemd. Sila kunjungi website pengembang elogind untuk informasi lebih lanjut mengenai elogind: https://github.com/wingo/elogind

Logind merupakan kebutuhan yang wajib ada untuk gdm GNOME3. Logind merupakan sebuah servis yang akan dijalankan untuk menyediakan informasi dan fasilitas manajemen sesi user melalui servis dbus. Yang saya baru tahu adalah, systemd adalah sebuah init sistem yang mengontrol servis melalui cgroup. Anda tidak dapat menjalankan systemd di sistem yang tidak memiliki fasilitas cgroup. Apa itu cgroup? Sila kunjungi website RedHat ini: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/…

Dalam sistem yang tidak menggunakan systemd, misalnya Slackware, tidak akan ada mount point untuk systemd yang seharusnya berada /sys/fs/cgroup/systemd. Kontrol servis logind seharusnya berada di dalam mount point tersebut. Hal ini menyebabkan servis logind tidak dapat berjalan. Jadi untuk menyelesaikan permasalahan ini, saya menjalankan skrip untuk menautkan elogind ke /sys/fs/cgroup/elogind. Saya letakkan skrip tersebut di dalam rc.S di baris setelah mount cgroup:

# Mount Control Groups filesystem interface:
if grep -wq cgroup /proc/filesystems ; then
  if [ -d /sys/fs/cgroup ]; then
    # See linux-*/Documentation/cgroups/cgroups.txt (section 1.6)
    # Check if we have some tools to autodetect the available cgroup controllers
    if [ -x /bin/cut -a -x /bin/tail ]; then
      # Mount a tmpfs as the cgroup filesystem root
      mount -t tmpfs -o mode=0755 cgroup_root /sys/fs/cgroup
      # Autodetect available controllers and mount them in subfolders
      controllers="$(/bin/cut -f 1 /proc/cgroups | /bin/tail -n +2)"
      for i in $controllers; do
        mkdir /sys/fs/cgroup/$i
        mount -t cgroup -o $i $i /sys/fs/cgroup/$i
      done
      unset i controllers
      # Add elogind cgroup controller
      mkdir -p /sys/fs/cgroup/elogind
      mount -t cgroup -o none,name=elogind cgroup /sys/fs/cgroup/elogind
    else
      # We can't use autodetection so fall back mounting them all together
      mount -t cgroup cgroup /sys/fs/cgroup
    fi
  else
    mkdir -p /dev/cgroup
    mount -t cgroup cgroup /dev/cgroup
  fi
fi

Hasilnya adalah seperti ini:

root@wls-lm:~# ls -lha /sys/fs/cgroup/
total 0
drwxr-xr-x 15 root root 300 Jul 31 13:50 ./
drwxr-xr-x  9 root root   0 Jul 31  2016 ../
dr-xr-xr-x  2 root root   0 Jul 31  2016 blkio/
drwxr-xr-x  2 root root  60 Jul 31 13:50 cgmanager/
dr-xr-xr-x  2 root root   0 Jul 31  2016 cpu/
dr-xr-xr-x  2 root root   0 Jul 31  2016 cpuacct/
dr-xr-xr-x  2 root root   0 Jul 31  2016 cpuset/
dr-xr-xr-x  2 root root   0 Jul 31  2016 devices/
dr-xr-xr-x  2 root root   0 Jul 31  2016 elogind/
dr-xr-xr-x  2 root root   0 Jul 31  2016 freezer/
dr-xr-xr-x  2 root root   0 Jul 31  2016 memory/
dr-xr-xr-x  2 root root   0 Jul 31  2016 net_cls/
dr-xr-xr-x  2 root root   0 Jul 31  2016 net_prio/
dr-xr-xr-x  2 root root   0 Jul 31  2016 perf_event/
dr-xr-xr-x  2 root root   0 Jul 31  2016 pids/
root@wls-lm:~# ls -lha /sys/fs/cgroup/elogind/
total 0
dr-xr-xr-x  2 root root   0 Jul 31 14:07 ./
drwxr-xr-x 15 root root 300 Jul 31 13:50 ../
-rw-r--r--  1 root root   0 Jul 31 14:07 cgroup.clone_children
-rw-r--r--  1 root root   0 Jul 31 13:54 cgroup.procs
-r--r--r--  1 root root   0 Jul 31 14:07 cgroup.sane_behavior
-rw-r--r--  1 root root   0 Jul 31 13:54 notify_on_release
-rw-r--r--  1 root root   0 Jul 31 13:54 release_agent
-rw-r--r--  1 root root   0 Jul 31 13:50 tasks

Setelah itu servis logind dapat dijalankan oleh dbus tiap kali GNOME3 saya jalankan. Ini adalah output dari debug dbus untuk servis logind:

root@wls-lm:~# gdbus introspect --system --dest org.freedesktop.login1 --object-path /org/freedesktop/login1
node /org/freedesktop/login1 {
  interface org.freedesktop.DBus.Peer {
    methods:
      Ping();
      GetMachineId(out s machine_uuid);
    signals:
    properties:
  };
  interface org.freedesktop.DBus.Introspectable {
    methods:
      Introspect(out s data);
    signals:
    properties:
  };
  interface org.freedesktop.DBus.Properties {
    methods:
      Get(in  s interface,
          in  s property,
          out v value);
      GetAll(in  s interface,
             out a{sv} properties);
      Set(in  s interface,
          in  s property,
          in  v value);
    signals:
      PropertiesChanged(s interface,
                        a{sv} changed_properties,
                        as invalidated_properties);
    properties:
  };
  interface org.freedesktop.login1.Manager {
    methods:
      GetSession(in  s arg_0,
                 out o arg_1);
      GetSessionByPID(in  u arg_0,
                      out o arg_1);
      GetUser(in  u arg_0,
              out o arg_1);
      GetUserByPID(in  u arg_0,
                   out o arg_1);
      GetSeat(in  s arg_0,
              out o arg_1);
      ListSessions(out a(susso) arg_0);
      ListUsers(out a(uso) arg_0);
      ListSeats(out a(so) arg_0);
      ListInhibitors(out a(ssssuu) arg_0);
      @org.freedesktop.systemd1.Privileged("true")
      CreateSession(in  u arg_0,
                    in  u arg_1,
                    in  s arg_2,
                    in  s arg_3,
                    in  s arg_4,
                    in  s arg_5,
                    in  s arg_6,
                    in  u arg_7,
                    in  s arg_8,
                    in  s arg_9,
                    in  b arg_10,
                    in  s arg_11,
                    in  s arg_12,
                    in  a(sv) arg_13,
                    out s arg_14,
                    out o arg_15,
                    out s arg_16,
                    out h arg_17,
                    out u arg_18,
                    out s arg_19,
                    out u arg_20,
                    out b arg_21);
      @org.freedesktop.systemd1.Privileged("true")
      ReleaseSession(in  s arg_0);
      ActivateSession(in  s arg_0);
      ActivateSessionOnSeat(in  s arg_0,
                            in  s arg_1);
      LockSession(in  s arg_0);
      UnlockSession(in  s arg_0);
      LockSessions();
      UnlockSessions();
      KillSession(in  s arg_0,
                  in  s arg_1,
                  in  i arg_2);
      KillUser(in  u arg_0,
               in  i arg_1);
      TerminateSession(in  s arg_0);
      TerminateUser(in  u arg_0);
      TerminateSeat(in  s arg_0);
      SetUserLinger(in  u arg_0,
                    in  b arg_1,
                    in  b arg_2);
      AttachDevice(in  s arg_0,
                   in  s arg_1,
                   in  b arg_2);
      FlushDevices(in  b arg_0);
      PowerOff(in  b arg_0);
      Reboot(in  b arg_0);
      Suspend(in  b arg_0);
      Hibernate(in  b arg_0);
      HybridSleep(in  b arg_0);
      CanPowerOff(out s arg_0);
      CanReboot(out s arg_0);
      CanSuspend(out s arg_0);
      CanHibernate(out s arg_0);
      CanHybridSleep(out s arg_0);
      Inhibit(in  s arg_0,
              in  s arg_1,
              in  s arg_2,
              in  s arg_3,
              out h arg_4);
    signals:
      SessionNew(s arg_0,
                 o arg_1);
      SessionRemoved(s arg_0,
                     o arg_1);
      UserNew(u arg_0,
              o arg_1);
      UserRemoved(u arg_0,
                  o arg_1);
      SeatNew(s arg_0,
              o arg_1);
      SeatRemoved(s arg_0,
                  o arg_1);
      PrepareForShutdown(b arg_0);
      PrepareForSleep(b arg_0);
    properties:
      @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
      readonly as KillOnlyUsers = [];
      @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
      readonly as KillExcludeUsers = ['root'];
      @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
      readonly b KillUserProcesses = false;
      readonly b IdleHint = true;
      readonly t IdleSinceHint = 0;
      readonly t IdleSinceHintMonotonic = 0;
      readonly s BlockInhibited = '';
      readonly s DelayInhibited = '';
      @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
      readonly t InhibitDelayMaxUSec = 5000000;
      @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
      readonly s HandlePowerKey = 'poweroff';
      @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
      readonly s HandleSuspendKey = 'suspend';
      @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
      readonly s HandleHibernateKey = 'hibernate';
      @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
      readonly s HandleLidSwitch = 'suspend';
      @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
      readonly s HandleLidSwitchDocked = 'ignore';
      @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
      readonly t HoldoffTimeoutUSec = 30000000;
      @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
      readonly s IdleAction = 'ignore';
      @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
      readonly t IdleActionUSec = 1800000000;
      @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
      readonly b PreparingForShutdown = false;
      @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
      readonly b PreparingForSleep = false;
  };
};

Mudah-mudahan dapat membantu