100 Days of DevOps — Day 68-Introduction to Systemd
To view the updated DevOps course(101DaysofDevOps)
Course Registration link: https://www.101daysofdevops.com/register/
Course Link: https://www.101daysofdevops.com/courses/101-days-of-devops/
YouTube link: https://www.youtube.com/user/laprashant/videos
Welcome to Day 68 of 100 Days of DevOps, Focus for today is Introduction to Systemd
If you ask me the most important new feature introduced in RHEL7/Centos7 I would say that is Systemd
Units in Systemd
- Unit is the basic building block in Systemd
- These are the things you can manage using Systemd
# It shows the unit types# systemctl -t helpAvailable unit types:servicesocketbusnametarget --> group of services that belong togethersnapshotdevicemount --> mounts are preferably done using systemd rather /etc/fstabautomountswaptimerpathslicescope
- Behind every unit, there is a file and they are located in /usr/lib/systemd/system
# cd /usr/lib/systemd/system
# lsarp-ethers.service fstrim.timer nss-user-lookup.target runlevel5.target systemd-localed.serviceauditd.service getty-pre.target paths.target runlevel5.target.wants systemd-logind.serviceauth-rpcgss-module.service getty@.service polkit.service runlevel6.target systemd-machined.serviceautovt@.service getty.target postfix.service selinux-policy-migrate-local-changes@.service systemd-machine-id-commit.servicebasic.target graphical.target poweroff.target serial-getty@.service systemd-modules-load.servicebasic.target.wants graphical.target.wants poweroff.target.wants shutdown.target systemd-nspawn@.serviceblk-availability.service gssproxy.service printer.target shutdown.target.wants systemd-poweroff.servicebluetooth.target halt-local.service proc-fs-nfsd.mount sigpwr.target systemd-quotacheck.servicebrandbot.path halt.target proc-sys-fs-binfmt_misc.automount sleep.target systemd-random-seed.servicebrandbot.service hibernate.target proc-sys-fs-binfmt_misc.mount -.slice systemd-readahead-collect.servicechrony-dnssrv@.service htcacheclean.service qemu-guest-agent.service slices.target systemd-readahead-done.servicechrony-dnssrv@.timer httpd.service quotaon.service smartcard.target systemd-readahead-done.timerchronyd.service hybrid-sleep.target rc-local.service sockets.target systemd-readahead-drop.servicechrony-wait.service initrd-cleanup.service rdisc.service sockets.target.wants systemd-readahead-replay.servicecloud-config.service initrd-fs.target reboot.target sound.target systemd-reboot.servicecloud-config.target initrd-parse-etc.service reboot.target.wants sshd-keygen.service systemd-remount-fs.servicecloud-final.service initrd-root-fs.target remote-cryptsetup.target sshd.service systemd-rfkill@.servicecloud-init-local.service initrd-switch-root.service remote-fs-pre.target sshd@.service systemd-shutdownd.servicecloud-init.service initrd-switch-root.target remote-fs.target sshd.socket systemd-shutdownd.socketconsole-getty.service initrd.target rescue.service suspend.target systemd-suspend.serviceconsole-shell.service initrd.target.wants rescue.target swap.target systemd-sysctl.servicecontainer-getty@.service initrd-udevadm-cleanup-db.service rescue.target.wants sys-fs-fuse-connections.mount systemd-timedated.servicecpupower.service irqbalance.service rhel-autorelabel-mark.service sysinit.target systemd-tmpfiles-clean.servicecrond.service kdump.service rhel-autorelabel.service sysinit.target.wants systemd-tmpfiles-clean.timercryptsetup-pre.target kexec.target rhel-configure.service sys-kernel-config.mount systemd-tmpfiles-setup-dev.servicecryptsetup.target kmod-static-nodes.service rhel-dmesg.service sys-kernel-debug.mount systemd-tmpfiles-setup.servicectrl-alt-del.target local-fs-pre.target rhel-domainname.service syslog.socket systemd-udevd-control.socketdbus-org.freedesktop.hostname1.service local-fs.target rhel-import-state.service syslog.target.wants systemd-udevd-kernel.socketdbus-org.freedesktop.import1.service local-fs.target.wants rhel-loadmodules.service sysstat.service systemd-udevd.servicedbus-org.freedesktop.locale1.service machine.slice rhel-readonly.service systemd-ask-password-console.path systemd-udev-settle.servicedbus-org.freedesktop.login1.service machines.target rpcbind.service systemd-ask-password-console.service systemd-udev-trigger.servicedbus-org.freedesktop.machine1.service messagebus.service rpcbind.socket systemd-ask-password-wall.path systemd-update-done.servicedbus-org.freedesktop.timedate1.service microcode.service rpcbind.target systemd-ask-password-wall.service systemd-update-utmp-runlevel.servicedbus.service multi-user.target rpc-gssd.service systemd-backlight@.service systemd-update-utmp.servicedbus.socket multi-user.target.wants rpcgssd.service systemd-binfmt.service systemd-user-sessions.servicedbus.target.wants network-online.target rpcidmapd.service systemd-bootchart.service systemd-vconsole-setup.servicedebug-shell.service network-pre.target rpc_pipefs.target systemd-firstboot.service system.slicedefault.target network.target rpc-rquotad.service systemd-fsck-root.service system-update.targetdefault.target.wants nfs-blkmap.service rpc-statd-notify.service systemd-fsck@.service teamd@.servicedev-hugepages.mount nfs-client.target rpc-statd.service systemd-halt.service timers.targetdev-mqueue.mount nfs-config.service rsyncd.service systemd-hibernate-resume@.service timers.target.wantsdracut-cmdline.service nfs-idmapd.service rsyncd@.service systemd-hibernate.service time-sync.targetdracut-initqueue.service nfs-idmap.service rsyncd.socket systemd-hostnamed.service tmp.mountdracut-mount.service nfs-lock.service rsyslog.service systemd-hwdb-update.service tuned.servicedracut-pre-mount.service nfslock.service runlevel0.target systemd-hybrid-sleep.service umount.targetdracut-pre-pivot.service nfs-mountd.service runlevel1.target systemd-importd.service user.slicedracut-pre-trigger.service nfs-rquotad.service runlevel1.target.wants systemd-initctl.service var-lib-nfs-rpc_pipefs.mountdracut-pre-udev.service nfs-secure.service runlevel2.target systemd-initctl.socket vsftpd.servicedracut-shutdown.service nfs-server.service runlevel2.target.wants systemd-journal-catalog-update.service vsftpd@.serviceemergency.service nfs.service runlevel3.target systemd-journald.service vsftpd.targetemergency.target nfs-utils.service runlevel3.target.wants systemd-journald.socket wpa_supplicant.servicefinal.target nginx.service runlevel4.target systemd-journal-flush.servicefstrim.service nss-lookup.target runlevel4.target.wants systemd-kexec.service
- These are all the files, installed with the installation of server
- Let’s take a look at a simple example
# cat vsftpd.service[Unit]Description=Vsftpd ftp daemonAfter=network.target [Service]Type=forkingExecStart=/usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf <---------[Install]WantedBy=multi-user.target
- Don't worry about all the other parameters and pay attention to how we are starting vsftpd service
- If as an administrator you want to make changes to the unit file, go to /etc/systemd/system
# cd /etc/systemd/system
# lsbasic.target.wants default.target.wants getty.target.wants multi-user.target.wants sockets.target.wants system-update.target.wantsdefault.target dev-virtio\x2dports-org.qemu.guest_agent.0.device.wants local-fs.target.wants remote-fs.target.wants sysinit.target.wants tmp.mount
Systemd Targets
- Targets are basically a collection of Systemd units
- If you want to look at the default targets
# cd /usr/lib/systemd/system
# ls *targetbasic.target emergency.target hybrid-sleep.target local-fs.target nss-lookup.target remote-fs-pre.target runlevel2.target sleep.target sysinit.targetbluetooth.target final.target initrd-fs.target machines.target nss-user-lookup.target remote-fs.target runlevel3.target slices.target system-update.targetcloud-config.target getty-pre.target initrd-root-fs.target multi-user.target paths.target rescue.target runlevel4.target smartcard.target timers.targetcryptsetup-pre.target getty.target initrd-switch-root.target network-online.target poweroff.target rpcbind.target runlevel5.target sockets.target time-sync.targetcryptsetup.target graphical.target initrd.target network-pre.target printer.target rpc_pipefs.target runlevel6.target sound.target umount.targetctrl-alt-del.target halt.target kexec.target network.target reboot.target runlevel0.target shutdown.target suspend.target vsftpd.targetdefault.target hibernate.target local-fs-pre.target nfs-client.target remote-cryptsetup.target runlevel1.target sigpwr.target swap.target
- If you open any one of these targets, you will see runlevel1.target requires other things which are group together(Requires=sysinit.target rescue.service)
# cat runlevel1.target# This file is part of systemd.## systemd is free software; you can redistribute it and/or modify it# under the terms of the GNU Lesser General Public License as published by# the Free Software Foundation; either version 2.1 of the License, or# (at your option) any later version.[Unit]Description=Rescue ModeDocumentation=man:systemd.special(7)Requires=sysinit.target rescue.serviceAfter=sysinit.target rescue.serviceAllowIsolate=yes[Install]Alias=kbrequest.target
- If you dig further you will see the comparison with runlevels
# ls -ld runlevel*lrwxrwxrwx. 1 root root 15 Jan 28 12:53 runlevel0.target -> poweroff.targetlrwxrwxrwx. 1 root root 13 Jan 28 12:53 runlevel1.target -> rescue.targetdrwxr-xr-x. 2 root root 50 Jan 28 12:53 runlevel1.target.wantslrwxrwxrwx. 1 root root 17 Jan 28 12:53 runlevel2.target -> multi-user.targetdrwxr-xr-x. 2 root root 50 Jan 28 12:53 runlevel2.target.wantslrwxrwxrwx. 1 root root 17 Jan 28 12:53 runlevel3.target -> multi-user.targetdrwxr-xr-x. 2 root root 50 Jan 28 12:53 runlevel3.target.wantslrwxrwxrwx. 1 root root 17 Jan 28 12:53 runlevel4.target -> multi-user.targetdrwxr-xr-x. 2 root root 50 Jan 28 12:53 runlevel4.target.wantslrwxrwxrwx. 1 root root 16 Jan 28 12:53 runlevel5.target -> graphical.targetdrwxr-xr-x. 2 root root 50 Jan 28 12:53 runlevel5.target.wantslrwxrwxrwx. 1 root root 13 Jan 28 12:53 runlevel6.target -> reboot.target
- eg: runlevel0.target is for poweroff and runlevel5.target is for graphical mode etc..
- Now when working with targets the important point to remember that targets will depend on each other
# systemctl list-dependencies graphical.target |grep -i targetgraphical.target● └─multi-user.target● ├─basic.target● │ ├─selinux-policy-migrate-local-changes@targeted.service● │ ├─paths.target● │ ├─slices.target● │ ├─sockets.target● │ ├─sysinit.target● │ │ ├─cryptsetup.target● │ │ ├─local-fs.target● │ │ └─swap.target● │ └─timers.target● ├─getty.target● ├─nfs-client.target● │ └─remote-fs-pre.target● └─remote-fs.target● └─nfs-client.target● └─remote-fs-pre.target
- To list out all the targets in the system
# systemctl list-units --type=target --allUNIT LOAD ACTIVE SUB DESCRIPTIONbasic.target loaded active active Basic Systemcloud-config.target loaded active active Cloud-config availabilitycryptsetup.target loaded active active Local Encrypted Volumesemergency.target loaded inactive dead Emergency Modefinal.target loaded inactive dead Final Step● firewalld.target not-found inactive dead firewalld.targetgetty-pre.target loaded inactive dead Login Prompts (Pre)getty.target loaded active active Login Promptsgraphical.target loaded inactive dead Graphical Interfacelocal-fs-pre.target loaded active active Local File Systems (Pre)local-fs.target loaded active active Local File Systemsmulti-user.target loaded active active Multi-User Systemnetwork-online.target loaded active active Network is Onlinenetwork-pre.target loaded active active Network (Pre)network.target loaded active active Networknfs-client.target loaded active active NFS client servicesnss-lookup.target loaded inactive dead Host and Network Name Lookupsnss-user-lookup.target loaded inactive dead User and Group Name Lookupspaths.target loaded active active Pathsremote-fs-pre.target loaded active active Remote File Systems (Pre)remote-fs.target loaded active active Remote File Systemsrescue.target loaded inactive dead Rescue Moderpc_pipefs.target loaded active active rpc_pipefs.targetrpcbind.target loaded active active RPC Port Mappershutdown.target loaded inactive dead Shutdownslices.target loaded active active Slicessockets.target loaded active active Socketsswap.target loaded active active Swapsysinit.target loaded active active System Initialization● syslog.target not-found inactive dead syslog.targettime-sync.target loaded inactive dead System Time Synchronizedtimers.target loaded active active Timersumount.target loaded inactive dead Unmount All FilesystemsLOAD = Reflects whether the unit definition was properly loaded.ACTIVE = The high-level unit activation state, i.e. generalization of SUB.SUB = The low-level unit activation state, values depend on unit type.33 loaded units listed.To show all installed unit files use 'systemctl list-unit-files'.
- To find out the default target
# systemctl get-defaultgraphical.target
- To change it some other target
# systemctl set-default multi-user.targetRemoved symlink /etc/systemd/system/default.target.Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/multi-user.target.
- To get the list of all the services via systemd
# systemctl --type=serviceUNIT LOAD ACTIVE SUB DESCRIPTIONauditd.service loaded active running Security Auditing Servicechronyd.service loaded active running NTP client/servercloud-config.service loaded active exited Apply the settings specified in cloud-configcloud-final.service loaded active exited Execute cloud user/final scriptscloud-init-local.service loaded active exited Initial cloud-init job (pre-networking)cloud-init.service loaded active exited Initial cloud-init job (metadata service crawler)crond.service loaded active running Command Schedulerdbus.service loaded active running D-Bus System Message Busgetty@tty1.service loaded active running Getty on tty1gssproxy.service loaded active running GSSAPI Proxy Daemonhttpd.service loaded active running The Apache HTTP Serverjenkins.service loaded active running LSB: Jenkins Automation Server● kdump.service loaded failed failed Crash recovery kernel armingkmod-static-nodes.service loaded active exited Create list of required static device nodes for the current kernelnetwork.service loaded active running LSB: Bring up/down networkingpolkit.service loaded active running Authorization Managerpostfix.service loaded active running Postfix Mail Transport Agentrhel-dmesg.service loaded active exited Dump dmesg to /var/log/dmesgrhel-domainname.service loaded active exited Read and set NIS domainname from /etc/sysconfig/networkrhel-import-state.service loaded active exited Import network configuration from initramfsrhel-readonly.service loaded active exited Configure read-only root supportrpcbind.service loaded active running RPC bind servicersyslog.service loaded active running System Logging Serviceserial-getty@ttyS0.service loaded active running Serial Getty on ttyS0sshd.service loaded active running OpenSSH server daemonsystemd-journal-flush.service loaded active exited Flush Journal to Persistent Storagesystemd-journald.service loaded active running Journal Servicesystemd-logind.service loaded active running Login Servicesystemd-random-seed.service loaded active exited Load/Save Random Seedsystemd-remount-fs.service loaded active exited Remount Root and Kernel File Systemssystemd-sysctl.service loaded active exited Apply Kernel Variablessystemd-tmpfiles-setup-dev.service loaded active exited Create Static Device Nodes in /devsystemd-tmpfiles-setup.service loaded active exited Create Volatile Files and Directoriessystemd-udev-trigger.service loaded active exited udev Coldplug all Devicessystemd-udevd.service loaded active running udev Kernel Device Managersystemd-update-utmp.service loaded active exited Update UTMP about System Boot/Shutdownsystemd-user-sessions.service loaded active exited Permit User Sessionssystemd-vconsole-setup.service loaded active exited Setup Virtual Consoletuned.service loaded active running Dynamic System Tuning DaemonLOAD = Reflects whether the unit definition was properly loaded.ACTIVE = The high-level unit activation state, i.e. generalization of SUB.SUB = The low-level unit activation state, values depend on unit type.39 loaded units listed. Pass --all to see loaded but inactive units, too.To show all installed unit files use 'systemctl list-unit-files'.
- If you are looking for a concise view(this is equivalent to chkconfig — list command)
# systemctl list-unit-files --type=serviceUNIT FILE STATEarp-ethers.service disabledauditd.service enabledauth-rpcgss-module.service staticautovt@.service enabledblk-availability.service disabledbrandbot.service staticchrony-dnssrv@.service staticchrony-wait.service disabledchronyd.service enabledcloud-config.service enabledcloud-final.service enabledcloud-init-local.service enabledcloud-init.service enabledconsole-getty.service disabledconsole-shell.service disabledcontainer-getty@.service staticcpupower.service disabledcrond.service enableddbus-org.freedesktop.hostname1.service staticdbus-org.freedesktop.import1.service staticdbus-org.freedesktop.locale1.service staticdbus-org.freedesktop.login1.service staticdbus-org.freedesktop.machine1.service staticdbus-org.freedesktop.timedate1.service staticdbus.service staticdebug-shell.service disableddracut-cmdline.service staticdracut-initqueue.service staticdracut-mount.service staticdracut-pre-mount.service staticdracut-pre-pivot.service staticdracut-pre-trigger.service staticdracut-pre-udev.service staticdracut-shutdown.service staticemergency.service staticfstrim.service staticgetty@.service enabledgssproxy.service disabledhalt-local.service statichtcacheclean.service statichttpd.service enabledinitrd-cleanup.service staticinitrd-parse-etc.service staticinitrd-switch-root.service staticinitrd-udevadm-cleanup-db.service staticirqbalance.service enabledkdump.service enabledkmod-static-nodes.service staticmessagebus.service staticmicrocode.service enablednfs-blkmap.service disablednfs-config.service staticnfs-idmap.service staticnfs-idmapd.service staticnfs-lock.service staticnfs-mountd.service staticnfs-rquotad.service disablednfs-secure.service staticnfs-server.service disablednfs-utils.service static
- To check the status of any service
# systemctl status httpd● httpd.service - The Apache HTTP ServerLoaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)Active: inactive (dead) since Thu 2019-04-18 22:01:42 PDT; 2s agoDocs: man:httpd(8)man:apachectl(8)Process: 15963 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=0/SUCCESS)Process: 410 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=0/SUCCESS)Main PID: 410 (code=exited, status=0/SUCCESS)Status: "Total requests: 137; Current requests/sec: 0; Current traffic: 0 B/sec"Apr 18 22:01:41 ip-172-31-31-68.us-west-2.compute.internal systemd[1]: Stopping The Apache HTTP Server...Apr 18 22:01:42 ip-172-31-31-68.us-west-2.compute.internal systemd[1]: Stopped The Apache HTTP Server.
- To start/stop any service
# systemctl start httpd
# systemctl stop httpd
- To make sure it enable/disable at reboot
# systemctl enable httpd
# systemctl disable httpd
- To list out the dependency of a particular service
# systemctl list-dependencies httpdhttpd.service● ├─-.mount● ├─system.slice● └─basic.target● ├─microcode.service● ├─rhel-dmesg.service● ├─selinux-policy-migrate-local-changes@targeted.service● ├─paths.target● ├─slices.target● │ ├─-.slice● │ └─system.slice● ├─sockets.target● │ ├─dbus.socket● │ ├─rpcbind.socket● │ ├─systemd-initctl.socket● │ ├─systemd-journald.socket● │ ├─systemd-shutdownd.socket● │ ├─systemd-udevd-control.socket● │ └─systemd-udevd-kernel.socket● ├─sysinit.target● │ ├─dev-hugepages.mount● │ ├─dev-mqueue.mount● │ ├─kmod-static-nodes.service● │ ├─proc-sys-fs-binfmt_misc.automount● │ ├─rhel-autorelabel.service● │ ├─rhel-domainname.service● │ ├─rhel-import-state.service● │ ├─rhel-loadmodules.service● │ ├─sys-fs-fuse-connections.mount● │ ├─sys-kernel-config.mount● │ ├─sys-kernel-debug.mount● │ ├─systemd-ask-password-console.path● │ ├─systemd-binfmt.service● │ ├─systemd-firstboot.service● │ ├─systemd-hwdb-update.service● │ ├─systemd-journal-catalog-update.service● │ ├─systemd-journal-flush.service● │ ├─systemd-journald.service● │ ├─systemd-machine-id-commit.service● │ ├─systemd-modules-load.service● │ ├─systemd-random-seed.service● │ ├─systemd-sysctl.service● │ ├─systemd-tmpfiles-setup-dev.service● │ ├─systemd-tmpfiles-setup.service● │ ├─systemd-udev-trigger.service● │ ├─systemd-udevd.service● │ ├─systemd-update-done.service● │ ├─systemd-update-utmp.service● │ ├─systemd-vconsole-setup.service● │ ├─cryptsetup.target● │ ├─local-fs.target● │ │ ├─-.mount● │ │ ├─rhel-readonly.service● │ │ └─systemd-remount-fs.service● │ └─swap.target● └─timers.target● └─systemd-tmpfiles-clean.timer
- Let discuss the important feature called Cgroups
- Cgroups allow you to allocate resources — such as CPU time, system memory, network bandwidth, or combinations of these resources — among user-defined groups of tasks (processes) running on a system
# mount |grep -i cgrouptmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd)cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_prio,net_cls)cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpuacct,cpu)cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb)cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)cgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,pids)cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
- Now in our use case, I want to restrict Apache to only use 500MB of memory
cd /etc/systemd/system
# Create a file
# cat httpd.service.include /usr/lib/systemd/system/httpd.service[Service]MemoryLimit=500M# As we made changes to Unit file this is required# systemctl daemon-reload# systemctl restart httpd# systemctl status httpd● httpd.service - The Apache HTTP ServerLoaded: loaded (/etc/systemd/system/httpd.service; enabled; vendor preset: disabled)Active: active (running) since Thu 2019-04-18 22:15:06 PDT; 2s agoDocs: man:httpd(8)man:apachectl(8)Process: 16580 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=0/SUCCESS)Main PID: 16585 (httpd)Status: "Processing requests..."Memory: 2.9M (limit: 500.0M)CGroup: /system.slice/httpd.service├─16585 /usr/sbin/httpd -DFOREGROUND├─16586 /usr/sbin/httpd -DFOREGROUND├─16587 /usr/sbin/httpd -DFOREGROUND├─16588 /usr/sbin/httpd -DFOREGROUND├─16589 /usr/sbin/httpd -DFOREGROUND└─16590 /usr/sbin/httpd -DFOREGROUNDApr 18 22:15:06 ip-172-31-31-68.us-west-2.compute.internal systemd[1]: Stopped The Apache HTTP Server.Apr 18 22:15:06 ip-172-31-31-68.us-west-2.compute.internal systemd[1]: Starting The Apache HTTP Server...Apr 18 22:15:06 ip-172-31-31-68.us-west-2.compute.internal systemd[1]: Started The Apache HTTP Server.
Mounting FileSystem using Systemd
- If we look at the /etc/fstab file, it becomes too short nowadays
# cat /etc/fstab## /etc/fstab# Created by anaconda on Mon Jan 28 20:51:49 2019## Accessible filesystems, by reference, are maintained under '/dev/disk'# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info#UUID=f41e390f-835b-4223-a9bb-9b45984ddf8d / xfs defaults 0 0
- One of the reasons for that, all the previous mounts which were handled by fstab earlier is now handled by Systemd
# cd /usr/lib/systemd/system
# ls *mountdev-hugepages.mount proc-fs-nfsd.mount proc-sys-fs-binfmt_misc.mount sys-kernel-config.mount tmp.mountdev-mqueue.mount proc-sys-fs-binfmt_misc.automount sys-fs-fuse-connections.mount sys-kernel-debug.mount var-lib-nfs-rpc_pipefs.mount
- If you open any of the files
# cat tmp.mount# This file is part of systemd.## systemd is free software; you can redistribute it and/or modify it# under the terms of the GNU Lesser General Public License as published by# the Free Software Foundation; either version 2.1 of the License, or# (at your option) any later version.[Unit]Description=Temporary DirectoryDocumentation=man:hier(7)Documentation=http://www.freedesktop.org/wiki/Software/systemd/APIFileSystemsConditionPathIsSymbolicLink=!/tmpDefaultDependencies=noConflicts=umount.targetBefore=local-fs.target umount.target[Mount]What=tmpfsWhere=/tmpType=tmpfsOptions=mode=1777,strictatime# Make 'systemctl enable tmp.mount' work:[Install]WantedBy=local-fs.target
- The important section is
* What to mount
* Where to mount
* Type of filesystem
* Options you can pass to this mount
Looking forward from you guys to join this journey and spend a minimum an hour every day for the next 100 days on DevOps work and post your progress using any of the below medium.
- Twitter: @100daysofdevops OR @lakhera2015
- Facebook: https://www.facebook.com/groups/795382630808645/
- Medium: https://medium.com/@devopslearning
- Slack: https://devops-myworld.slack.com/messages/CF41EFG49/
- GitHub Link:https://github.com/100daysofdevops
Reference