You are on page 1of 39

Week 4 Unit 1:

SLES Storage Administration


SLES Storage Administration
Linux I/O Stack

Linux storage architecture can be described by the following diagram:

open.sap.com Slide 2
SLES Storage Administration
Partitioning Utilities

There are multiple tools for partition management in SUSE Linux Enterprise Server:
o YaST partitioner module – Graphical or ncurses tool for partitioning, formatting and other block device and
filesystem management
o fdisk – traditional command line tool for manipulating MBR (MSDOS) type partition definitions
o parted – command line tool for MBR and GPT type partitions

open.sap.com Slide 3
SLES Storage Administration
MBR and GPT

• Master Boot Record • Globally Unique Partition Table


o Boot loader (446 bytes) o Protected MBR (512 bytes)
o GPT header (512 bytes)
o Partition table (64 bytes)
o Partition entries (128 bytes
o Magic number (2 bytes) each)
• Limited to 2 TB hard disks • Limited to 9.2 ZB hard disks

open.sap.com Slide 4
SLES Storage Administration
Device Files for Block Devices

• Under MBR (or MSDOS) partition types, partitions are categorized:


o Primary – only 4 primary partitions can exist with MBR
o Extended – a primary partition can be made an extended partition, allowing for multiple sub-partitions
underneath
o Logical – logical partitions are sub-partitions underneath an extended partition.
• Device files under MBR follow a naming routine:
o Primary: /dev/sdx1, /dev/sdx2, /dev/sdx3, etc.
• These are the first, second and third partitions on a scsi device (x)
o Extended: not referenced via a device file since only sub-partitions (logical) are used
o Logical: the first logical partition is /dev/sdx5 as there are only 4 primary partition, so the first logical
partition always begins here
• GPT partitions are all primary partitions and have no special numbering rules

open.sap.com Slide 5
SLES Storage Administration
Supported Filesystems

• Making a filesystem on a partition typically is done with the mkfs.<filesystem> command:


o mkfs.ext4, mkfs.xfs, mkfs.btrfs, etc.
• Filesystems supported in SLES 15:
o Ext2
o Ext3 (default in SLE 11) Traditional Linux filesystems
o Ext4
o XFS (default in SLE 12 and 15 for data partitions)
o Btrfs (default in SLE 12 and 15 for /)
o JFS (existing volumes only)
o NTFS-3G (only in SUSE Linux Enterprise Desktop/Desktop Extension)
o VFAT

From an applications perspective – in most cases – the filesystem does not matter because of Linux’s
use of the Virtual Filesystem Switch (VFS). The VFS makes the filesystem opaque.

open.sap.com Slide 6
SLES Storage Administration
The Virtual Filesystem Switch (VFS)*

* Also referred to as the Virtual File System.

open.sap.com Slide 7
SLES Storage Administration
/etc/fstab

• The /etc/fstab file (file systems table) is the primary configuration file for determining where, how
and when a partition or other storage device is to be mounted on the local system
• There are 6 fields that configure each partition/device
o Field 1: Name, file system label, or UUID
o Field 2: Mount point
o Field 3: Filesystem type
o Field 4: Mount options
o Field 5: Use the dump backup utility?
o Field 6: Sequence of filesystem checks to perform

open.sap.com Slide 8
SLES Storage Administration
Device, Filesystem, and Mounting Utilities

o mount/umount – command line tool for adding or removing a partition from the / (root) filesystem
• Examples of options: remount, rw/ro, sync, atime, user, defaults
o lsblk – list block devices

o blkid – display block IDs and the associated block device files

o df – list free disk space


o du – estimate file space usage
o lsof – list open files
o fuser – display the process IDs (PIDs) of processes using specified files

open.sap.com Slide 9
Copyright © SUSE LLC

© 2019 SUSE LLC. All rights reserved. SUSE and the SUSE logo are registered trademarks of SUSE
LLC in the United States and other countries. All third-party trademarks are the property of their
respective owners.

open.sap.com Slide 10
Thank You!

Contact Information:
open@sap.com
Week 4 Unit 2:
The Shell Environment
The Shell Environment
What is the Shell?

The shell is the most basic user interface to SUSE Linux Enterprise Server.
o Also referred to as the command line interface
There are multiple shells available in SLES, and they are listed in /etc/shells:
o bash (Bourne Again SHell) -> the default shell in SLES
o csh – the c shell
o ksh – the korn shell
o tcsh – an enhanced c shell
o zsh – the z shell
o etc.

open.sap.com Slide 2
The Shell Environment
The Shell Environment

The shell environment is made up of components that can be customized to the user’s preference
using:
o Variables – the most commonly customized part of the shell environment
o Functions – define core functionality of the shell
o Aliases – allow shortcuts to longer, sometimes complex, commands using shorter input
A shell can be invoked in two different ways
o Login shell – the user’s preferred environment (variables, functions and aliases) is set
• A login shell will ask for a username/password
• A login shell can be requested with the --login option when /bin/bash is called
o Non-login shell – the shell inherits an existing environment (from a previously started shell)
• A non-login shell will not ask for username/password (e.g. – a gnome-terminal session)

open.sap.com Slide 3
The Shell Environment
Shell Variables and Settings

Global profiles (all users): Order of execution for login shells:


1) /etc/profile
• /etc/profile 2) /etc/profile.d/*.sh
• /etc/profile.d/*.sh 3) /etc/profile.local
4) ~/.profile
• /etc/profile.local 5) /etc/bash.bashrc
6) /etc/bash_completion.d/*sh
7) /etc/bash.bashrc.local
• /etc/bash.bashrc 8) /etc/inputrc
• /etc/bash_completion.d/*.sh 9) ~/.bashrc
10) ~/.alias
• /etc/bash.bashrc.local
Order of execution for non-login shells
• User specific profiles: 1) /etc/bash.bashrc
• ~/.profile 2) /etc/bash_completion.d/*.sh
• ~/.bashrc 3) /etc/bash.bashrc.local
4) /etc/inputrc
• ~/.alias 5) ~/.bashrc
6) ~/.alias

open.sap.com Slide 4
The Shell Environment
Shell Aliases

A shell alias allows a typed shortcut to longer, more complex, commands using shorter input.
o Define an alias:
alias ALIAS_NAME=“COMMAND”
o Remove an alias:
unalias ALIAS_NAME
o List all defined aliases:
alias
o Alias definition file:
~/.alias

open.sap.com Slide 5
The Shell Environment
Shell History

When a command is entered in a shell, it is stored in the history file of the user who executed it:
o ~/.bash_history
o View the shell history with the history command
• Scroll through the history with the <up-arrow> and <down-arrow> keys
o Search the history for a command that begins with <string>
• <string><PageUp>/<string><PageDown>
o Search history for any <string>, press ctrl+r
• Execute the found item: press Enter
• Change the found item: press Tab
o Re-execute a numbered command from history:
• !<command-number>

open.sap.com Slide 6
The Shell Environment
Tab Auto-Completion

Commands in a shell can be automatically completed if they are unambiguous, or a list of possibilities
can be displayed:

open.sap.com Slide 7
The Shell Environment
Data Channels

open.sap.com Slide 8
The Shell Environment
Channel Redirection

Command Description
> Redirect stdout into a file
Example: ls /etc > /tmp/etc_files.txt
>> Redirect stdout, appending to a file

2> Redirect stderr into a file

2>> Redirect stderr, appending to a file

< Redirect stdin from a file


Example: mail geeko < email_body.txt
| Use stdout from one command as stdin of another
Example: ls /etc | grep samba
tee Redirects stdout to a file and the terminal
Example: <command> | tee <file>

open.sap.com Slide 9
The Shell Environment
Chain Commands Together

Command Description
; Chain multiple commands together on a single command line
Example: echo Hello ; echo How are you?
&& Execute a second command only if the first command returns
no error (return code 0)
Example: grep “swap” /etc/fstab && echo Success
|| Execute a second command if the first command returns an
error (i.e. return a code other than 0)
Example: grep “XXX” /etc/fstab || echo Failure

open.sap.com Slide 10
The Shell Environment
Help Resources

o Command help: <command> -h or <command> --help


o Manual pages: man [section] command
o List for keywords: man –k keyword
o Display descriptions: whatis <command>
o Info pages: info <command>
o Software package documentation in /usr/share/doc/packages/
o Release Notes in /usr/share/doc/release-notes/

open.sap.com Slide 11
Copyright © SUSE LLC

© 2019 SUSE LLC. All rights reserved. SUSE and the SUSE logo are registered trademarks of SUSE
LLC in the United States and other countries. All third-party trademarks are the property of their
respective owners.

open.sap.com Slide 12
Thank You!

Contact Information:
open@sap.com
Week 4 Unit 3:
Process Administration Basics
Process Administration Basics
Process Basics

o Terminology
• Program: Executable code, stored on a drive
• Process: Executable code, copied into RAM for execution
• Task: Synonym for process
o Basic process types:
• User: Associated with a controlling shell or terminal
• Daemon: Not associated with a controlling shell or terminal
o Every process is assigned a unique Process ID (PID)
o Processes can spawn other processes (parent/child relationship)

open.sap.com Slide 2
Process Administration Basics
View Processes

Command Description
Display running processes
ps Common options:
aux All processes, with user list
-ef All processes, full-format with CLI
Display running processes with their parent/child
pstree relationships
Common options:
-p Add PIDs to the output
top Display processes, sorted by usage and refreshed at an
interval

open.sap.com Slide 3
Process Administration Basics
Manage Processes
Command Description
kill <PID> [signal] Sends a signal to a specific PID
killall <process_name> [signal] Sends a signal to all processes with a specified name
(e.g. killall firefox TERM)
No. Signal Description No. Signal Description
1 HUP Hangup 11 SEGV Segmentation fault
2 INT Interrupt
12 USR2 User defined
3 QUIT Quit
4 ILL Illegal instruction
13 PIPE Broken pipe
5 TRAP Trace 14 ALRM Alarm clock
6 ABRT Aborted 15 TERM Terminated
7 BUS Bus error 16 STKFLT Stack fault
8 FPE Floating point exception 17 CHLD Child exited
9 KILL Killed 18 CONT Continued
10 USR1 User defined 19 STOP Stopped
open.sap.com Slide 4
Process Administration Basics
Process Priority

o The relative process priority range is from 19 to -20


• -20 is the highest relative priority (a not-nice task has a higher priority)
• 19 is the lowest relative priority (a nice task has a lower priority)

Command Description

nice Launch a task with a specified relative priority


Example: nice 10 xterm

renice Change a running task’s relative priority.


Tasks are specified using their PID
Example: renice -15 –p 2567

open.sap.com Slide 5
Process Administration Basics
Jobs and Processes

o Jobs (processes) can be put into the background to allow continued use of the shell instead of
waiting for each task to finish
• ctrl+z Pause the task
• bg Continues the paused task in the background
o Start a job directly in the background: append “&”
• Example: xeyes &
• jobs – command to view jobs tied to a shell
• fg – bring background tasks into the foreground

open.sap.com Slide 6
Copyright © SUSE LLC

© 2019 SUSE LLC. All rights reserved. SUSE and the SUSE logo are registered trademarks of SUSE
LLC in the United States and other countries. All third-party trademarks are the property of their
respective owners.

open.sap.com Slide 7
Thank You!

Contact Information:
open@sap.com
Week 4 Unit 4:
Process Scheduling
Process Scheduling
Cron Jobs

o Cron jobs are the primary way that SUSE Linux Enterprise Server administrators schedule
tasks to be completed regularly. There are cron jobs for users and for the system.
o User cron jobs are configured via the crontab utility:
Option Description
-e Edit a user’s crontab
-l List a user’s crontab
-r Remove a user’s entire crontab
o There are fields in the crontab entries that represent different time intervals:

open.sap.com Slide 2
Process Scheduling
System Cron Jobs

o System cron jobs are kept in the /etc/crontab file


o System cron jobs include a “who” field to designate which user a task should be run as:

o There are also some predefined directories where tasks can be dropped in for hourly, daily,
weekly, or monthly execution:
• /etc/cron.hourly/
• /etc/cron.daily/
• /etc/cron.weekly/
• /etc/cron.monthly/

open.sap.com Slide 3
Process Scheduling
Cron Architecture

open.sap.com Slide 4
Process Scheduling
The at Daemon

Command Description
at, batch Schedule a task
Ctrl+D exits command input
-f: specify a script file
atq View scheduled tasks for a user
atrm <job_number> Remove a scheduled task

File Description
/etc/at.allow Listed users can define jobs
/etc/at.deny Listed users cannot define jobs

open.sap.com Slide 5
Copyright © SUSE LLC

© 2019 SUSE LLC. All rights reserved. SUSE and the SUSE logo are registered trademarks of SUSE
LLC in the United States and other countries. All third-party trademarks are the property of their
respective owners.

open.sap.com Slide 6
Thank You!

Contact Information:
open@sap.com

You might also like