• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

UnixArena

  • Home
  • kubernetes
  • DevOps
    • Terraform
    • Jenkins
    • Docker
    • Openshift
      • OKD
    • Ansible engine
    • Ansible Tower
      • AWX
    • Puppet
  • Cloud
    • Azure
    • AWS
    • Openstack
    • Docker
  • VMware
    • vCloud Director
    • VMware-Guests
    • Vcenter Appliance 5.5
    • vC OPS
    • VMware SDDC
    • VMware vSphere 5.x
      • vSphere Network
      • vSphere DS
      • vShield Suite
    • VMware vSphere 6.0
    • VSAN
    • VMware Free Tools
  • Backup
    • Vembu BDR
    • Veeam
    • Nakivo
    • Azure Backup
    • Altaro VMBackup
    • Spinbackup
  • Tutorials
    • Openstack Tutorial
    • Openstack Beginner’s Guide
    • VXVM-Training
    • ZFS-Tutorials
    • NetApp cDot
    • LVM
    • Cisco UCS
    • LDOM
    • Oracle VM for x86
  • Linux
    • How to Articles
    • Q&A
    • Networking
    • RHEL7
  • DevOps Instructor-led Training
  • Contact

Redhat Enterprise Linux 7 – systemd targets

April 18, 2015 By Cloud_Devops 2 Comments

Redhat Enterprise Linux 7 ‘s booting process also modified lot when you compare to the earlier versions. Instead of grub ,we have grub2 in RHEL 7  to boot the system. The boot loader loads the configured kernel and initramfs from disk to memory. An initramfs  is a gzip-ed cpio archive containing kernel modules for all hardware which required at boot, init scripts and more.  initramfs can be configured in /etc/dracut.conf.

systemctl command can also be used to reboot , powoer-off the system.

Systemd Target:

In Redhat Enterprise Linux 7 , init run levels are replaced by systemd targets.  Still init commands are available , but  in the back-end , it calls the systemd targets to bring the system in to the certain targets .

Target Purpose
graphical.target System  supports multiple users,graphiacal and text-based logins
multi-user.target System  supports multiple users, text-based logins only
rescue.target sulogin prompt,basic system initialization completed
emergency.target sulogin prompt,initramfs pivot complete and system root mounted on /read-only

1. Check the default systemd.target.  (checking default runlevel).

[root@server1-UA ~]#systemctl get-default
multi-user.target
[root@server1-UA ~]#

2.Check the current systemd target(who -r )

[root@server1-UA ~]#systemctl list-units --type=target |grep active |egrep "graphical|multi|resuce|emergency"
multi-user.target   loaded active active Multi-User System
[root@server1-UA ~]#
[root@server1-UA ~]#who -r
         run-level 3  2015-04-18 03:42                   last=5
[root@server1-UA ~]#

3.Change the systemd target to graphical.target (switching to init 5).

[root@server1-UA ~]#systemctl isolate graphical.target
[root@server1-UA ~]#systemctl list-units --type=target |grep active |egrep "graphical|multi|resuce|emergency"
graphical.target    loaded active active Graphical Interface
multi-user.target   loaded active active Multi-User System
[root@server1-UA ~]#who -r
         run-level 5  2015-04-18 03:46                   last=3
[root@server1-UA ~]#

Note: One “systemd target” can be part of another “systemd target”. For an example, graphical systemd target includes multi-user.target and multi-user.target depends on various other targets. You can check the systemd targets dependencies using systemctl list-dependencies command.

Let me check the dependencies for systemd target .

[root@server1-UA ~]#systemctl list-dependencies multi-user.target |grep target
multi-user.target
├─basic.target
│ ├─paths.target
│ ├─slices.target
│ ├─sockets.target
│ ├─sysinit.target
│ │ ├─cryptsetup.target
│ │ ├─local-fs.target
│ │ └─swap.target
│ └─timers.target
├─getty.target
├─nfs.target
└─remote-fs.target
[root@server1-UA ~]#

Here is the available systemd targets on the system.

[root@server1-UA ~]#systemctl list-units --type=target
UNIT                LOAD   ACTIVE SUB    DESCRIPTION
basic.target        loaded active active Basic System
cryptsetup.target   loaded active active Encrypted Volumes
getty.target        loaded active active Login Prompts
graphical.target    loaded active active Graphical Interface
local-fs-pre.target loaded active active Local File Systems (Pre)
local-fs.target     loaded active active Local File Systems
multi-user.target   loaded active active Multi-User System
network.target      loaded active active Network
nfs.target          loaded active active Network File System Server
paths.target        loaded active active Paths
remote-fs.target    loaded active active Remote File Systems
slices.target       loaded active active Slices
sockets.target      loaded active active Sockets
swap.target         loaded active active Swap
sysinit.target      loaded active active System Initialization
timers.target       loaded active active Timers

LOAD   = 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.

16 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.
[root@server1-UA ~]#

4.Set the graphical.target as a default target . (Setting default run-level as 5 ).

[root@server1-UA ~]#systemctl set-default graphical.target
rm '/etc/systemd/system/default.target'
ln -s '/usr/lib/systemd/system/graphical.target' '/etc/systemd/system/default.target'
[root@server1-UA ~]#systemctl get-default
graphical.target
[root@server1-UA ~]#

5.Rebooting the system using systemctl. Since we set the default systemd target as “graphical target” , system should come up with that target.

[root@server1-UA ~]#systemctl reboot
Connection to server1 closed by remote host.
Connection to server1 closed.

6.Check the systemd target, once the system is up .

[root@server1-UA ~]#systemctl list-units --type=target |grep active |egrep "graphical|multi|resuce|emergency"
graphical.target    loaded active active Graphical Interface
multi-user.target   loaded active active Multi-User System
[root@server1-UA ~]#

7.If you would like to boot the system with specific target from the grub menu, please follow the below steps.Here I have shown that how to boot the system in to rescue mode.

  • Interrupt the boot loader grub menu count down by pressing escape key .

grub2 menu

  • Use the arrow keys to scroll down and find the line which starts with linux16. press “end” key to reach the end of the line.
grub2 menu
grub2 menu
  • Append “systemd.unit=rescue.target
resuce.target
resuce.target
  • Press control-X to boot with these changes.

Here you can see that system has been booted in to the rescue mode.

[  OK  ] Reached target System Initialization.
         Starting Rescue Shell...
[  OK  ] Started Rescue Shell.
[  OK  ] Reached target Rescue Mode.
Welcome to rescue mode! Type "systemctl default" or ^D to enter default mode.
Type "journalctl -xb" to view system logs. Type "systemctl reboot" to reboot.
Give root password for maintenance

Use the systemcctl command to list the target status.

[root@server1 ~]# systemctl list-units --type=target -all
UNIT                   LOAD   ACTIVE   SUB    DESCRIPTION
basic.target           loaded inactive dead   Basic System
cryptsetup.target      loaded active   active Encrypted Volumes
emergency.target       loaded inactive dead   Emergency Mode
final.target           loaded inactive dead   Final Step
getty.target           loaded inactive dead   Login Prompts
graphical.target       loaded inactive dead   Graphical Interface
local-fs-pre.target    loaded active   active Local File Systems (Pre)
local-fs.target        loaded active   active Local File Systems
multi-user.target      loaded inactive dead   Multi-User System
network-online.target  loaded inactive dead   Network is Online
network.target         loaded inactive dead   Network
nfs.target             loaded inactive dead   Network File System Server
nss-lookup.target      loaded inactive dead   Host and Network Name Lookups
nss-user-lookup.target loaded inactive dead   User and Group Name Lookups
paths.target           loaded inactive dead   Paths
remote-fs-pre.target   loaded inactive dead   Remote File Systems (Pre)
remote-fs.target       loaded inactive dead   Remote File Systems
rescue.target          loaded active   active Rescue Mode
shutdown.target        loaded inactive dead   Shutdown
slices.target          loaded inactive dead   Slices
sockets.target         loaded inactive dead   Sockets
swap.target            loaded active   active Swap
sysinit.target         loaded active   active System Initialization
syslog.target          not-found inactive dead   syslog.target
time-sync.target       loaded inactive dead   System Time Synchronized
timers.target          loaded inactive dead   Timers
umount.target          loaded inactive dead   Unmount All Filesystems

LOAD   = 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.

27 loaded units listed.
To show all installed unit files use 'systemctl list-unit-files'.
[root@server1 ~]#

If you would like to see the targets which are currently active, use the below command.

roott@server1 ~]# systemctl list-units --type=target -all |grep active |grep -v dead
cryptsetup.target      loaded active   active Encrypted Volumes
local-fs-pre.target    loaded active   active Local File Systems (Pre)
local-fs.target        loaded active   active Local File Systems
rescue.target          loaded active   active Rescue Mode
swap.target            loaded active   active Swap
sysinit.target         loaded active   active System Initialization
[root@server1 ~]#

The above commands confirms that system has been booted into the rescue mode.

System can be bring in to any new target by using systemctl isolate command.

[root@server1 ~]# systemctl isolate multi-user.target
[  991.464879] type=1305 audit(1429346862.537:3): audit_pid=488 old=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:auditd_t:s0 res=1
[  991.669108] systemd-journald[372]: Received request to flush runtime journal from PID 1
[  991.795015] Installing knfsd (copyright (C) 1996 okir@monad.swb.de).
[  996.829590] systemd-journald[372]: Received request to flush runtime journal from PID 1
netcf-transaction.sh[581]: Running  start: No pending transaction to rollback
[  999.417764] ip_tables: (C) 2000-2006 Netfilter Core Team
[  999.870080] nf_conntrack version 0.5.0 (5793 buckets, 23172 max)
[ 1000.072606] ip6_tables: (C) 2000-2006 Netfilter Core Team
[ 1000.643220] Ebtables v2.0 registered
[ 1000.873726] Bridge firewalling registered

server1 login:root
password:
[root@server1-UA ~]#

Hope this article is informative to you .

Share it ! Comment it !! Be sociable !!!

Filed Under: RHEL7 Tagged With: RHEL7

Reader Interactions

Comments

  1. Krishna says

    February 6, 2017 at 5:57 pm

    after changing the rescue mode, i am unable to changing the multi-user.target

    Reply
  2. darkfader says

    October 5, 2016 at 10:02 pm

    So they fried the emengency target, with used to put you right in the initrd.
    It’s the one you could use if all you had left was the kernel and the initrd, and fix your system from there and then boot up without even a final reboot.

    So glad we have these competent people at the steering wheel now.
    – Failed to grasp what it did
    – Failed to copy it
    – Failed to notice there’s a gap in functionality
    – Failed to notice the other guys had done all the fucking work for them

    These guys can be so happy the GPL protects them from being liable for their recklessness.

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Follow UnixArena

  • Facebook
  • LinkedIn
  • Twitter

Copyright © 2025 · UnixArena ·

Go to mobile version