4/09/2017

Linux systemd 구조분석 (AM335x-SK)

1 TI-Sitara(AM335x-SK)

AM335x-SK, Start Kit 관련하여 File system을 간단히 분석을 해보고, 이를 최적화를 하려고 한다.
분석을 해보면, /sbin/init 을 systemd로 이용하고 SysVinit의 bootscript 을 혼용해서 사용하고 있다.
TI의 경우는 변화 도중 인지 몰라도 /lib/systemd/systemd boot 후 SysVInit Script모드를 사용한다.
현재의 추세가 SysVInit 에서 systemd로 변환되어지는 구조이며, 혼용해서 사용하는 독특한 구조이다.

Systemd 와 SysVInit 혼용
  https://ahyuo79.blogspot.com/2017/04/linux-init-script.html

1.1 기본동작분석

boot parameter 확인하고, file system의 구조를 파악을 하자

  • PID 1의 boot parameter 확인 
Kernel은 Filesystem이 존재하지 않으면 Booting이 되지 않기때문에 아래의 두개의 중요
  1. root= filesystem
  2. init=  init program ( 현재 설정하지 않았기 때문에 기본설정 /sbin/init)

root@am335x-evm:~# cat /proc/cmdline 
console=ttyO0,115200n8 root=PARTUUID=000390f5-02 rw rootfstype=ext4 rootwait

root@am335x-evm:~# cat /proc/1/cmdline  // init args 확인 
root@am335x-evm:~# ls /proc/1/fd     // 관련 FD 확인 부모 Process / 자식 Process
or
root@am335x-evm:~# ls /proc/1/fdinfo 

상위 커널 Argument를 보면 현재 /sbin/init로 기반으로 동작

/sbin/init ->  /lib/systemd/systemd  (현재 /sbin/init 은 /lib/systemd/systemd에 link)

  • /sin/init 와 runlevel 존재 확인 
root@am335x-evm:~# ls /sbin      
agetty                  e2fsck                  fsck.minix              ifup                    losetup                 mkswap.util-linux       route                   switch_root.util-linux
arp                     e2image                 fsck.minix.util-linux   init                    losetup.util-linux      modinfo                 routef                  sysctl
badblocks               e2label                 fsck.msdos              insmod                  lsmod                   modinfo.kmod            routel                  sysctl.procps
blkid                   e2undo                  fsck.util-linux         insmod.kmod             mkdosfs                 modprobe                rtmon                   syslogd
blockdev                e4crypt                 fsck.vfat               ip                      mke2fs                  modprobe.kmod           rtpr                    tc
blockdev.util-linux     e4defrag                fstrim                  ip.iproute2             mkfs.ext2               mount-copybind          runlevel                tune2fs
bridge                  fatlabel                fw_printenv             iwconfig                mkfs.ext3               mount.nfs               setconsole              udevd
cfdisk                  fdisk                   fw_setenv               iwgetid                 mkfs.ext4               mount.nfs4              shutdown                udhcpc
ctrlaltdel              fdisk.util-linux        getty                   iwlist                  mkfs.ext4dev            nologin                 start-stop-daemon       uevent
debugfs                 filefrag                halt                    iwpriv                  mkfs.fat                pivot_root              sulogin                 umount.nfs
depmod                  fsck                    hdparm                  iwspy                   mkfs.minix              pivot_root.util-linux   sulogin.util-linux      umount.nfs4
depmod.kmod             fsck.ext2               hdparm.hdparm           klogd                   mkfs.minix.util-linux   populate-extfs.sh       swapoff                 vconfig
dosfsck                 fsck.ext3               hwclock                 ldconfig                mkfs.msdos              poweroff                swapoff.util-linux      vigr
dosfslabel              fsck.ext4               ifcfg                   loadkmap                mkfs.vfat               reboot                  swapon                  vigr.shadow
dumpe2fs                fsck.ext4dev            ifconfig                logread                 mklost+found            rmmod                   swapon.util-linux       vipw
e2freefrag              fsck.fat                ifdown                  logsave                 mkswap                  rmmod.kmod              switch_root             vipw.shadow


  • runlevel 0~6까지 존재하며, init를 통해 다시 확인가능
  1. init 0 : Halt 
  2. init 1 : Single-user Mode 
  3. init 2 : Multi-user Mode  (Not support network)
  4. init 3 : Multi-user Mode with Networking
  5. init 4 : Not used/User-definable  (For special purposes)
  6. init 5 : Graphic-user Mode ( As runlevel 3 + display manager)
  7. init 6 : Reboot  (Reboots the system)

  https://wiki.kldp.org/KoreanDoc/html/Boot_Process-KLDP/iterateinittab.html

  • systemd 관련 명령어 (system damon)
systemd 명령어와 관련 명령어 검색

root@am335x-evm:~# find / -name systemd
/var/lib/systemd
/lib/systemd
/lib/systemd/systemd   // 실제 user를 위한 system daemon 이며 이동작을 확인 (systemctl) 
/etc/systemd
/etc/xdg/systemd
/sys/fs/cgroup/systemd
/run/user/0/systemd
/run/udev/tags/systemd
/run/systemd
/usr/lib/systemd
/usr/share/systemd
/usr/include/systemd
/tmp/0-runtime-dir/systemd

다양한 systemd의 실행이며 각각의 역할이 있으며, 이 부분은 좀 더 자세히 알아보자

root@am335x-evm:~# ls /lib/systemd/ 
network                       systemd-ac-power              systemd-initctl               systemd-networkd-wait-online  systemd-shutdown              systemd-udevd
system                        systemd-backlight             systemd-journald              systemd-quotacheck            systemd-sleep                 systemd-update-done
system-generators             systemd-bootchart             systemd-localed               systemd-random-seed           systemd-socket-proxyd         systemd-update-utmp
system-preset                 systemd-cgroups-agent         systemd-logind                systemd-remount-fs            systemd-sysctl                systemd-user-sessions
system-shutdown               systemd-fsck                  systemd-machined              systemd-reply-password        systemd-sysv-install          systemd-vconsole-setup
system-sleep                  systemd-hibernate-resume      systemd-modules-load          systemd-resolved              systemd-timedated
systemd                       systemd-hostnamed             systemd-networkd              systemd-rfkill                systemd-timesyncd

root@am335x-evm:~# /lib/systemd/systemd --help

systemd [OPTIONS...]

Starts up and maintains the system or user services.

  -h --help                      Show this help
     --test                      Determine startup sequence, dump it and exit
     --no-pager                  Do not pipe output into a pager
     --dump-configuration-items  Dump understood unit configuration items
     --unit=UNIT                 Set default unit
     --system                    Run a system instance, even if PID != 1
     --user                      Run a user instance
     --dump-core[=BOOL]          Dump core on crash
     --crash-vt=NR               Change to specified VT on crash
     --crash-reboot[=BOOL]       Reboot on crash
     --crash-shell[=BOOL]        Run shell on crash
     --confirm-spawn[=BOOL]      Ask for confirmation when spawning processes
     --show-status[=BOOL]        Show status updates on the console during bootup
     --log-target=TARGET         Set log target (console, journal, kmsg, journal-or-kmsg, null)
     --log-level=LEVEL           Set log level (debug, info, notice, warning, err, crit, alert, emerg)
     --log-color[=BOOL]          Highlight important log messages
     --log-location[=BOOL]       Include code location in log messages
     --default-standard-output=  Set default standard output for services
     --default-standard-error=   Set default standard error output for services


systemd의 설명
  https://www.freedesktop.org/software/systemd/man/systemd.html#


  • systemd의 설정 (system/user 설정 값확인)
  1. /etc/systemd/system.conf
  2. /etc/systemd/user.conf
  https://www.freedesktop.org/software/systemd/man/systemd-system.conf.html#


1.2 systemd-x program들 

각 systemd-xxx program 설치는 옵션이므로, 대부분 필요한 것들을 별도설치

root@am335x-evm:~# ls -al /usr/bin/systemd-*
-rwxr-xr-x    1 root     root         26160 Dec 15 00:09 /usr/bin/systemd-cat
-rwxr-xr-x    1 root     root        256116 Dec 15 00:09 /usr/bin/systemd-cgls
-rwxr-xr-x    1 root     root        268436 Dec 15 00:09 /usr/bin/systemd-cgtop
-rwxr-xr-x    1 root     root         54932 Dec 15 00:09 /usr/bin/systemd-delta
-rwxr-xr-x    1 root     root         30256 Dec 15 00:09 /usr/bin/systemd-detect-virt
-rwxr-xr-x    1 root     root        535036 Dec 15 00:09 /usr/bin/systemd-nspawn
-rwxr-xr-x    1 root     root         34348 Dec 15 00:09 /usr/bin/systemd-path
-rwxr-xr-x    1 root     root        292980 Dec 15 00:09 /usr/bin/systemd-resolve
-rwxr-xr-x    1 root     root        334168 Dec 15 00:09 /usr/bin/systemd-run
-rwxr-xr-x    1 root     root         46672 Dec 15 00:09 /usr/bin/systemd-socket-activate
-rwxr-xr-x    1 root     root        239724 Dec 15 00:09 /usr/bin/systemd-stdio-bridge
...


systemd-cat
  https://www.freedesktop.org/software/systemd/man/systemd-cat.html#

systemd-cgls
  https://www.freedesktop.org/software/systemd/man/systemd-cgls.html#

systemd-cgtop
  https://www.freedesktop.org/software/systemd/man/systemd-cgtop.html#

systemd-run
  https://www.freedesktop.org/software/systemd/man/systemd-run.html

systemd-nspanwn
  https://www.freedesktop.org/software/systemd/man/systemd-nspawn.html

systemd-xxx 검색
  https://www.freedesktop.org/software/systemd/man/index.html

systemd-analyze가 없음 (추후 설치)
  https://www.freedesktop.org/software/systemd/man/systemd-analyze.html

systemd의 service 등록방법
  https://chhanz.github.io/linux/2019/01/18/linux-how-to-create-custom-systemd-service/
  https://fmd1225.tistory.com/93

systemd의 Yocto service 등록방법
  https://community.nxp.com/thread/472820

systemd-analyze 못찾을 경우
  https://stackoverflow.com/questions/34501611/systemd-apparently-not-finding-service-file

backup
  https://stackoverflow.com/questions/50354012/systemctl-failing-with-unknown-section-timer

1.3 Process 의 PID 분석 

Process의 PID를 보고 현재 실행되는 순서를 역분석을 해보면, 아래와 같이 /sbin/init 가 PID가 1 지만, link만 존재하므로 systemd가 실행이 되어있다.

확인할 경우 아래와 같이 ps -ax or ps -aux 전체사항을 확인하고 필요한 사항이 있다면, grep or head or tail 사용하자.

root@am335x-evm:~# ps -aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  9.9  1.7   5232  4384 ?        Ss   23:15   0:08 /sbin/init
root         2  0.0  0.0      0     0 ?        S    23:15   0:00 [kthreadd]
root         3  0.1  0.0      0     0 ?        S    23:15   0:00 [ksoftirqd/0]
root         4  0.0  0.0      0     0 ?        S    23:15   0:00 [kworker/0:0]
root         5  0.0  0.0      0     0 ?        S<   23:15   0:00 [kworker/0:0H]
root         6  0.0  0.0      0     0 ?        S    23:15   0:00 [kworker/u2:0]
root         7  0.2  0.0      0     0 ?        S    23:15   0:00 [rcu_preempt]
root         8  0.0  0.0      0     0 ?        S    23:15   0:00 [rcu_sched]
root         9  0.0  0.0      0     0 ?        S    23:15   0:00 [rcu_bh]
root        10  0.0  0.0      0     0 ?        S    23:15   0:00 [kdevtmpfs]
root        11  0.0  0.0      0     0 ?        S<   23:15   0:00 [netns]
root        12  0.0  0.0      0     0 ?        S<   23:15   0:00 [perf]
root        13  0.0  0.0      0     0 ?        S    23:15   0:00 [kworker/0:1]
root        14  0.0  0.0      0     0 ?        S<   23:15   0:00 [writeback]
root        15  0.0  0.0      0     0 ?        S<   23:15   0:00 [crypto]
root        16  0.0  0.0      0     0 ?        S<   23:15   0:00 [bioset]
root        17  0.0  0.0      0     0 ?        S<   23:15   0:00 [kblockd]
root        18  0.0  0.0      0     0 ?        S<   23:15   0:00 [edac-poller]
root        19  0.0  0.0      0     0 ?        S<   23:15   0:00 [rpciod]
root        20  0.0  0.0      0     0 ?        S    23:15   0:00 [kswapd0]
root        21  0.0  0.0      0     0 ?        S    23:15   0:00 [fsnotify_mark]
root        22  0.0  0.0      0     0 ?        S<   23:15   0:00 [nfsiod]
root        31  0.0  0.0      0     0 ?        S<   23:15   0:00 [dma_wq]
root        32  0.7  0.0      0     0 ?        S    23:15   0:00 [kworker/u2:1]
root        33  0.0  0.0      0     0 ?        S<   23:15   0:00 [bioset]
root        34  0.0  0.0      0     0 ?        S<   23:15   0:00 [bioset]
root        35  0.0  0.0      0     0 ?        S<   23:15   0:00 [bioset]
root        36  0.0  0.0      0     0 ?        S<   23:15   0:00 [bioset]
root        37  0.0  0.0      0     0 ?        S<   23:15   0:00 [bioset]
root        38  0.0  0.0      0     0 ?        S<   23:15   0:00 [bioset]
root        39  0.0  0.0      0     0 ?        S<   23:15   0:00 [bioset]
root        40  0.0  0.0      0     0 ?        S<   23:15   0:00 [bioset]
root        43  0.0  0.0      0     0 ?        S<   23:15   0:00 [kpsmoused]
root        44  0.0  0.0      0     0 ?        S    23:15   0:00 [irq/180-4803c00]
root        45  0.0  0.0      0     0 ?        S    23:15   0:00 [irq/179-4803c00]
root        46  0.0  0.0      0     0 ?        S<   23:15   0:00 [ipv6_addrconf]
root        47  0.0  0.0      0     0 ?        S<   23:15   0:00 [deferwq]
root        48  0.0  0.0      0     0 ?        S    23:15   0:00 [irq/159-44e0b00]
root        49  0.1  0.0      0     0 ?        S    23:15   0:00 [kworker/u2:2]
root        50  0.0  0.0      0     0 ?        S    23:15   0:00 [irq/33-48060000]
root        51  0.0  0.0      0     0 ?        S    23:15   0:00 [kworker/u2:3]
root        52  0.0  0.0      0     0 ?        S<   23:15   0:00 [bioset]
root        53  1.6  0.0      0     0 ?        S    23:15   0:01 [mmcqd/0]
root        54  0.1  0.0      0     0 ?        S<   23:15   0:00 [kworker/0:1H]
root        55  0.0  0.0      0     0 ?        S    23:15   0:00 [jbd2/mmcblk0p2-]
root        56  0.0  0.0      0     0 ?        S<   23:15   0:00 [ext4-rsv-conver]
root        68  0.0  0.0      0     0 ?        S    23:15   0:00 [kworker/0:2]
root        76  0.0  0.0      0     0 ?        S<   23:15   0:00 [cryptodev_queue]
root        98  2.3  0.7   3616  1908 ?        Ss   23:15   0:01 /lib/systemd/systemd-journald // log를 위해 시작 
root       121  0.1  0.0      0     0 ?        S    23:15   0:00 [kworker/0:3]
root       127  1.6  1.0  10524  2528 ?        Ss   23:15   0:01 /lib/systemd/systemd-udevd  //udevd 시작 
root       325  0.0  0.0      0     0 ?        S<   23:15   0:00 [pvr_timer]
systemd+   398  0.2  0.6  12136  1608 ?        Ssl  23:15   0:00 /lib/systemd/systemd-timesyncd
root       432  0.0  0.0      0     0 ?        S    23:15   0:00 [irq/195-remotep]
root       437  0.0  0.0      0     0 ?        S    23:15   0:00 [irq/197-remotep]
root       456  0.0  0.0      0     0 ?        S    23:15   0:00 [scsi_eh_0]
root       457  0.0  0.0      0     0 ?        S<   23:15   0:00 [scsi_tmf_0]
root       458  0.0  0.0      0     0 ?        S    23:15   0:00 [usb-storage]
root       460  0.0  0.5   1956  1300 ?        Ss   23:15   0:00 /sbin/klogd -n
root       469  2.5  2.5   8864  6408 ?        Ss   23:15   0:01 /usr/sbin/ofonod -n
root       471  0.1  0.7   2600  1812 ?        Ss   23:15   0:00 /lib/systemd/systemd-logind
root       475  0.1  0.5   1908  1440 ?        Ss   23:15   0:00 /usr/libexec/ipsec/starter --daemon charon --nofork
root       480  0.1  0.4   1972  1244 ?        Ss   23:15   0:00 /sbin/syslogd -n -C
avahi      483  0.0  0.9   4660  2484 ?        Ss   23:15   0:00 avahi-daemon: running [am335x-evm.local]
message+   492  0.5  0.9   4320  2496 ?        Ss   23:15   0:00 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
root       494  0.0  0.0      0     0 ?        S<   23:15   0:00 [bioset]
avahi      501  0.0  0.7   4660  1792 ?        S    23:15   0:00 avahi-daemon: chroot helper
root       513  0.0  0.0      0     0 ?        S    23:15   0:00 [file-storage]
systemd+   535  0.2  0.8   2776  2056 ?        Ss   23:15   0:00 /lib/systemd/systemd-networkd
root       562  0.2  1.8 142008  4528 ?        Ssl  23:15   0:00 /usr/libexec/ipsec/charon
systemd+   677  0.0  0.7   2984  1904 ?        Ss   23:15   0:00 /lib/systemd/systemd-resolved
root       682  0.0  0.4   1780  1184 tty1     Ss+  23:15   0:00 /sbin/agetty --noclear tty1 linux
root       688  0.1  0.8   4864  2132 ttyS0    Ss   23:15   0:00 /bin/login --
root       689  0.0  0.4   1780  1196 ttyGS0   Ss+  23:15   0:00 /sbin/agetty -8 -L ttyGS0 115200 xterm
root       691  0.2  1.1   5160  2984 ?        Ss   23:15   0:00 /usr/sbin/lighttpd -D -f /etc/lighttpd.conf
root       773  0.0  0.0      0     0 ?        S<   23:15   0:00 [pvr_workqueue]
root       807  0.0  0.7   2664  1776 tty4     Ss+  23:15   0:00 /bin/sh /usr/bin/runWeston
root       810  0.5  5.0  19144 12556 tty4     S+   23:15   0:00 weston --idle-time=0
root       815  0.0  0.3   1956   868 ?        Ss   23:15   0:00 /usr/sbin/telnetd
root       822  0.2  2.0   7008  5096 tty4     S+   23:15   0:00 /usr/libexec/weston-keyboard
root       823  0.2  2.0   7016  5024 tty4     S+   23:15   0:00 /usr/libexec/weston-desktop-shell
nobody     829  0.0  0.6   2448  1632 ?        Ss   23:15   0:00 /usr/sbin/thttpd -d /srv/www -p 8080
root       835  0.0  0.3   2292   928 ?        Ss   23:15   0:00 /usr/sbin/rngd -r /dev/urandom
root       843  8.3 24.3 176048 60924 ?        Sl   23:15   0:04 /usr/bin/matrix_browser http://localhost:80/
root       860  0.0  0.0      0     0 ?        S    23:15   0:00 [kworker/0:4]
root       863  0.0  0.0      0     0 ?        S    23:15   0:00 [kworker/0:5]
root       867  0.4  0.0      0     0 ?        S    23:15   0:00 [kworker/0:6]
root       894  1.3  1.7   5348  4388 ?        Ss   23:15   0:00 /lib/systemd/systemd --user  //user용 systemd 실행 (일반서비스) 
root       898  0.0  0.9   7492  2352 ?        S    23:15   0:00 (sd-pam)
root       901  0.0  0.8   2668  2044 ttyS0    S    23:15   0:00 -sh
root       918  0.2  0.4   1780  1212 ?        Ss   23:16   0:00 /sbin/agetty -8 -L ttyS3 115200 xterm
root       922  0.0  0.5   2612  1272 ttyS0    R+   23:16   0:00 ps -aux


2 systemd 와 init script 혼합 (telinit) 

/sbin/telinit  확인필요

  • run level 3 확인 (init.d link)
root@am335x-evm:~# runlevel 
N 3   // multi-user mode 

root@am335x-evm:/etc# ls -al  rc3.d    // Runlevel 3 분석 
drwxr-xr-x    2 root     root          4096 Dec 15  2016 .
drwxr-xr-x   46 root     root          4096 Dec 14 23:15 ..
lrwxrwxrwx    1 root     root            20 Dec 15  2016 S01networking -> ../init.d/networking
lrwxrwxrwx    1 root     root            16 Dec 15  2016 S02dbus-1 -> ../init.d/dbus-1
lrwxrwxrwx    1 root     root            19 Dec 15  2016 S03uim-sysfs -> ../init.d/uim-sysfs
lrwxrwxrwx    1 root     root            16 Dec 15  2016 S08rc.pvr -> ../init.d/rc.pvr
lrwxrwxrwx    1 root     root            18 Dec 15  2016 S10dropbear -> ../init.d/dropbear
lrwxrwxrwx    1 root     root            17 Dec 15  2016 S10telnetd -> ../init.d/telnetd
lrwxrwxrwx    1 root     root            17 Dec 15  2016 S12rpcbind -> ../init.d/rpcbind
lrwxrwxrwx    1 root     root            21 Dec 14 23:36 S15mountnfs.sh -> ../init.d/mountnfs.sh
lrwxrwxrwx    1 root     root            19 Dec 15  2016 S19nfscommon -> ../init.d/nfscommon
lrwxrwxrwx    1 root     root            24 Dec 15  2016 S20busybox-udhcpd -> ../init.d/busybox-udhcpd
lrwxrwxrwx    1 root     root            20 Dec 15  2016 S20hwclock.sh -> ../init.d/hwclock.sh
lrwxrwxrwx    1 root     root            16 Dec 15  2016 S20syslog -> ../init.d/syslog
lrwxrwxrwx    1 root     root            16 Dec 15  2016 S20thttpd -> ../init.d/thttpd
lrwxrwxrwx    1 root     root            22 Dec 15  2016 S21avahi-daemon -> ../init.d/avahi-daemon
lrwxrwxrwx    1 root     root            15 Dec 15  2016 S22ofono -> ../init.d/ofono
lrwxrwxrwx    1 root     root            19 Dec 15  2016 S30rng-tools -> ../init.d/rng-tools
lrwxrwxrwx    1 root     root            18 Dec 15  2016 S70lighttpd -> ../init.d/lighttpd
lrwxrwxrwx    1 root     root            24 Dec 15  2016 S97matrix-gui-2.0 -> ../init.d/matrix-gui-2.0
lrwxrwxrwx    1 root     root            18 Dec 15  2016 S98parse-ip -> ../init.d/parse-ip
lrwxrwxrwx    1 root     root            27 Dec 15  2016 S98thermal-zone-init -> ../init.d/thermal-zone-init
lrwxrwxrwx    1 root     root            22 Dec 15  2016 S99gplv3-notice -> ../init.d/gplv3-notice
lrwxrwxrwx    1 root     root            22 Dec 14 23:36 S99rmnologin.sh -> ../init.d/rmnologin.sh


  • /etc/init.d  확인 
root@am335x-evm:/etc# ls -al init.d/
drwxr-xr-x    2 root     root          4096 Dec 15  2016 .
drwxr-xr-x   46 root     root          4096 Dec 14 23:15 ..
-rw-r--r--    1 root     root          1150 Dec 15 00:09 README
-rwxr-xr-x    1 root     root           250 Dec 14 23:23 alignment.sh
-rwxr-xr-x    1 root     root           811 Dec 14 23:45 alsa-state
-rwxr-xr-x    1 root     root          4491 Dec 15 00:13 avahi-daemon
-rwxr-xr-x    1 root     root           492 Dec 14 23:23 banner.sh
-rwxr-xr-x    1 root     root          1922 Dec 14 23:23 bootmisc.sh
-rwxr-xr-x    1 root     root          1042 Dec 14 23:50 busybox-udhcpd
-rwxr-xr-x    1 root     root          3581 Dec 14 23:23 checkroot.sh
-rwxr-xr-x    1 root     root          2887 Dec 15 00:11 dbus-1
-rwxr-xr-x    1 root     root           526 Dec 14 23:23 devpts.sh
-rwxr-xr-x    1 root     root           353 Dec 14 23:23 dmesg.sh
-rwxr-xr-x    1 root     root          3002 Dec 15 00:00 dropbear
lrwxrwxrwx    1 root     root            33 Dec 15  2016 functions -> /etc/init.d/functions.initscripts
-rw-r--r--    1 root     root          2141 Dec 14 23:23 functions.initscripts
-rwxr-xr-x    1 root     root          2389 Dec 14 23:48 gplv3-notice
-rwxr-xr-x    1 root     root           510 Dec 14 23:23 halt
-rwxr-xr-x    1 root     root           546 Dec 15 00:00 hostapd
-rwxr-xr-x    1 root     root           580 Dec 14 23:23 hostname.sh
-rwxr-xr-x    1 root     root          2541 Dec 14 23:50 hwclock.sh
-rwxr-xr-x    1 root     root           579 Dec 14 23:50 inetd.busybox
-rwxr-xr-x    1 root     root           632 Dec 14 23:52 lighttpd
-rwxr-xr-x    1 root     root          1102 Dec 14 23:51 matrix-gui-2.0
-rwxr-xr-x    1 root     root          1223 Dec 14 23:48 modutils.sh
-rwxr-xr-x    1 root     root           859 Dec 14 23:23 mountall.sh
-rwxr-xr-x    1 root     root          1522 Dec 14 23:23 mountnfs.sh
-rwxr-xr-x    1 root     root          2124 Dec 14 23:48 networking
-rwxr-xr-x    1 root     root          1609 Dec 14 23:49 nfscommon
-rwxr-xr-x    1 root     root           516 Dec 15 00:15 ofono
-rwxr-xr-x    1 root     root          1950 Dec 15 00:00 parse-ip
-rwxr-xr-x    1 root     root          6721 Dec 14 23:23 populate-volatile.sh
-rwxr-xr-x    1 root     root           521 Dec 14 23:50 psplash.sh
-rwxr-xr-x    1 1001     1001          3203 Dec 14 23:15 rc.pvr
-rwxr-xr-x    1 root     root           968 Dec 14 23:23 read-only-rootfs-hook.sh
-rwxr-xr-x    1 root     root           289 Dec 14 23:23 reboot
-rwxr-xr-x    1 root     root           585 Dec 14 23:23 rmnologin.sh
-rwxr-xr-x    1 root     root          1098 Dec 14 23:48 rng-tools
-rwxr-xr-x    1 root     root          1827 Dec 15 00:12 rpcbind
-rwxr-xr-x    1 root     root            25 Dec 14 23:47 run-postinsts
-rwxr-xr-x    1 root     root           336 Dec 14 23:23 save-rtc.sh
-rwxr-xr-x    1 root     root           438 Dec 14 23:23 sendsigs
-rwxr-xr-x    1 root     root           578 Dec 14 23:23 single
-rwxr-xr-x    1 root     root           782 Dec 14 23:23 sysfs.sh
lrwxrwxrwx    1 root     root            26 Dec 15  2016 syslog -> /etc/init.d/syslog.busybox
-rwxr-xr-x    1 root     root          1715 Dec 14 23:50 syslog.busybox
-rwxr-xr-x    1 root     root          3183 Dec 15 00:09 systemd-udevd
-rwxr-xr-x    1 root     root          1455 Dec 14 23:48 telnetd
-rwxr-xr-x    1 root     root           414 Dec 14 23:48 thermal-zone-init
-rwxr-xr-x    1 root     root          1033 Dec 14 23:48 thttpd
-rwxr-xr-x    1 root     root           663 Dec 15 00:00 uim-sysfs
-rwxr-xr-x    1 root     root           516 Dec 14 23:23 umountfs
-rwxr-xr-x    1 root     root           711 Dec 14 23:23 umountnfs.sh
-rwxr-xr-x    1 root     root          1473 Dec 14 23:23 urandom
-rwxr-xr-x    1 root     root          2750 Dec 15 00:00 weston


2.1 systemctl 확인 사항 

상위 init script에 대해 알아봤으니, 이제 systemd의 기본 명령어인 systemctl 을 이용하여 기본설정과 현재 동작하는 순서에 대해서 알아보자.

  • systemctl 명령어
root@am335x-evm:/# systemctl get-default // default mode 확인

root@am335x-evm:/# systemctl list-dependencies multi-user.target  // default-mode 관련부분 list 확인 
.......
root@am335x-evm:/# systemctl list-unit-files // unit 관련 list 전부확인
........


2.2 systemd unit 기능 확인 (AM335x-SK)

  • 현재 boot mode 확인
# systemctl get-default  // 현재 boot mode 3 
multi-user.target

상위 runlevel과 동일하며, 3에 해당하는 유저로, 만약 X Server를 이용한다면, graphical. target으로 나올 것이다.

default.target -> /lib/systemd/system/multi-user.target



  • Unit 분석 방법

이런식으로 현재 분석을 하고 있으며, 추후 더 시간이 있을 경우 다시 분석

$ grep WantedBy=multi-user.target -r /lib/systemd/system  // 확인 
$ grep WantedBy=multi-user.target -r /etc/systemd/system  // 확인
$ grep WantedBy=sysinit.target -r /lib/systemd/system 
$ ls multi-user.target.wants // 확인 

Unit 문법확인
  https://www.freedesktop.org/software/systemd/man/systemd.unit.html

일반적인 사용되는 Unit 전체구조 설명
  https://www.freedesktop.org/software/systemd/man/systemd.special.html#

*. slice 의 부분설명 (machine.slice, system.slice, user.slice )
  https://www.freedesktop.org/software/systemd/man/systemd.special.html#Special%20Slice%20Units

sysinit.target : 기본적으로 실행되는 곳
  https://www.freedesktop.org/software/systemd/man/systemd.special.html#sysinit.target


  • 각 unit 확인 (/etc/systemd/system)
/etc/systemd/system 의 unit은 대부분 link로 구성이 되며 사용되는것은 /lib/systemd/system 에 연결 or 사용되지 않는다면 /dev/null 연결
별도로 추가한다면 이곳에 추가
root@am335x-evm:/# cd /etc/systemd/system  // 사용하는 service는 /lib or /etc/systemd/system 
root@am335x-evm:/etc/systemd/system# ls -al
drwxr-xr-x   11 root     root          4096 Dec 15 02:24 .
drwxr-xr-x    5 root     root          4096 Dec 14 23:43 ..
lrwxrwxrwx    1 root     root             9 Dec 15 02:23 banner.service -> /dev/null  // 사용하지 않는다면, /dev/null link 하며, 사용한다면, /lib/systemd/system link 
drwxr-xr-x    2 root     root          4096 Dec 14 23:15 basic.target.wants
drwxr-xr-x    2 root     root          4096 Dec 15 02:23 bluetooth.target.wants
lrwxrwxrwx    1 root     root             9 Dec 15 02:23 bootmisc.service -> /dev/null
lrwxrwxrwx    1 root     root             9 Dec 15 02:23 busybox-udhcpc.service -> /dev/null
lrwxrwxrwx    1 root     root             9 Dec 15 02:23 checkfs.service -> /dev/null
lrwxrwxrwx    1 root     root             9 Dec 15 02:23 checkroot.service -> /dev/null
lrwxrwxrwx    1 root     root             9 Dec 15 02:23 dbus-1.service -> /dev/null
lrwxrwxrwx    1 root     root            37 Dec 15 02:23 dbus-org.bluez.service -> /lib/systemd/system/bluetooth.service
lrwxrwxrwx    1 root     root            40 Dec 15 02:23 dbus-org.freedesktop.Avahi.service -> /lib/systemd/system/avahi-daemon.service
lrwxrwxrwx    1 root     root            37 Dec 15 02:24 default.target -> /lib/systemd/system/multi-user.target
lrwxrwxrwx    1 root     root             9 Dec 15 02:23 devpts.service -> /dev/null
lrwxrwxrwx    1 root     root             9 Dec 15 02:23 dmesg.service -> /dev/null
drwxr-xr-x    2 root     root          4096 Dec 15 02:22 getty.target.wants
lrwxrwxrwx    1 root     root             9 Dec 15 02:23 hostname.service -> /dev/null
lrwxrwxrwx    1 root     root             9 Dec 15 02:23 hwclock.service -> /dev/null
drwxr-xr-x    2 root     root          4096 Dec 15 02:23 local-fs.target.wants
lrwxrwxrwx    1 root     root             9 Dec 15 02:23 modutils.service -> /dev/null
lrwxrwxrwx    1 root     root             9 Dec 15 02:23 mountall.service -> /dev/null
lrwxrwxrwx    1 root     root             9 Dec 15 02:23 mountnfs.service -> /dev/null
drwxr-xr-x    2 root     root          4096 Dec 15 02:23 multi-user.target.wants
drwxr-xr-x    2 root     root          4096 Dec 15 00:09 network-online.target.wants
lrwxrwxrwx    1 root     root             9 Dec 15 02:23 networking.service -> /dev/null
lrwxrwxrwx    1 root     root             9 Dec 15 02:23 nfscommon.service -> /dev/null
lrwxrwxrwx    1 root     root             9 Dec 15 02:23 nfsserver.service -> /dev/null
lrwxrwxrwx    1 root     root             9 Dec 15 02:23 populate-volatile.service -> /dev/null
lrwxrwxrwx    1 root     root             9 Dec 15 02:23 psplash.service -> /dev/null
lrwxrwxrwx    1 root     root             9 Dec 15 02:23 read-only-rootfs-hook.service -> /dev/null
lrwxrwxrwx    1 root     root             9 Dec 15 02:23 rmnologin.service -> /dev/null
drwxr-xr-x    2 root     root          4096 Dec 15 02:23 sockets.target.wants
-rw-r--r--    1 root     root           327 Dec 15 00:09 sync-clocks.service
lrwxrwxrwx    1 root     root             9 Dec 15 02:23 sysfs.service -> /dev/null
drwxr-xr-x    2 root     root          4096 Dec 14 23:15 sysinit.target.wants
lrwxrwxrwx    1 root     root             9 Dec 15 02:23 syslog.busybox.service -> /dev/null
lrwxrwxrwx    1 root     root            42 Dec 15 02:23 syslog.service -> /lib/systemd/system/busybox-syslog.service
-rw-r--r--    1 root     root           709 Dec 15 00:09 systemd-hostnamed.service
drwxr-xr-x    2 root     root          4096 Dec 15 02:23 systemd-random-seed.service.wants
-rw-r--r--    1 root     root           843 Dec 15 00:09 systemd-udevd.service
lrwxrwxrwx    1 root     root             9 Dec 15 02:23 urandom.service -> /dev/null

  • 각 unit 확인 (/lib/systemd/system)
기본으로 제공되는 unit으로 많이사용하는 것을 이곳에 넣어 보관

root@am335x-evm:/# cd /lib/systemd/system
root@am335x-evm:/lib/systemd/system# ls -al
-rw-r--r--    1 root     root           403 Dec 15 00:09 -.slice
drwxr-xr-x   19 root     root         12288 Dec 15 02:23 .
drwxr-xr-x    8 root     root          4096 Dec 14 23:50 ..
-rw-r--r--    1 root     root           506 Dec 15 00:10 alsa-restore.service
-rw-r--r--    1 root     root           410 Dec 15 00:10 alsa-state.service
lrwxrwxrwx    1 root     root            14 Dec 15 00:09 autovt@.service -> getty@.service
-rw-r--r--    1 root     root          1044 Dec 15 00:13 avahi-daemon.service
-rw-r--r--    1 root     root           874 Dec 15 00:13 avahi-daemon.socket
-rw-r--r--    1 root     root           879 Dec 15 00:09 basic.target
drwxr-xr-x    2 root     root          4096 Dec 15 00:10 basic.target.wants
-rw-r--r--    1 root     root           176 Dec 15 00:13 bluetooth.service
-rw-r--r--    1 root     root           379 Dec 15 00:09 bluetooth.target
-rw-r--r--    1 root     root           358 Dec 15 00:09 busnames.target
drwxr-xr-x    2 root     root          4096 Dec 15 00:09 busnames.target.wants
-rw-r--r--    1 root     root           116 Dec 14 23:50 busybox-klogd.service
-rw-r--r--    1 root     root           270 Dec 14 23:50 busybox-syslog.service
-rw-r--r--    1 root     root           770 Dec 15 00:09 console-getty.service
-rw-r--r--    1 root     root           752 Dec 15 00:09 console-shell.service
-rw-r--r--    1 root     root           791 Dec 15 00:09 container-getty@.service
lrwxrwxrwx    1 root     root            13 Dec 15 00:09 ctrl-alt-del.target -> reboot.target
lrwxrwxrwx    1 root     root            25 Dec 15 00:09 dbus-org.freedesktop.hostname1.service -> systemd-hostnamed.service
lrwxrwxrwx    1 root     root            23 Dec 15 00:09 dbus-org.freedesktop.locale1.service -> systemd-localed.service
lrwxrwxrwx    1 root     root            22 Dec 15 00:09 dbus-org.freedesktop.login1.service -> systemd-logind.service
lrwxrwxrwx    1 root     root            24 Dec 15 00:09 dbus-org.freedesktop.machine1.service -> systemd-machined.service
lrwxrwxrwx    1 root     root            24 Dec 15 00:09 dbus-org.freedesktop.network1.service -> systemd-networkd.service
lrwxrwxrwx    1 root     root            24 Dec 15 00:09 dbus-org.freedesktop.resolve1.service -> systemd-resolved.service
lrwxrwxrwx    1 root     root            25 Dec 15 00:09 dbus-org.freedesktop.timedate1.service -> systemd-timedated.service
-rw-r--r--    1 root     root           366 Dec 15 00:11 dbus.service
-rw-r--r--    1 root     root           106 Dec 15 00:11 dbus.socket
drwxr-xr-x    2 root     root          4096 Dec 15 00:11 dbus.target.wants
-rw-r--r--    1 root     root          1008 Dec 15 00:09 debug-shell.service
lrwxrwxrwx    1 root     root            16 Dec 15 00:09 default.target -> graphical.target
-rw-r--r--    1 root     root           670 Dec 15 00:09 dev-hugepages.mount
-rw-r--r--    1 root     root           624 Dec 15 00:09 dev-mqueue.mount
-rw-r--r--    1 root     root           131 Dec 15 00:00 dropbear.socket
-rw-r--r--    1 root     root           384 Dec 15 00:00 dropbear@.service
-rw-r--r--    1 root     root           453 Dec 15 00:00 dropbearkey.service
-rw-r--r--    1 root     root           995 Dec 15 00:09 emergency.service
-rw-r--r--    1 root     root           431 Dec 15 00:09 emergency.target
-rw-r--r--    1 root     root           501 Dec 15 00:09 exit.target
-rw-r--r--    1 root     root           440 Dec 15 00:09 final.target
-rw-r--r--    1 root     root           420 Dec 15 00:00 gadget-init.service
-rw-r--r--    1 root     root           460 Dec 15 00:09 getty.target
-rw-r--r--    1 root     root          1536 Dec 15 00:09 getty@.service
-rw-r--r--    1 root     root           198 Dec 14 23:48 gplv3-notice.service
-rw-r--r--    1 root     root           558 Dec 15 00:09 graphical.target
drwxr-xr-x    2 root     root          4096 Dec 15 00:09 graphical.target.wants
-rw-r--r--    1 root     root           565 Dec 15 00:09 halt-local.service
-rw-r--r--    1 root     root           487 Dec 15 00:09 halt.target
-rw-r--r--    1 root     root           447 Dec 15 00:09 hibernate.target
-rw-r--r--    1 root     root           468 Dec 15 00:09 hybrid-sleep.target
-rw-r--r--    1 root     root           630 Dec 15 00:09 initrd-cleanup.service
-rw-r--r--    1 root     root           553 Dec 15 00:09 initrd-fs.target
-rw-r--r--    1 root     root           790 Dec 15 00:09 initrd-parse-etc.service
-rw-r--r--    1 root     root           526 Dec 15 00:09 initrd-root-fs.target
-rw-r--r--    1 root     root           640 Dec 15 00:09 initrd-switch-root.service
-rw-r--r--    1 root     root           691 Dec 15 00:09 initrd-switch-root.target
-rw-r--r--    1 root     root           664 Dec 15 00:09 initrd-udevadm-cleanup-db.service
-rw-r--r--    1 root     root           671 Dec 15 00:09 initrd.target
-rw-r--r--    1 root     root           501 Dec 15 00:09 kexec.target
-rw-r--r--    1 root     root           677 Dec 15 00:09 kmod-static-nodes.service
-rw-r--r--    1 root     root           658 Dec 15 00:09 ldconfig.service
-rw-r--r--    1 root     root           292 Dec 14 23:52 lighttpd.service
-rw-r--r--    1 root     root           395 Dec 15 00:09 local-fs-pre.target
-rw-r--r--    1 root     root           507 Dec 15 00:09 local-fs.target
drwxr-xr-x    2 root     root          4096 Dec 15 00:09 local-fs.target.wants
-rw-r--r--    1 root     root           405 Dec 15 00:09 machine.slice
-rw-r--r--    1 root     root           531 Dec 15 00:09 machines.target
-rw-r--r--    1 root     root           492 Dec 15 00:09 multi-user.target
drwxr-xr-x    2 root     root          4096 Dec 15 02:22 multi-user.target.wants
-rw-r--r--    1 root     root           464 Dec 15 00:09 network-online.target
-rw-r--r--    1 root     root           461 Dec 15 00:09 network-pre.target
-rw-r--r--    1 root     root           480 Dec 15 00:09 network.target
-rw-r--r--    1 root     root           250 Dec 14 23:49 nfs-statd.service
-rw-r--r--    1 root     root           514 Dec 15 00:09 nss-lookup.target
-rw-r--r--    1 root     root           473 Dec 15 00:09 nss-user-lookup.target
-rw-r--r--    1 root     root           183 Dec 15 00:15 ofono.service
-rw-r--r--    1 root     root           521 Dec 14 23:50 opkg-configure.service
-rw-r--r--    1 root     root           554 Dec 15 00:09 org.freedesktop.hostname1.busname
-rw-r--r--    1 root     root           550 Dec 15 00:09 org.freedesktop.locale1.busname
-rw-r--r--    1 root     root           598 Dec 15 00:09 org.freedesktop.login1.busname
-rw-r--r--    1 root     root           549 Dec 15 00:09 org.freedesktop.machine1.busname
-rw-r--r--    1 root     root           675 Dec 15 00:09 org.freedesktop.network1.busname
-rw-r--r--    1 root     root           763 Dec 15 00:09 org.freedesktop.resolve1.busname
-rw-r--r--    1 root     root           480 Dec 15 00:09 org.freedesktop.systemd1.busname
-rw-r--r--    1 root     root           538 Dec 15 00:09 org.freedesktop.timedate1.busname
-rw-r--r--    1 root     root           354 Dec 15 00:09 paths.target
-rw-r--r--    1 root     root           552 Dec 15 00:09 poweroff.target
drwxr-xr-x    2 root     root          4096 Dec 15 00:09 poweroff.target.wants
-rw-r--r--    1 root     root           377 Dec 15 00:09 printer.target
-rw-r--r--    1 root     root           178 Dec 15 00:16 ptpd.service
-rw-r--r--    1 root     root           576 Dec 15 00:09 quotaon.service
-rw-r--r--    1 root     root           612 Dec 15 00:09 rc-local.service
-rw-r--r--    1 root     root           543 Dec 15 00:09 reboot.target
drwxr-xr-x    2 root     root          4096 Dec 15 00:09 reboot.target.wants
-rw-r--r--    1 root     root           396 Dec 15 00:09 remote-fs-pre.target
-rw-r--r--    1 root     root           482 Dec 15 00:09 remote-fs.target
-rw-r--r--    1 root     root           988 Dec 15 00:09 rescue.service
-rw-r--r--    1 root     root           486 Dec 15 00:09 rescue.target
drwxr-xr-x    2 root     root          4096 Dec 15 00:09 rescue.target.wants
-rw-r--r--    1 root     root           212 Dec 15 00:12 rpcbind.service
-rw-r--r--    1 root     root           132 Dec 15 00:12 rpcbind.socket
-rw-r--r--    1 root     root           500 Dec 15 00:09 rpcbind.target
-rw-r--r--    1 root     root           385 Dec 14 23:47 run-postinsts.service
lrwxrwxrwx    1 root     root            15 Dec 15 00:09 runlevel0.target -> poweroff.target
lrwxrwxrwx    1 root     root            13 Dec 15 00:09 runlevel1.target -> rescue.target
drwxr-xr-x    2 root     root          4096 Dec 15 00:09 runlevel1.target.wants
lrwxrwxrwx    1 root     root            17 Dec 15 00:09 runlevel2.target -> multi-user.target
drwxr-xr-x    2 root     root          4096 Dec 15 00:09 runlevel2.target.wants
lrwxrwxrwx    1 root     root            17 Dec 15 00:09 runlevel3.target -> multi-user.target
drwxr-xr-x    2 root     root          4096 Dec 15 00:09 runlevel3.target.wants
lrwxrwxrwx    1 root     root            17 Dec 15 00:09 runlevel4.target -> multi-user.target
drwxr-xr-x    2 root     root          4096 Dec 15 00:09 runlevel4.target.wants
lrwxrwxrwx    1 root     root            16 Dec 15 00:09 runlevel5.target -> graphical.target
drwxr-xr-x    2 root     root          4096 Dec 15 00:09 runlevel5.target.wants
lrwxrwxrwx    1 root     root            13 Dec 15 00:09 runlevel6.target -> reboot.target
-rw-r--r--    1 root     root          1059 Dec 14 23:23 serial-getty@.service
-rw-r--r--    1 root     root           402 Dec 15 00:09 shutdown.target
-rw-r--r--    1 root     root           362 Dec 15 00:09 sigpwr.target
-rw-r--r--    1 root     root           420 Dec 15 00:09 sleep.target
-rw-r--r--    1 root     root           409 Dec 15 00:09 slices.target
-rw-r--r--    1 root     root           380 Dec 15 00:09 smartcard.target
-rw-r--r--    1 root     root           356 Dec 15 00:09 sockets.target
drwxr-xr-x    2 root     root          4096 Dec 15 02:22 sockets.target.wants
-rw-r--r--    1 root     root           380 Dec 15 00:09 sound.target
-rw-r--r--    1 root     root           204 Dec 15 00:03 strongswan.service
-rw-r--r--    1 root     root           441 Dec 15 00:09 suspend.target
-rw-r--r--    1 root     root           353 Dec 15 00:09 swap.target
-rw-r--r--    1 root     root           715 Dec 15 00:09 sys-fs-fuse-connections.mount
-rw-r--r--    1 root     root           719 Dec 15 00:09 sys-kernel-config.mount
-rw-r--r--    1 root     root           662 Dec 15 00:09 sys-kernel-debug.mount
-rw-r--r--    1 root     root           518 Dec 15 00:09 sysinit.target
drwxr-xr-x    2 root     root          4096 Dec 15 02:22 sysinit.target.wants
lrwxrwxrwx    1 root     root             9 Dec 14 23:50 syslog.service -> /dev/null
-rw-r--r--    1 root     root          1235 Dec 15 00:09 syslog.socket
-rw-r--r--    1 root     root           585 Dec 15 00:09 system-update.target
-rw-r--r--    1 root     root           436 Dec 15 00:09 system.slice
-rw-r--r--    1 root     root           646 Dec 15 00:09 systemd-ask-password-console.path
-rw-r--r--    1 root     root           653 Dec 15 00:09 systemd-ask-password-console.service
-rw-r--r--    1 root     root           574 Dec 15 00:09 systemd-ask-password-wall.path
-rw-r--r--    1 root     root           681 Dec 15 00:09 systemd-ask-password-wall.service
-rw-r--r--    1 root     root           724 Dec 15 00:09 systemd-backlight@.service
-rw-r--r--    1 root     root           650 Dec 15 00:09 systemd-bootchart.service
-rw-r--r--    1 root     root           497 Dec 15 00:09 systemd-exit.service
-rw-r--r--    1 root     root           755 Dec 15 00:09 systemd-firstboot.service
-rw-r--r--    1 root     root           574 Dec 15 00:09 systemd-fsck-root.service
-rw-r--r--    1 root     root           600 Dec 15 00:09 systemd-fsck@.service
-rw-r--r--    1 root     root           544 Dec 15 00:09 systemd-halt.service
-rw-r--r--    1 root     root           631 Dec 15 00:09 systemd-hibernate-resume@.service
-rw-r--r--    1 root     root           501 Dec 15 00:09 systemd-hibernate.service
-rw-r--r--    1 root     root           710 Dec 15 00:09 systemd-hostnamed.service
-rw-r--r--    1 root     root           778 Dec 15 00:09 systemd-hwdb-update.service
-rw-r--r--    1 root     root           519 Dec 15 00:09 systemd-hybrid-sleep.service
-rw-r--r--    1 root     root           480 Dec 15 00:09 systemd-initctl.service
-rw-r--r--    1 root     root           524 Dec 15 00:09 systemd-initctl.socket
-rw-r--r--    1 root     root           667 Dec 15 00:09 systemd-journal-catalog-update.service
-rw-r--r--    1 root     root           731 Dec 15 00:09 systemd-journal-flush.service
-rw-r--r--    1 root     root           607 Dec 15 00:09 systemd-journald-audit.socket
-rw-r--r--    1 root     root          1090 Dec 15 00:09 systemd-journald-dev-log.socket
-rw-r--r--    1 root     root          1293 Dec 15 00:09 systemd-journald.service
-rw-r--r--    1 root     root           842 Dec 15 00:09 systemd-journald.socket
-rw-r--r--    1 root     root           557 Dec 15 00:09 systemd-kexec.service
-rw-r--r--    1 root     root           691 Dec 15 00:09 systemd-localed.service
-rw-r--r--    1 root     root          1126 Dec 15 00:09 systemd-logind.service
-rw-r--r--    1 root     root           693 Dec 15 00:09 systemd-machine-id-commit.service
-rw-r--r--    1 root     root           948 Dec 15 00:09 systemd-machined.service
-rw-r--r--    1 root     root           967 Dec 15 00:09 systemd-modules-load.service
-rw-r--r--    1 root     root           685 Dec 15 00:09 systemd-networkd-wait-online.service
-rw-r--r--    1 root     root          1339 Dec 15 00:09 systemd-networkd.service
-rw-r--r--    1 root     root           591 Dec 15 00:09 systemd-networkd.socket
-rw-r--r--    1 root     root          1378 Dec 15 00:09 systemd-nspawn@.service
-rw-r--r--    1 root     root           553 Dec 15 00:09 systemd-poweroff.service
-rw-r--r--    1 root     root           618 Dec 15 00:09 systemd-quotacheck.service
-rw-r--r--    1 root     root           717 Dec 15 00:09 systemd-random-seed.service
-rw-r--r--    1 root     root           548 Dec 15 00:09 systemd-reboot.service
-rw-r--r--    1 root     root           757 Dec 15 00:09 systemd-remount-fs.service
-rw-r--r--    1 root     root           907 Dec 15 00:09 systemd-resolved.service
-rw-r--r--    1 root     root           696 Dec 15 00:09 systemd-rfkill.service
-rw-r--r--    1 root     root           617 Dec 15 00:09 systemd-rfkill.socket
-rw-r--r--    1 root     root           497 Dec 15 00:09 systemd-suspend.service
-rw-r--r--    1 root     root           649 Dec 15 00:09 systemd-sysctl.service
-rw-r--r--    1 root     root           655 Dec 15 00:09 systemd-timedated.service
-rw-r--r--    1 root     root          1032 Dec 15 00:09 systemd-timesyncd.service
-rw-r--r--    1 root     root           598 Dec 15 00:09 systemd-tmpfiles-clean.service
-rw-r--r--    1 root     root           450 Dec 15 00:09 systemd-tmpfiles-clean.timer
-rw-r--r--    1 root     root           703 Dec 15 00:09 systemd-tmpfiles-setup-dev.service
-rw-r--r--    1 root     root           683 Dec 15 00:09 systemd-tmpfiles-setup.service
-rw-r--r--    1 root     root           823 Dec 15 00:09 systemd-udev-settle.service
-rw-r--r--    1 root     root           743 Dec 15 00:09 systemd-udev-trigger.service
-rw-r--r--    1 root     root           578 Dec 15 00:09 systemd-udevd-control.socket
-rw-r--r--    1 root     root           570 Dec 15 00:09 systemd-udevd-kernel.socket
-rw-r--r--    1 root     root           842 Dec 15 00:09 systemd-udevd.service
-rw-r--r--    1 root     root           630 Dec 15 00:09 systemd-update-done.service
-rw-r--r--    1 root     root           757 Dec 15 00:09 systemd-update-utmp-runlevel.service
-rw-r--r--    1 root     root           754 Dec 15 00:09 systemd-update-utmp.service
-rw-r--r--    1 root     root           573 Dec 15 00:09 systemd-user-sessions.service
-rw-r--r--    1 root     root           613 Dec 15 00:09 systemd-vconsole-setup.service
-rw-r--r--    1 root     root           395 Dec 15 00:09 time-sync.target
-rw-r--r--    1 root     root           405 Dec 15 00:09 timers.target
drwxr-xr-x    2 root     root          4096 Dec 15 00:09 timers.target.wants
-rw-r--r--    1 root     root           625 Dec 15 00:09 tmp.mount
-rw-r--r--    1 root     root           417 Dec 15 00:09 umount.target
-rw-r--r--    1 root     root           392 Dec 15 00:09 user.slice
-rw-r--r--    1 root     root           528 Dec 15 00:09 user@.service
-rw-r--r--    1 root     root           475 Dec 15 00:09 var-lib-machines.mount
-rw-r--r--    1 root     root           496 Dec 14 23:22 var-volatile-lib.service



root@am335x-evm:/lib/systemd/system# cd /usr/lib/systemd // system 이 존재하지 않음 
root@am335x-evm:/usr/lib/systemd# ls -al
drwxr-xr-x    6 root     root          4096 Dec 15  2016 .
drwxr-xr-x   56 root     root         53248 Dec 15  2016 ..
drwxr-xr-x    2 root     root          4096 Dec 15  2016 catalog
drwxr-xr-x    2 root     root          4096 Dec 15  2016 network
drwxr-xr-x    2 root     root          4096 Dec 15  2016 user
drwxr-xr-x    2 root     root          4096 Dec 15  2016 user-generators


  • 전체 service status 확인 및 기본분석 
방향키가 상 아래가 동작이 되며, 실시간으로 반영이 되기 때문에 확인가능
서비스 종료를 원한다면 q를 사용
  1. /etc/systemd/system.conf  : /lib/systemd/systemd --system 설정 : Consol에서만 가능  
  2. /etc/systemd/user.conf : /lib/systemd/systemd --user 설정 : SSH로 로그인시 확인가능


#systemctl status  // 현재 전체 service 확인 
?? am335x-evm
    State: running
     Jobs: 0 queued
   Failed: 0 units
    Since: Thu 1970-01-01 00:00:02 UTC; 46 years 11 months ago
   CGroup: /
           ???€init.scope  // init.scope 영역 , 만약 ssh를 사용하여 login을 한다면, user.slice가 존재 
           ?? ???€1 /sbin/init  // PID 1 /sbin/init
           ???€system.slice  //systemd 로 실행되는 각 service들 
           ?? ???€avahi-daemon.service
           ?? ?? ???€502 avahi-daemon: running [am335x-evm.local  // 502는 PID, init scirpt도 존재 
           ?? ?? ???€524 avahi-daemon: chroot helpe
           ?? ???€dbus.service
           ?? ??  ???€475 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
           ?? ???€lighttpd.service
           ?? ?? ???€695 /usr/sbin/lighttpd -D -f /etc/lighttpd.conf
           ?? ???€matrix-gui-2.0.service
           ?? ?? ???€857 /usr/bin/matrix_browser http://localhost:80/
           ?? ???€weston.service
           ?? ?? ???€811 /bin/sh /usr/bin/runWeston
           ?? ?? ???€814 weston --idle-time=0
           ?? ?? ???€826 /usr/libexec/weston-keyboard
           ?? ?? ???€828 /usr/libexec/weston-desktop-shell
           ?? ???€busybox-klogd.service
           ?? ?? ???€506 /sbin/klogd -n
           ?? ???€telnetd.service
           ?? ?? ???€819 /usr/sbin/telnetd
           ?? ???€system-serial\x2dgetty.slice
           ?? ?? ???€serial-getty@ttyS3.service
           ?? ?? ?? ???€1018 /sbin/agetty -8 -L ttyS3 115200 xterm
           ?? ?? ???€serial-getty@ttyGS0.service
           ?? ??   ???€685 /sbin/agetty -8 -L ttyGS0 115200 xterm
           ?? ???€systemd-journald.service
           ?? ?? ???€99 /lib/systemd/systemd-journald
           ?? ???€busybox-udhcpd.service
           ?? ?? ???€833 /usr/sbin/udhcpd -S /etc/udhcpd_usb0.conf
           ?? ???€thttpd.service
           ?? ?? ???€831 /usr/sbin/thttpd -d /srv/www -p 8080
           ?? ???€systemd-resolved.service
           ?? ?? ???€687 /lib/systemd/systemd-resolved
           ?? ???€systemd-timesyncd.service
           ?? ?? ???€396 /lib/systemd/systemd-timesyncd
           ?? ???€systemd-logind.service
           ?? ?? ???€465 /lib/systemd/systemd-logind
           ?? ???€systemd-networkd.service
           ?? ?? ???€496 /lib/systemd/systemd-networkd
           ?? ???€system-getty.slice
           ?? ?? ???€getty@tty1.service
           ?? ??   ???€682 /sbin/agetty --noclear tty1 linux
           ?? ???€ofono.service
           .......



  • systemd 관련 관리
  https://wiki.archlinux.org/index.php/systemd
  https://websetnet.com/ko/manage-systemd-services-and-units/
  http://www.phytec.eu/fileadmin/user_upload/downloads/Manuals/L-818e_1.pdf

  • Frame buffer Console 기능
  https://e2e.ti.com/support/embedded/linux/f/354/t/324198