CT320: Network and System Administration

Fall 2019

Booting

Show Lecture.Booting as a slide show.

CT320 Booting

Colorado State University
Computer Science Department

Original slides from Dr. James Walden at Northern Kentucky University.

Topics

  1. Booting
  2. Bootstrap loaders
  3. Run levels
  4. Startup system
  5. Shutdown and reboot

Booting

  1. ROM boot code (BIOS in PCs)
  2. Master Boot Record (MBR)
  3. Bootloader
  4. Kernel
  5. Hardware detection and configuration
  6. Creation of system processes
  7. Multiuser operation

BIOS

MBR

Bootloader: GRUB

GRUB Boot

Booting with GRUB

GRUB Config

My /etc/default/grub:

    GRUB_DEFAULT=0
    GRUB_HIDDEN_TIMEOUT_QUIET=true
    GRUB_TIMEOUT=4
    GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
    GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
    GRUB_CMDLINE_LINUX=""

Edit, then update-grub.

How can GRUB_DISTRUBTOR possibly do shell stuff at boot-time?!

GRUB Naming Convention

Kernel

Kernel Arguments

Numeric arguments

Root device options

Kernel Arguments (continued)

Console options

Hardware options

See bootparam for many more.

Getting it all going

There has to be an initial process that gets things going. It must:

Historically, Linux systems have used the System V init to accomplish this.

What's wrong with init?

Competition

made at imgflip.com

init has several competitors, including:

systemd is quite popular, and quite controversial. It is now the default startup mechanism for Debian, Fedora, Red Hat, SUSE, and Ubuntu. We will discuss only systemd.

Service Cheatsheet

CommandPurpose
systemctl start nameStart a service right now.
systemctl stop nameStop a service right now.
systemctl restart nameRestart a service (stop+start).
systemctl reload nameReload configuration (config file changed).
systemctl status nameHow’s it going?
systemctl enable nameStart this service at each boot.
systemctl disable nameDo not start service at each boot.
systemctl is-active nameWhat services are active?
systemctl list-units --type service --allWhat services exist?

Targets in systemd

Old init RunlevelSystemd TargetDescription
0poweroff.targetHalt the system.
1, s, singlerescue.targetSingle user mode
3multi-user.targetMulti-user, non-graphical
login via console or the network
5graphical.targetSame as previous plus graphical login
6reboot.targetReboot
 emergency.targetEmergency shell

Switch to a different target: systemctl isolate name

What if single user mode doesn’t work?

It’s all systemd

$ PATH=/sbin:/bin:/usr/bin
$ type -p shutdown halt poweroff reboot
/sbin/shutdown
/sbin/halt
/sbin/poweroff
/sbin/reboot
$ ls -l $(type -p shutdown halt poweroff reboot)
lrwxrwxrwx 1 root root 16 Sep 23 20:25 /sbin/halt -> ../bin/systemctl
lrwxrwxrwx 1 root root 16 Sep 23 20:25 /sbin/poweroff -> ../bin/systemctl
lrwxrwxrwx 1 root root 16 Sep 23 20:25 /sbin/reboot -> ../bin/systemctl
lrwxrwxrwx 1 root root 16 Sep 23 20:25 /sbin/shutdown -> ../bin/systemctl

Example systemd .service file

/usr/lib/systemd/system/crond.service:

    [Unit]
    Description=Command Scheduler
    After=auditd.service nss-user-lookup.target systemd-user-sessions.service time-s
    ync.target ypbind.service

    [Service]
    EnvironmentFile=/etc/sysconfig/crond
    ExecStart=/usr/sbin/crond -n $CRONDARGS
    ExecReload=/bin/kill -HUP $MAINPID
    KillMode=process

    [Install]
    WantedBy=multi-user.target