Red Hat Enterprise Linux 5

Deployment Guide

Deployment, configuration and administration of Red Hat Enterprise Linux 5

Edition 10

Logo

Legal Notice

Copyright © 2007–2013 Red Hat, Inc.
This document is licensed by Red Hat under the Creative Commons Attribution-ShareAlike 3.0 Unported License. If you distribute this document, or a modified version of it, you must provide attribution to Red Hat, Inc. and provide a link to the original. If the document is modified, all Red Hat trademarks must be removed.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, Red Hat Enterprise Linux, the Shadowman logo, JBoss, MetaMatrix, Fedora, the Infinity Logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
Java® is a registered trademark of Oracle and/or its affiliates.
XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
Node.js® is an official trademark of Joyent. Red Hat Software Collections is not formally related to or endorsed by the official Joyent Node.js open source or commercial project.
The OpenStack® Word Mark and OpenStack Logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation's permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.

Abstract

The Deployment Guide documents relevant information regarding the deployment, configuration and administration of Red Hat Enterprise Linux 5.
Introduction
1. Document Conventions
2. Send in Your Feedback
I. File Systems
1. File System Structure
1.1. Why Share a Common Structure?
1.2. Overview of File System Hierarchy Standard (FHS)
1.2.1. FHS Organization
1.3. Special File Locations Under Red Hat Enterprise Linux
2. Using the mount Command
2.1. Listing Currently Mounted File Systems
2.2. Mounting a File System
2.2.1. Specifying the File System Type
2.2.2. Specifying the Mount Options
2.2.3. Sharing Mounts
2.2.4. Moving a Mount Point
2.3. Unmounting a File System
2.4. Additional Resources
2.4.1. Installed Documentation
2.4.2. Useful Websites
3. The ext3 File System
3.1. Features of ext3
3.2. Creating an ext3 File System
3.3. Converting to an ext3 File System
3.4. Reverting to an ext2 File System
4. The ext4 File System
4.1. Features of ext4
4.2. Managing an ext4 File System
4.3. Creating an ext4 File System
4.4. Mounting an ext4 File System
4.5. Resizing an ext4 File System
5. The proc File System
5.1. A Virtual File System
5.1.1. Viewing Virtual Files
5.1.2. Changing Virtual Files
5.1.3. Restricting Access to Process Directories
5.2. Top-level Files within the proc File System
5.2.1. /proc/apm
5.2.2. /proc/buddyinfo
5.2.3. /proc/cmdline
5.2.4. /proc/cpuinfo
5.2.5. /proc/crypto
5.2.6. /proc/devices
5.2.7. /proc/dma
5.2.8. /proc/execdomains
5.2.9. /proc/fb
5.2.10. /proc/filesystems
5.2.11. /proc/interrupts
5.2.12. /proc/iomem
5.2.13. /proc/ioports
5.2.14. /proc/kcore
5.2.15. /proc/kmsg
5.2.16. /proc/loadavg
5.2.17. /proc/locks
5.2.18. /proc/mdstat
5.2.19. /proc/meminfo
5.2.20. /proc/misc
5.2.21. /proc/modules
5.2.22. /proc/mounts
5.2.23. /proc/mtrr
5.2.24. /proc/partitions
5.2.25. /proc/pci
5.2.26. /proc/slabinfo
5.2.27. /proc/stat
5.2.28. /proc/swaps
5.2.29. /proc/sysrq-trigger
5.2.30. /proc/uptime
5.2.31. /proc/version
5.3. Directories within /proc/
5.3.1. Process Directories
5.3.2. /proc/bus/
5.3.3. /proc/driver/
5.3.4. /proc/fs
5.3.5. /proc/ide/
5.3.6. /proc/irq/
5.3.7. /proc/net/
5.3.8. /proc/scsi/
5.3.9. /proc/sys/
5.3.10. /proc/sysvipc/
5.3.11. /proc/tty/
5.3.12. /proc/<PID>/
5.4. Using the sysctl Command
5.5. Additional Resources
5.5.1. Installed Documentation
5.5.2. Useful Websites
6. Redundant Array of Independent Disks (RAID)
6.1. What is RAID?
6.1.1. Who Should Use RAID?
6.1.2. Hardware RAID versus Software RAID
6.1.3. RAID Levels and Linear Support
6.2. Configuring Software RAID
6.2.1. Creating the RAID Partitions
6.2.2. Creating the RAID Devices and Mount Points
6.3. Managing Software RAID
6.3.1. Reviewing RAID Configuration
6.3.2. Creating a New RAID Device
6.3.3. Replacing a Faulty Device
6.3.4. Extending a RAID Device
6.3.5. Removing a RAID Device
6.3.6. Preserving the Configuration
6.4. Additional Resources
6.4.1. Installed Documentation
7. Swap Space
7.1. What is Swap Space?
7.2. Adding Swap Space
7.2.1. Extending Swap on an LVM2 Logical Volume
7.2.2. Creating an LVM2 Logical Volume for Swap
7.2.3. Creating a Swap File
7.3. Removing Swap Space
7.3.1. Reducing Swap on an LVM2 Logical Volume
7.3.2. Removing an LVM2 Logical Volume for Swap
7.3.3. Removing a Swap File
7.4. Moving Swap Space
8. Managing Disk Storage
8.1. Standard Partitions using parted
8.1.1. Viewing the Partition Table
8.1.2. Creating a Partition
8.1.3. Removing a Partition
8.1.4. Resizing a Partition
8.2. LVM Partition Management
9. Implementing Disk Quotas
9.1. Configuring Disk Quotas
9.1.1. Enabling Quotas
9.1.2. Remounting the File Systems
9.1.3. Creating the Quota Database Files
9.1.4. Assigning Quotas per User
9.1.5. Assigning Quotas per Group
9.1.6. Setting the Grace Period for Soft Limits
9.2. Managing Disk Quotas
9.2.1. Enabling and Disabling
9.2.2. Reporting on Disk Quotas
9.2.3. Keeping Quotas Accurate
9.3. Additional Resources
9.3.1. Installed Documentation
9.3.2. Related Books
10. Access Control Lists
10.1. Mounting File Systems
10.1.1. NFS
10.2. Setting Access ACLs
10.3. Setting Default ACLs
10.4. Retrieving ACLs
10.5. Archiving File Systems With ACLs
10.6. Compatibility with Older Systems
10.7. Additional Resources
10.7.1. Installed Documentation
10.7.2. Useful Websites
11. LVM (Logical Volume Manager)
11.1. What is LVM?
11.1.1. What is LVM2?
11.2. LVM Configuration
11.3. Automatic Partitioning
11.4. Manual LVM Partitioning
11.4.1. Creating the /boot Partition
11.4.2. Creating the LVM Physical Volumes
11.4.3. Creating the LVM Volume Groups
11.4.4. Creating the LVM Logical Volumes
11.5. Using the LVM utility system-config-lvm
11.5.1. Utilizing uninitialized entities
11.5.2. Adding Unallocated Volumes to a volume group
11.5.3. Migrating extents
11.5.4. Adding a new hard disk using LVM
11.5.5. Adding a new volume group
11.5.6. Extending a volume group
11.5.7. Editing a Logical Volume
11.6. Additional Resources
11.6.1. Installed Documentation
11.6.2. Useful Websites
II. Package Management
12. Package Management with RPM
12.1. RPM Design Goals
12.2. Using RPM
12.2.1. Finding RPM Packages
12.2.2. Installing
12.2.3. Uninstalling
12.2.4. Upgrading
12.2.5. Freshening
12.2.6. Querying
12.2.7. Verifying
12.3. Checking a Package's Signature
12.3.1. Importing Keys
12.3.2. Verifying Signature of Packages
12.4. Practical and Common Examples of RPM Usage
12.5. Additional Resources
12.5.1. Installed Documentation
12.5.2. Useful Websites
12.5.3. Related Books
13. Package Management Tool
13.1. Listing and Analyzing Packages
13.2. Installing and Removing Packages
14. YUM (Yellowdog Updater Modified)
14.1. Setting Up a Yum Repository
14.2. yum Commands
14.3. yum Options
14.4. Configuring yum
14.4.1. [main] Options
14.4.2. [repository] Options
14.5. Upgrading the System Off-line with ISO and Yum
14.6. Useful yum Variables
15. Registering a System and Managing Subscriptions
15.1. Using Red Hat Subscription Manager Tools
15.1.1. Launching the Red Hat Subscription Manager GUI
15.1.2. Running the subscription-manager Command-Line Tool
15.2. Registering and Unregistering a System
15.2.1. Registering from the GUI
15.2.2. Registering from the Command Line
15.2.3. Unregistering
15.3. Attaching and Removing Subscriptions
15.3.1. Attaching and Removing Subscriptions through the GUI
15.3.2. Attaching and Removing Subscriptions through the Command Line
15.4. Redeeming Vendor Subscriptions
15.4.1. Redeeming Subscriptions through the GUI
15.4.2. Redeeming Subscriptions through the Command Line
15.5. Attaching Subscriptions from a Subscription Asset Manager Activation Key
15.6. Setting Preferences for Systems
15.6.1. Setting Preferences in the UI
15.6.2. Setting Service Levels Through the Command Line
15.6.3. Setting a Preferred Operating System Release Version in the Command Line
15.6.4. Removing a Preference
15.7. Managing Subscription Expiration and Notifications
III. Network-Related Configuration
16. Network Interfaces
16.1. Network Configuration Files
16.2. Interface Configuration Files
16.2.1. Ethernet Interfaces
16.2.2. IPsec Interfaces
16.2.3. Channel Bonding Interfaces
16.2.4. Alias and Clone Files
16.2.5. Dialup Interfaces
16.2.6. Other Interfaces
16.3. Interface Control Scripts
16.4. Static Routes and the Default Gateway
16.5. Network Function Files
16.6. Additional Resources
16.6.1. Installed Documentation
17. Network Configuration
17.1. Overview
17.2. Establishing an Ethernet Connection
17.3. Establishing an ISDN Connection
17.4. Establishing a Modem Connection
17.5. Establishing an xDSL Connection
17.6. Establishing a Token Ring Connection
17.7. Establishing a Wireless Connection
17.8. Managing DNS Settings
17.9. Managing Hosts
17.10. Working with Profiles
17.11. Device Aliases
17.12. Saving and Restoring the Network Configuration
18. Controlling Access to Services
18.1. Runlevels
18.2. TCP Wrappers
18.2.1. xinetd
18.3. Services Configuration Tool
18.4. ntsysv
18.5. chkconfig
18.6. Additional Resources
18.6.1. Installed Documentation
18.6.2. Useful Websites
19. Berkeley Internet Name Domain (BIND)
19.1. Introduction to DNS
19.1.1. Nameserver Zones
19.1.2. Nameserver Types
19.1.3. BIND as a Nameserver
19.2. /etc/named.conf
19.2.1. Common Statement Types
19.2.2. Other Statement Types
19.2.3. Comment Tags
19.3. Zone Files
19.3.1. Zone File Directives
19.3.2. Zone File Resource Records
19.3.3. Example Zone File
19.3.4. Reverse Name Resolution Zone Files
19.4. Using rndc
19.4.1. Configuring /etc/named.conf
19.4.2. Configuring /etc/rndc.conf
19.4.3. Command Line Options
19.5. Advanced Features of BIND
19.5.1. DNS Protocol Enhancements
19.5.2. Multiple Views
19.5.3. Security
19.5.4. IP version 6
19.6. Common Mistakes to Avoid
19.7. Additional Resources
19.7.1. Installed Documentation
19.7.2. Useful Websites
19.7.3. Related Books
20. OpenSSH
20.1. Features of SSH
20.1.1. Why Use SSH?
20.2. SSH Protocol Versions
20.3. Event Sequence of an SSH Connection
20.3.1. Transport Layer
20.3.2. Authentication
20.3.3. Channels
20.4. Configuring an OpenSSH Server
20.4.1. Requiring SSH for Remote Connections
20.5. OpenSSH Configuration Files
20.6. Configuring an OpenSSH Client
20.6.1. Using the ssh Command
20.6.2. Using the scp Command
20.6.3. Using the sftp Command
20.7. More Than a Secure Shell
20.7.1. X11 Forwarding
20.7.2. Port Forwarding
20.7.3. Generating Key Pairs
20.8. Additional Resources
20.8.1. Installed Documentation
20.8.2. Useful Websites
21. Network File System (NFS)
21.1. How It Works
21.1.1. Required Services
21.2. NFS Client Configuration
21.2.1. Mounting NFS File Systems using /etc/fstab
21.3. autofs
21.3.1. What's new in autofs version 5?
21.3.2. autofs Configuration
21.3.3. autofs Common Tasks
21.4. Common NFS Mount Options
21.5. Starting and Stopping NFS
21.6. NFS Server Configuration
21.6.1. Exporting or Sharing NFS File Systems
21.6.2. Command Line Configuration
21.6.3. Running NFS Behind a Firewall
21.6.4. Hostname Formats
21.7. The /etc/exports Configuration File
21.7.1. The exportfs Command
21.8. Securing NFS
21.8.1. Host Access
21.8.2. File Permissions
21.9. NFS and portmap
21.9.1. Troubleshooting NFS and portmap
21.10. Using NFS over TCP
21.11. Additional Resources
21.11.1. Installed Documentation
21.11.2. Useful Websites
21.11.3. Related Books
22. Samba
22.1. Introduction to Samba
22.1.1. Samba Features
22.2. Samba Daemons and Related Services
22.2.1. Samba Daemons
22.3. Connecting to a Samba Share
22.3.1. Command Line
22.3.2. Mounting the Share
22.4. Configuring a Samba Server
22.4.1. Graphical Configuration
22.4.2. Command Line Configuration
22.4.3. Encrypted Passwords
22.5. Starting and Stopping Samba
22.6. Samba Server Types and the smb.conf File
22.6.1. Stand-alone Server
22.6.2. Domain Member Server
22.6.3. Domain Controller
22.7. Samba Security Modes
22.7.1. User-Level Security
22.7.2. Share-Level Security
22.8. Samba Account Information Databases
22.9. Samba Network Browsing
22.9.1. Domain Browsing
22.9.2. WINS (Windows Internetworking Name Server)
22.10. Samba with CUPS Printing Support
22.10.1. Simple smb.conf Settings
22.11. Samba Distribution Programs
22.12. Additional Resources
22.12.1. Installed Documentation
22.12.2. Related Books
22.12.3. Useful Websites
23. Dynamic Host Configuration Protocol (DHCP)
23.1. Why Use DHCP?
23.2. Configuring a DHCP Server
23.2.1. Configuration File
23.2.2. Lease Database
23.2.3. Starting and Stopping the Server
23.2.4. DHCP Relay Agent
23.3. Configuring a DHCP Client
23.4. Configuring a Multihomed DHCP Server
23.4.1. Host Configuration
23.5. Additional Resources
23.5.1. Installed Documentation
24. Migrating from MySQL 5.0 to MySQL 5.5
24.1. Upgrading from MySQL 5.0 to MySQL 5.5
25. Apache HTTP Server
25.1. Apache HTTP Server 2.2
25.1.1. Features of Apache HTTP Server 2.2
25.2. Migrating Apache HTTP Server Configuration Files
25.2.1. Migrating Apache HTTP Server 2.0 Configuration Files
25.2.2. Migrating Apache HTTP Server 1.3 Configuration Files to 2.0
25.3. Starting and Stopping httpd
25.4. Apache HTTP Server Configuration
25.4.1. Basic Settings
25.4.2. Default Settings
25.5. Configuration Directives in httpd.conf
25.5.1. General Configuration Tips
25.5.2. Configuration Directives for SSL
25.5.3. MPM Specific Server-Pool Directives
25.6. Adding Modules
25.7. Virtual Hosts
25.7.1. Setting Up Virtual Hosts
25.8. Apache HTTP Secure Server Configuration
25.8.1. An Overview of Security-Related Packages
25.8.2. An Overview of Certificates and Security
25.8.3. Using Pre-Existing Keys and Certificates
25.8.4. Types of Certificates
25.8.5. Generating a Key
25.8.6. How to configure the server to use the new key
25.9. Additional Resources
25.9.1. Useful Websites
26. FTP
26.1. The File Transfer Protocol
26.1.1. Multiple Ports, Multiple Modes
26.2. FTP Servers
26.2.1. vsftpd
26.3. Files Installed with vsftpd
26.4. Starting and Stopping vsftpd
26.4.1. Starting Multiple Copies of vsftpd
26.5. vsftpd Configuration Options
26.5.1. Daemon Options
26.5.2. Log In Options and Access Controls
26.5.3. Anonymous User Options
26.5.4. Local User Options
26.5.5. Directory Options
26.5.6. File Transfer Options
26.5.7. Logging Options
26.5.8. Network Options
26.6. Additional Resources
26.6.1. Installed Documentation
26.6.2. Useful Websites
27. Email
27.1. Email Protocols
27.1.1. Mail Transport Protocols
27.1.2. Mail Access Protocols
27.2. Email Program Classifications
27.2.1. Mail Transport Agent
27.2.2. Mail Delivery Agent
27.2.3. Mail User Agent
27.3. Mail Transport Agents
27.3.1. Sendmail
27.3.2. Postfix
27.3.3. Fetchmail
27.4. Mail Transport Agent (MTA) Configuration
27.5. Mail Delivery Agents
27.5.1. Procmail Configuration
27.5.2. Procmail Recipes
27.6. Mail User Agents
27.6.1. Securing Communication
27.7. Additional Resources
27.7.1. Installed Documentation
27.7.2. Useful Websites
27.7.3. Related Books
28. Lightweight Directory Access Protocol (LDAP)
28.1. Why Use LDAP?
28.1.1. OpenLDAP Features
28.2. LDAP Terminology
28.3. OpenLDAP Daemons and Utilities
28.3.1. NSS, PAM, and LDAP
28.3.2. PHP4, LDAP, and the Apache HTTP Server
28.3.3. LDAP Client Applications
28.4. OpenLDAP Configuration Files
28.5. The /etc/openldap/schema/ Directory
28.6. OpenLDAP Setup Overview
28.6.1. Editing /etc/openldap/slapd.conf
28.7. Configuring a System to Authenticate Using OpenLDAP
28.7.1. PAM and LDAP
28.7.2. Migrating Old Authentication Information to LDAP Format
28.8. Migrating Directories from Earlier Releases
28.9. Additional Resources
28.9.1. Installed Documentation
28.9.2. Useful Websites
28.9.3. Related Books
29. Authentication Configuration
29.1. User Information
29.2. Authentication
29.3. Options
29.4. Command Line Version
30. Using and Caching Credentials with SSSD
30.1. About the sssd.conf File
30.2. Starting and Stopping SSSD
30.3. Configuring SSSD to Work with System Services
30.3.1. Configuring NSS Services
30.3.2. Configuring the PAM Service
30.4. Creating Domains
30.4.1. General Rules and Options for Configuring a Domain
30.4.2. Configuring an LDAP Domain
30.4.3. Configuring Kerberos Authentication with a Domain
30.4.4. Configuring a Proxy Domain
30.5. Configuring Access Control for SSSD Domains
30.5.1. Using the Simple Access Provider
30.5.2. Using the LDAP Access Filter
30.6. Configuring Domain Failover
30.6.1. Configuring Failover
30.6.2. Using SRV Records with Failover
30.7. Deleting Domain Cache Files
30.8. Using NSCD with SSSD
30.9. Troubleshooting SSSD
30.9.1. Checking SSSD Log Files
30.9.2. Problems with SSSD Configuration
IV. System Configuration
31. Console Access
31.1. Disabling Shutdown Via Ctrl+Alt+Del
31.2. Disabling Console Program Access
31.3. Defining the Console
31.4. Making Files Accessible From the Console
31.5. Enabling Console Access for Other Applications
31.6. The floppy Group
32. The sysconfig Directory
32.1. Files in the /etc/sysconfig/ Directory
32.1.1. /etc/sysconfig/amd
32.1.2. /etc/sysconfig/apmd
32.1.3. /etc/sysconfig/arpwatch
32.1.4. /etc/sysconfig/authconfig
32.1.5. /etc/sysconfig/autofs
32.1.6. /etc/sysconfig/clock
32.1.7. /etc/sysconfig/desktop
32.1.8. /etc/sysconfig/dhcpd
32.1.9. /etc/sysconfig/exim
32.1.10. /etc/sysconfig/firstboot
32.1.11. /etc/sysconfig/gpm
32.1.12. /etc/sysconfig/hwconf
32.1.13. /etc/sysconfig/i18n
32.1.14. /etc/sysconfig/init
32.1.15. /etc/sysconfig/ip6tables-config
32.1.16. /etc/sysconfig/iptables-config
32.1.17. /etc/sysconfig/irda
32.1.18. /etc/sysconfig/keyboard
32.1.19. /etc/sysconfig/kudzu
32.1.20. /etc/sysconfig/named
32.1.21. /etc/sysconfig/network
32.1.22. /etc/sysconfig/nfs
32.1.23. /etc/sysconfig/ntpd
32.1.24. /etc/sysconfig/radvd
32.1.25. /etc/sysconfig/samba
32.1.26. /etc/sysconfig/selinux
32.1.27. /etc/sysconfig/sendmail
32.1.28. /etc/sysconfig/spamassassin
32.1.29. /etc/sysconfig/squid
32.1.30. /etc/sysconfig/system-config-securitylevel
32.1.31. /etc/sysconfig/system-config-selinux
32.1.32. /etc/sysconfig/system-config-users
32.1.33. /etc/sysconfig/system-logviewer
32.1.34. /etc/sysconfig/tux
32.1.35. /etc/sysconfig/vncservers
32.1.36. /etc/sysconfig/xinetd
32.2. Directories in the /etc/sysconfig/ Directory
32.3. Additional Resources
32.3.1. Installed Documentation
33. Date and Time Configuration
33.1. Time and Date Properties
33.2. Network Time Protocol (NTP) Properties
33.3. Time Zone Configuration
34. Keyboard Configuration
35. The X Window System
35.1. The X11R7.1 Release
35.2. Desktop Environments and Window Managers
35.2.1. Desktop Environments
35.2.2. Window Managers
35.3. X Server Configuration Files
35.3.1. xorg.conf
35.4. Fonts
35.4.1. Fontconfig
35.4.2. Core X Font System
35.5. Runlevels and X
35.5.1. Runlevel 3
35.5.2. Runlevel 5
35.6. Additional Resources
35.6.1. Installed Documentation
35.6.2. Useful Websites
36. X Window System Configuration
36.1. Display Settings
36.2. Display Hardware Settings
36.3. Dual Head Display Settings
37. Users and Groups
37.1. User and Group Configuration
37.1.1. Adding a New User
37.1.2. Modifying User Properties
37.1.3. Adding a New Group
37.1.4. Modifying Group Properties
37.2. User and Group Management Tools
37.2.1. Command Line Configuration
37.2.2. Adding a User
37.2.3. Adding a Group
37.2.4. Password Aging
37.2.5. Explaining the Process
37.3. Standard Users
37.4. Standard Groups
37.5. User Private Groups
37.5.1. Group Directories
37.6. Shadow Passwords
37.7. Additional Resources
37.7.1. Installed Documentation
38. Printer Configuration
38.1. Adding a Local Printer
38.2. Adding an IPP Printer
38.3. Adding a Samba (SMB) Printer
38.4. Adding a JetDirect Printer
38.5. Selecting the Printer Model and Finishing
38.5.1. Confirming Printer Configuration
38.6. Printing a Test Page
38.7. Modifying Existing Printers
38.7.1. The Settings Tab
38.7.2. The Policies Tab
38.7.3. The Access Control Tab
38.7.4. The Printer and Job OptionsTab
38.8. Managing Print Jobs
38.9. Additional Resources
38.9.1. Installed Documentation
38.9.2. Useful Websites
39. Automated Tasks
39.1. Cron
39.1.1. Configuring Cron Jobs
39.1.2. Controlling Access to Cron
39.1.3. Starting and Stopping the Service
39.2. At and Batch
39.2.1. Configuring At Jobs
39.2.2. Configuring Batch Jobs
39.2.3. Viewing Pending Jobs
39.2.4. Additional Command Line Options
39.2.5. Controlling Access to At and Batch
39.2.6. Starting and Stopping the Service
39.3. Additional Resources
39.3.1. Installed Documentation
40. Log Files
40.1. Locating Log Files
40.2. Viewing Log Files
40.3. Adding a Log File
40.4. Monitoring Log Files
V. System Monitoring
41. SystemTap
41.1. Introduction
41.2. Implementation
41.3. Using SystemTap
41.3.1. Tracing
42. Gathering System Information
42.1. System Processes
42.2. Memory Usage
42.3. File Systems
42.4. Hardware
42.5. Additional Resources
42.5.1. Installed Documentation
43. OProfile
43.1. Overview of Tools
43.2. Configuring OProfile
43.2.1. Specifying the Kernel
43.2.2. Setting Events to Monitor
43.2.3. Separating Kernel and User-space Profiles
43.3. Starting and Stopping OProfile
43.4. Saving Data
43.5. Analyzing the Data
43.5.1. Using opreport
43.5.2. Using opreport on a Single Executable
43.5.3. Getting more detailed output on the modules
43.5.4. Using opannotate
43.6. Understanding /dev/oprofile/
43.7. Example Usage
43.8. Graphical Interface
43.9. Additional Resources
43.9.1. Installed Docs
43.9.2. Useful Websites
VI. Kernel and Driver Configuration
44. Manually Upgrading the Kernel
44.1. Overview of Kernel Packages
44.2. Preparing to Upgrade
44.3. Downloading the Upgraded Kernel
44.4. Performing the Upgrade
44.5. Verifying the Initial RAM Disk Image
44.6. Verifying the Boot Loader
44.6.1. x86 Systems
44.6.2. Itanium Systems
44.6.3. IBM S/390 and IBM System z Systems
44.6.4. IBM eServer iSeries Systems
44.6.5. IBM eServer pSeries Systems
45. General Parameters and Modules
45.1. Kernel Module Utilities
45.2. Persistent Module Loading
45.3. Specifying Module Parameters
45.4. Storage parameters
45.5. Ethernet Parameters
45.5.1. Using Multiple Ethernet Cards
45.5.2. The Channel Bonding Module
45.6. Additional Resources
45.6.1. Installed Documentation
45.6.2. Useful Websites
46. The kdump Crash Recovery Service
46.1. Installing the kdump Service
46.2. Configuring the kdump Service
46.2.1. Configuring kdump at First Boot
46.2.2. Using the Kernel Dump Configuration Utility
46.2.3. Configuring kdump on the Command Line
46.2.4. Testing the Configuration
46.3. Analyzing the Core Dump
46.3.1. Displaying the Message Buffer
46.3.2. Displaying a Backtrace
46.3.3. Displaying a Process Status
46.3.4. Displaying Virtual Memory Information
46.3.5. Displaying Open Files
46.4. Additional Resources
46.4.1. Installed Documentation
46.4.2. Useful Websites
VII. Security And Authentication
47. Security Overview
47.1. Introduction to Security
47.1.1. What is Computer Security?
47.1.2. Security Controls
47.1.3. Conclusion
47.2. Vulnerability Assessment
47.2.1. Thinking Like the Enemy
47.2.2. Defining Assessment and Testing
47.2.3. Evaluating the Tools
47.3. Attackers and Vulnerabilities
47.3.1. A Quick History of Hackers
47.3.2. Threats to Network Security
47.3.3. Threats to Server Security
47.3.4. Threats to Workstation and Home PC Security
47.4. Common Exploits and Attacks
47.5. Security Updates
47.5.1. Updating Packages
48. Securing Your Network
48.1. Workstation Security
48.1.1. Evaluating Workstation Security
48.1.2. BIOS and Boot Loader Security
48.1.3. Password Security
48.1.4. Administrative Controls
48.1.5. Available Network Services
48.1.6. Personal Firewalls
48.1.7. Security Enhanced Communication Tools
48.2. Server Security
48.2.1. Securing Services With TCP Wrappers and xinetd
48.2.2. Securing Portmap
48.2.3. Securing NIS
48.2.4. Securing NFS
48.2.5. Securing the Apache HTTP Server
48.2.6. Securing FTP
48.2.7. Securing Sendmail
48.2.8. Verifying Which Ports Are Listening
48.3. Single Sign-on (SSO)
48.3.1. Introduction
48.3.2. Getting Started with your new Smart Card
48.3.3. How Smart Card Enrollment Works
48.3.4. How Smart Card Login Works
48.3.5. Configuring Firefox to use Kerberos for SSO
48.4. Pluggable Authentication Modules (PAM)
48.4.1. Advantages of PAM
48.4.2. PAM Configuration Files
48.4.3. PAM Configuration File Format
48.4.4. Sample PAM Configuration Files
48.4.5. Creating PAM Modules
48.4.6. PAM and Administrative Credential Caching
48.4.7. PAM and Device Ownership
48.4.8. Additional Resources
48.5. TCP Wrappers and xinetd
48.5.1. TCP Wrappers
48.5.2. TCP Wrappers Configuration Files
48.5.3. xinetd
48.5.4. xinetd Configuration Files
48.5.5. Additional Resources
48.6. Kerberos
48.6.1. What is Kerberos?
48.6.2. Kerberos Terminology
48.6.3. How Kerberos Works
48.6.4. Kerberos and PAM
48.6.5. Configuring a Kerberos 5 Server
48.6.6. Configuring a Kerberos 5 Client
48.6.7. Domain-to-Realm Mapping
48.6.8. Setting Up Secondary KDCs
48.6.9. Setting Up Cross Realm Authentication
48.6.10. Additional Resources
48.7. Virtual Private Networks (VPNs)
48.7.1. How Does a VPN Work?
48.7.2. VPNs and Red Hat Enterprise Linux
48.7.3. IPsec
48.7.4. Creating an IPsec Connection
48.7.5. IPsec Installation
48.7.6. IPsec Host-to-Host Configuration
48.7.7. IPsec Network-to-Network Configuration
48.7.8. Starting and Stopping an IPsec Connection
48.8. Firewalls
48.8.1. Netfilter and IPTables
48.8.2. Basic Firewall Configuration
48.8.3. Using IPTables
48.8.4. Common IPTables Filtering
48.8.5. FORWARD and NAT Rules
48.8.6. Malicious Software and Spoofed IP Addresses
48.8.7. IPTables and Connection Tracking
48.8.8. IPv6
48.8.9. Additional Resources
48.9. IPTables
48.9.1. Packet Filtering
48.9.2. Differences Between IPTables and IPChains
48.9.3. Command Options for IPTables
48.9.4. Saving IPTables Rules
48.9.5. IPTables Control Scripts
48.9.6. IPTables and IPv6
48.9.7. Additional Resources
49. Security and SELinux
49.1. Access Control Mechanisms (ACMs)
49.1.1. Discretionary Access Control (DAC)
49.1.2. Access Control Lists (ACLs)
49.1.3. Mandatory Access Control (MAC)
49.1.4. Role-based Access Control (RBAC)
49.1.5. Multi-Level Security (MLS)
49.1.6. Multi-Category Security (MCS)
49.2. Introduction to SELinux
49.2.1. SELinux Overview
49.2.2. Files Related to SELinux
49.2.3. Additional Resources
49.3. Brief Background and History of SELinux
49.4. Multi-Category Security (MCS)
49.4.1. Introduction
49.4.2. Applications for Multi-Category Security
49.4.3. SELinux Security Contexts
49.5. Getting Started with Multi-Category Security (MCS)
49.5.1. Introduction
49.5.2. Comparing SELinux and Standard Linux User Identities
49.5.3. Configuring Categories
49.5.4. Assigning Categories to Users
49.5.5. Assigning Categories to Files
49.6. Multi-Level Security (MLS)
49.6.1. Why Multi-Level?
49.6.2. Security Levels, Objects and Subjects
49.6.3. MLS Policy
49.6.4. Enabling MLS in SELinux
49.6.5. LSPP Certification
49.7. SELinux Policy Overview
49.7.1. What is the SELinux Policy?
49.7.2. Where is the Policy?
49.7.3. The Role of Policy in the Boot Process
49.7.4. Object Classes and Permissions
49.8. Targeted Policy Overview
49.8.1. What is the Targeted Policy?
49.8.2. Files and Directories of the Targeted Policy
49.8.3. Understanding the Users and Roles in the Targeted Policy
50. Working With SELinux
50.1. End User Control of SELinux
50.1.1. Moving and Copying Files
50.1.2. Checking the Security Context of a Process, User, or File Object
50.1.3. Relabeling a File or Directory
50.1.4. Creating Archives That Retain Security Contexts
50.2. Administrator Control of SELinux
50.2.1. Viewing the Status of SELinux
50.2.2. Relabeling a File System
50.2.3. Managing NFS Home Directories
50.2.4. Granting Access to a Directory or a Tree
50.2.5. Backing Up and Restoring the System
50.2.6. Enabling or Disabling Enforcement
50.2.7. Enable or Disable SELinux
50.2.8. Changing the Policy
50.2.9. Specifying the Security Context of Entire File Systems
50.2.10. Changing the Security Category of a File or User
50.2.11. Running a Command in a Specific Security Context
50.2.12. Useful Commands for Scripts
50.2.13. Changing to a Different Role
50.2.14. When to Reboot
50.3. Analyst Control of SELinux
50.3.1. Enabling Kernel Auditing
50.3.2. Dumping and Viewing Logs
51. Customizing SELinux Policy
51.1. Introduction
51.1.1. Modular Policy
51.2. Building a Local Policy Module
51.2.1. Using audit2allow to Build a Local Policy Module
51.2.2. Analyzing the Type Enforcement (TE) File
51.2.3. Loading the Policy Package
52. References
VIII. Red Hat Training And Certification
53. Red Hat Training and Certification
53.1. Three Ways to Train
53.2. Microsoft Certified Professional Resource Center
54. Certification Tracks
54.1. Free Pre-assessment tests
55. RH033: Red Hat Linux Essentials
55.1. Course Description
55.1.1. Prerequisites
55.1.2. Goal
55.1.3. Audience
55.1.4. Course Objectives
55.1.5. Follow-on Courses
56. RH035: Red Hat Linux Essentials for Windows Professionals
56.1. Course Description
56.1.1. Prerequisites
56.1.2. Goal
56.1.3. Audience
56.1.4. Course Objectives
56.1.5. Follow-on Courses
57. RH133: Red Hat Linux System Administration and Red Hat Certified Technician (RHCT) Certification
57.1. Course Description
57.1.1. Prerequisites
57.1.2. Goal
57.1.3. Audience
57.1.4. Course Objectives
57.1.5. Follow-on Courses
58. RH202 RHCT EXAM - The fastest growing credential in all of Linux.
58.1. Course Description
58.1.1. Prerequisites
59. RH253 Red Hat Linux Networking and Security Administration
59.1. Course Description
59.1.1. Prerequisites
59.1.2. Goal
59.1.3. Audience
59.1.4. Course Objectives
59.1.5. Follow-on Courses
60. RH300: RHCE Rapid track course (and RHCE exam)
60.1. Course Description
60.1.1. Prerequisites
60.1.2. Goal
60.1.3. Audience
60.1.4. Course Objectives
60.1.5. Follow-on Courses
61. RH302 RHCE EXAM
61.1. Course Description
61.1.1. Prerequisites
61.1.2. Content
62. RHS333: RED HAT enterprise security: network services
62.1. Course Description
62.1.1. Prerequisites
62.1.2. Goal
62.1.3. Audience
62.1.4. Course Objectives
62.1.5. Follow-on Courses
63. RH401: Red Hat Enterprise Deployment and systems management
63.1. Course Description
63.1.1. Prerequisites
63.1.2. Goal
63.1.3. Audience
63.1.4. Course Objectives
63.1.5. Follow-on Courses
64. RH423: Red Hat Enterprise Directory services and authentication
64.1. Course Description
64.1.1. Prerequisites
64.1.2. Goal
64.1.3. Audience
64.1.4. Course Objectives
64.1.5. Follow-on Courses
65. SELinux Courses
65.1. RHS427: Introduction to SELinux and Red Hat Targeted Policy
65.1.1. Audience
65.1.2. Course Summary
65.2. RHS429: Red Hat Enterprise SELinux Policy Administration
66. RH436: Red Hat Enterprise storage management
66.1. Course Description
66.1.1. Prerequisites
66.1.2. Goal
66.1.3. Audience
66.1.4. Course Objectives
66.1.5. Follow-on Courses
67. RH442: Red Hat Enterprise system monitoring and performance tuning
67.1. Course Description
67.1.1. Prerequisites
67.1.2. Goal
67.1.3. Audience
67.1.4. Course Objectives
67.1.5. Follow-on Courses
68. Red Hat Enterprise Linux Developer Courses
68.1. RHD143: Red Hat Linux Programming Essentials
68.2. RHD221 Red Hat Linux Device Drivers
68.3. RHD236 Red Hat Linux Kernel Internals
68.4. RHD256 Red Hat Linux Application Development and Porting
69. JBoss Courses
69.1. RHD161 JBoss and EJB3 for Java
69.1.1. Prerequisites
69.2. RHD163 JBoss for Web Developers
69.2.1. Prerequisites
69.3. RHD167: JBOSS - HIBERNATE ESSENTIALS
69.3.1. Prerequisites
69.3.2. Course Summary
69.4. RHD267: JBOSS - ADVANCED HIBERNATE
69.4.1. Prerequisites
69.5. RHD261:JBOSS for advanced J2EE developers
69.5.1. Prerequisites
69.6. RH336: JBOSS for Administrators
69.6.1. Prerequisites
69.6.2. Course Summary
69.7. RHD439: JBoss Clustering
69.7.1. Prerequisites
69.8. RHD449: JBoss jBPM
69.8.1. Description
69.8.2. Prerequisites
69.9. RHD451 JBoss Rules
69.9.1. Prerequisites
A. Revision History
B. Colophon

Introduction

Welcome to the Red Hat Enterprise Linux Deployment Guide.
The Red Hat Enterprise Linux Deployment Guide contains information on how to customize your Red Hat Enterprise Linux system to fit your needs. If you are looking for a comprehensive, task-oriented guide for configuring and customizing your system, this is the manual for you.
This manual discusses many intermediate topics such as the following:
  • Setting up a network interface card (NIC)
  • Configuring a Virtual Private Network (VPN)
  • Configuring Samba shares
  • Managing your software with RPM
  • Determining information about your system
  • Upgrading your kernel
This manual is divided into the following main categories:
  • File systems
  • Package management
  • Network-related configuration
  • System configuration
  • System monitoring
  • Kernel and Driver Configuration
  • Security and Authentication
  • Red Hat Training and Certification
This guide assumes you have a basic understanding of your Red Hat Enterprise Linux system. If you need help installing Red Hat Enterprise Linux, refer to the Red Hat Enterprise Linux Installation Guide.

1. Document Conventions

In this manual, certain words are represented in different fonts, typefaces, sizes, and weights. This highlighting is systematic; different words are represented in the same style to indicate their inclusion in a specific category. The types of words that are represented this way include the following:
command
Linux commands (and other operating system commands, when used) are represented this way. This style should indicate to you that you can type the word or phrase on the command line and press Enter to invoke a command. Sometimes a command contains words that would be displayed in a different style on their own (such as file names). In these cases, they are considered to be part of the command, so the entire phrase is displayed as a command. For example:
Use the cat testfile command to view the contents of a file, named testfile, in the current working directory.
file name
File names, directory names, paths, and RPM package names are represented this way. This style indicates that a particular file or directory exists with that name on your system. Examples:
The .bashrc file in your home directory contains bash shell definitions and aliases for your own use.
The /etc/fstab file contains information about different system devices and file systems.
Install the webalizer RPM if you want to use a Web server log file analysis program.
application
This style indicates that the program is an end-user application (as opposed to system software). For example:
Use Mozilla to browse the Web.
key
A key on the keyboard is shown in this style. For example:
To use Tab completion to list particular files in a directory, type ls, then a character, and finally the Tab key. Your terminal displays the list of files in the working directory that begin with that character.
key+combination
A combination of keystrokes is represented in this way. For example:
The Ctrl+Alt+Backspace key combination exits your graphical session and returns you to the graphical login screen or the console.
text found on a GUI interface
A title, word, or phrase found on a GUI interface screen or window is shown in this style. Text shown in this style indicates a particular GUI screen or an element on a GUI screen (such as text associated with a checkbox or field). Example:
Select the Require Password checkbox if you would like your screensaver to require a password before stopping.
top level of a menu on a GUI screen or window
A word in this style indicates that the word is the top level of a pulldown menu. If you click on the word on the GUI screen, the rest of the menu should appear. For example:
Under File on a GNOME terminal, the New Tab option allows you to open multiple shell prompts in the same window.
Instructions to type in a sequence of commands from a GUI menu look like the following example:
Go to Applications (the main menu on the panel) > Programming > Emacs Text Editor to start the Emacs text editor.
button on a GUI screen or window
This style indicates that the text can be found on a clickable button on a GUI screen. For example:
Click on the Back button to return to the webpage you last viewed.
computer output
Text in this style indicates text displayed to a shell prompt such as error messages and responses to commands. For example:
The ls command displays the contents of a directory. For example:
Desktop    about.html    logs     paulwesterberg.png
Mail    backupfiles    mail     reports
The output returned in response to the command (in this case, the contents of the directory) is shown in this style.
prompt
A prompt, which is a computer's way of signifying that it is ready for you to input something, is shown in this style. Examples:
$
#
[stephen@maturin stephen]$
leopard login:
user input
Text that the user types, either on the command line or into a text box on a GUI screen, is displayed in this style. In the following example, text is displayed in this style:
To boot your system into the text based installation program, you must type in the text command at the boot: prompt.
<replaceable>
Text used in examples that is meant to be replaced with data provided by the user is displayed in this style. In the following example, <version-number> is displayed in this style:
The directory for the kernel source is /usr/src/kernels/<version-number>/, where <version-number> is the version and type of kernel installed on this system.
Additionally, we use several different strategies to draw your attention to certain pieces of information. In order of urgency, these items are marked as a note, tip, important, caution, or warning. For example:

Note

Remember that Linux is case sensitive. In other words, a rose is not a ROSE is not a rOsE.

Tip

The directory /usr/share/doc/ contains additional documentation for packages installed on your system.

Important

If you modify the DHCP configuration file, the changes do not take effect until you restart the DHCP daemon.

Caution

Do not perform routine tasks as root — use a regular user account unless you need to use the root account for system administration tasks.

Warning

Be careful to remove only the necessary partitions. Removing other partitions could result in data loss or a corrupted system environment.

2. Send in Your Feedback

If you find an error in the Red Hat Enterprise Linux Deployment Guide, or if you have thought of a way to make this manual better, we would like to hear from you! Submit a report in Bugzilla (http://bugzilla.redhat.com/bugzilla/) against the component Deployment_Guide.
If you have a suggestion for improving the documentation, try to be as specific as possible. If you have found an error, include the section number and some of the surrounding text so we can find it easily.

Part I. File Systems

File system refers to the files and directories stored on a computer. A file system can have different formats called file system types. These formats determine how the information is stored as files and directories. Some file system types store redundant copies of the data, while some file system types make hard drive access faster. This part discusses the ext3, swap, RAID, and LVM file system types. It also discusses the parted utility to manage partitions and access control lists (ACLs) to customize file permissions.

Table of Contents

1. File System Structure
1.1. Why Share a Common Structure?
1.2. Overview of File System Hierarchy Standard (FHS)
1.2.1. FHS Organization
1.3. Special File Locations Under Red Hat Enterprise Linux
2. Using the mount Command
2.1. Listing Currently Mounted File Systems
2.2. Mounting a File System
2.2.1. Specifying the File System Type
2.2.2. Specifying the Mount Options
2.2.3. Sharing Mounts
2.2.4. Moving a Mount Point
2.3. Unmounting a File System
2.4. Additional Resources
2.4.1. Installed Documentation
2.4.2. Useful Websites
3. The ext3 File System
3.1. Features of ext3
3.2. Creating an ext3 File System
3.3. Converting to an ext3 File System
3.4. Reverting to an ext2 File System
4. The ext4 File System
4.1. Features of ext4
4.2. Managing an ext4 File System
4.3. Creating an ext4 File System
4.4. Mounting an ext4 File System
4.5. Resizing an ext4 File System
5. The proc File System
5.1. A Virtual File System
5.1.1. Viewing Virtual Files
5.1.2. Changing Virtual Files
5.1.3. Restricting Access to Process Directories
5.2. Top-level Files within the proc File System
5.2.1. /proc/apm
5.2.2. /proc/buddyinfo
5.2.3. /proc/cmdline
5.2.4. /proc/cpuinfo
5.2.5. /proc/crypto
5.2.6. /proc/devices
5.2.7. /proc/dma
5.2.8. /proc/execdomains
5.2.9. /proc/fb
5.2.10. /proc/filesystems
5.2.11. /proc/interrupts
5.2.12. /proc/iomem
5.2.13. /proc/ioports
5.2.14. /proc/kcore
5.2.15. /proc/kmsg
5.2.16. /proc/loadavg
5.2.17. /proc/locks
5.2.18. /proc/mdstat
5.2.19. /proc/meminfo
5.2.20. /proc/misc
5.2.21. /proc/modules
5.2.22. /proc/mounts
5.2.23. /proc/mtrr
5.2.24. /proc/partitions
5.2.25. /proc/pci
5.2.26. /proc/slabinfo
5.2.27. /proc/stat
5.2.28. /proc/swaps
5.2.29. /proc/sysrq-trigger
5.2.30. /proc/uptime
5.2.31. /proc/version
5.3. Directories within /proc/
5.3.1. Process Directories
5.3.2. /proc/bus/
5.3.3. /proc/driver/
5.3.4. /proc/fs
5.3.5. /proc/ide/
5.3.6. /proc/irq/
5.3.7. /proc/net/
5.3.8. /proc/scsi/
5.3.9. /proc/sys/
5.3.10. /proc/sysvipc/
5.3.11. /proc/tty/
5.3.12. /proc/<PID>/
5.4. Using the sysctl Command
5.5. Additional Resources
5.5.1. Installed Documentation
5.5.2. Useful Websites
6. Redundant Array of Independent Disks (RAID)
6.1. What is RAID?
6.1.1. Who Should Use RAID?
6.1.2. Hardware RAID versus Software RAID
6.1.3. RAID Levels and Linear Support
6.2. Configuring Software RAID
6.2.1. Creating the RAID Partitions
6.2.2. Creating the RAID Devices and Mount Points
6.3. Managing Software RAID
6.3.1. Reviewing RAID Configuration
6.3.2. Creating a New RAID Device
6.3.3. Replacing a Faulty Device
6.3.4. Extending a RAID Device
6.3.5. Removing a RAID Device
6.3.6. Preserving the Configuration
6.4. Additional Resources
6.4.1. Installed Documentation
7. Swap Space
7.1. What is Swap Space?
7.2. Adding Swap Space
7.2.1. Extending Swap on an LVM2 Logical Volume
7.2.2. Creating an LVM2 Logical Volume for Swap
7.2.3. Creating a Swap File
7.3. Removing Swap Space
7.3.1. Reducing Swap on an LVM2 Logical Volume
7.3.2. Removing an LVM2 Logical Volume for Swap
7.3.3. Removing a Swap File
7.4. Moving Swap Space
8. Managing Disk Storage
8.1. Standard Partitions using parted
8.1.1. Viewing the Partition Table
8.1.2. Creating a Partition
8.1.3. Removing a Partition
8.1.4. Resizing a Partition
8.2. LVM Partition Management
9. Implementing Disk Quotas
9.1. Configuring Disk Quotas
9.1.1. Enabling Quotas
9.1.2. Remounting the File Systems
9.1.3. Creating the Quota Database Files
9.1.4. Assigning Quotas per User
9.1.5. Assigning Quotas per Group
9.1.6. Setting the Grace Period for Soft Limits
9.2. Managing Disk Quotas
9.2.1. Enabling and Disabling
9.2.2. Reporting on Disk Quotas
9.2.3. Keeping Quotas Accurate
9.3. Additional Resources
9.3.1. Installed Documentation
9.3.2. Related Books
10. Access Control Lists
10.1. Mounting File Systems
10.1.1. NFS
10.2. Setting Access ACLs
10.3. Setting Default ACLs
10.4. Retrieving ACLs
10.5. Archiving File Systems With ACLs
10.6. Compatibility with Older Systems
10.7. Additional Resources
10.7.1. Installed Documentation
10.7.2. Useful Websites
11. LVM (Logical Volume Manager)
11.1. What is LVM?
11.1.1. What is LVM2?
11.2. LVM Configuration
11.3. Automatic Partitioning
11.4. Manual LVM Partitioning
11.4.1. Creating the /boot Partition
11.4.2. Creating the LVM Physical Volumes
11.4.3. Creating the LVM Volume Groups
11.4.4. Creating the LVM Logical Volumes
11.5. Using the LVM utility system-config-lvm
11.5.1. Utilizing uninitialized entities
11.5.2. Adding Unallocated Volumes to a volume group
11.5.3. Migrating extents
11.5.4. Adding a new hard disk using LVM
11.5.5. Adding a new volume group
11.5.6. Extending a volume group
11.5.7. Editing a Logical Volume
11.6. Additional Resources
11.6.1. Installed Documentation
11.6.2. Useful Websites

Chapter 1. File System Structure

1.1. Why Share a Common Structure?

The file system structure is the most basic level of organization in an operating system. Almost all of the ways an operating system interacts with its users, applications, and security model are dependent upon the way it organizes files on storage devices. Providing a common file system structure ensures users and programs are able to access and write files.
File systems break files down into two logical categories:
  • Shareable vs. unshareable files
  • Variable vs. static files
Shareable files are those that can be accessed locally and by remote hosts; unshareable files are only available locally. Variable files, such as documents, can be changed at any time; static files, such as binaries, do not change without an action from the system administrator.
The reason for looking at files in this manner is to help correlate the function of the file with the permissions assigned to the directories which hold them. The way in which the operating system and its users interact with a given file determines the directory in which it is placed, whether that directory is mounted with read-only or read/write permissions, and the level of access each user has to that file. The top level of this organization is crucial. Access to the underlying directories can be restricted or security problems could manifest themselves if, from the top level down, it does not adhere to a rigid structure.

1.2. Overview of File System Hierarchy Standard (FHS)

Red Hat Enterprise Linux uses the Filesystem Hierarchy Standard (FHS) file system structure, which defines the names, locations, and permissions for many file types and directories.
The FHS document is the authoritative reference to any FHS-compliant file system, but the standard leaves many areas undefined or extensible. This section is an overview of the standard and a description of the parts of the file system not covered by the standard.
Compliance with the standard means many things, but the two most important are compatibility with other compliant systems and the ability to mount a /usr/ partition as read-only. This second point is important because the directory contains common executables and should not be changed by users. Also, since the /usr/ directory is mounted as read-only, it can be mounted from the CD-ROM or from another machine via a read-only NFS mount.

1.2.1. FHS Organization

The directories and files noted here are a small subset of those specified by the FHS document. Refer to the latest FHS document for the most complete information.
The complete standard is available online at http://www.pathname.com/fhs/.

1.2.1.1. The /boot/ Directory

The /boot/ directory contains static files required to boot the system, such as the Linux kernel. These files are essential for the system to boot properly.

Warning

Do not remove the /boot/ directory. Doing so renders the system unbootable.

1.2.1.2. The /dev/ Directory

The /dev/ directory contains device nodes that either represent devices that are attached to the system or virtual devices that are provided by the kernel. These device nodes are essential for the system to function properly. The udev daemon takes care of creating and removing all these device nodes in /dev/.
Devices in the /dev directory and subdirectories are either character (providing only a serial stream of input/output) or block (accessible randomly). Character devices include mouse, keyboard, modem while block devices include hard disk, floppy drive etc. If you have GNOME or KDE installed in your system, devices such as external drives or cds are automatically detected when connected (e.g via usb) or inserted (e.g via CD or DVD drive) and a popup window displaying the contents is automatically displayed. Files in the /dev directory are essential for the system to function properly.

Table 1.1. Examples of common files in the /dev

File Description
/dev/hda The master device on primary IDE channel.
/dev/hdb The slave device on primary IDE channel.
/dev/tty0 The first virtual console.
/dev/tty1 The second virtual console.
/dev/sda The first device on primary SCSI or SATA channel.
/dev/lp0 The first parallel port.

1.2.1.3. The /etc/ Directory

The /etc/ directory is reserved for configuration files that are local to the machine. No binaries are to be placed in /etc/. Any binaries that were once located in /etc/ should be placed into /sbin/ or /bin/.
Examples of directories in /etc are the X11/ and skel/:
/etc
   |- X11/
   |- skel/
The /etc/X11/ directory is for X Window System configuration files, such as xorg.conf. The /etc/skel/ directory is for "skeleton" user files, which are used to populate a home directory when a user is first created. Applications also store their configuration files in this directory and may reference them when they are executed.

1.2.1.4. The /lib/ Directory

The /lib/ directory should contain only those libraries needed to execute the binaries in /bin/ and /sbin/. These shared library images are particularly important for booting the system and executing commands within the root file system.

1.2.1.5. The /media/ Directory

The /media/ directory contains subdirectories used as mount points for removable media such as usb storage media, DVDs, CD-ROMs, and Zip disks.

1.2.1.6. The /mnt/ Directory

The /mnt/ directory is reserved for temporarily mounted file systems, such as NFS file system mounts. For all removable media, please use the /media/ directory. Automatically detected removable media will be mounted in the /media directory.

Note

The /mnt directory must not be used by installation programs.

1.2.1.7. The /opt/ Directory

The /opt/ directory provides storage for most application software packages.
A package placing files in the /opt/ directory creates a directory bearing the same name as the package. This directory, in turn, holds files that otherwise would be scattered throughout the file system, giving the system administrator an easy way to determine the role of each file within a particular package.
For example, if sample is the name of a particular software package located within the /opt/ directory, then all of its files are placed in directories inside the /opt/sample/ directory, such as /opt/sample/bin/ for binaries and /opt/sample/man/ for manual pages.
Packages that encompass many different sub-packages, data files, extra fonts, clipart etc are also located in the /opt/ directory, giving that large package a way to organize itself. In this way, our sample package may have different tools that each go in their own sub-directories, such as /opt/sample/tool1/ and /opt/sample/tool2/, each of which can have their own bin/, man/, and other similar directories.

1.2.1.8. The /proc/ Directory

The /proc/ directory contains special files that either extract information from or send information to the kernel. Examples include system memory, cpu information, hardware configuration etc.
Due to the great variety of data available within /proc/ and the many ways this directory can be used to communicate with the kernel, an entire chapter has been devoted to the subject. For more information, refer to Chapter 5, The proc File System.

1.2.1.9. The /sbin/ Directory

The /sbin/ directory stores executables used by the root user. The executables in /sbin/ are used at boot time, for system administration and to perform system recovery operations. Of this directory, the FHS says:
/sbin contains binaries essential for booting, restoring, recovering, and/or repairing the system in addition to the binaries in /bin. Programs executed after /usr/ is known to be mounted (when there are no problems) are generally placed into /usr/sbin. Locally-installed system administration programs should be placed into /usr/local/sbin.
At a minimum, the following programs should be in /sbin/:
arp, clock,
halt, init,
fsck.*, grub,
ifconfig, mingetty,
mkfs.*, mkswap,
reboot, route,
shutdown, swapoff,
swapon

1.2.1.10. The /srv/ Directory

The /srv/ directory contains site-specific data served by your system running Red Hat Enterprise Linux. This directory gives users the location of data files for a particular service, such as FTP, WWW, or CVS. Data that only pertains to a specific user should go in the /home/ directory.

1.2.1.11. The /sys/ Directory

The /sys/ directory utilizes the new sysfs virtual file system specific to the 2.6 kernel. With the increased support for hot plug hardware devices in the 2.6 kernel, the /sys/ directory contains information similarly held in /proc/, but displays a hierarchical view of specific device information in regards to hot plug devices.

1.2.1.12. The /usr/ Directory

The /usr/ directory is for files that can be shared across multiple machines. The /usr/ directory is often on its own partition and is mounted read-only. At a minimum, the following directories should be subdirectories of /usr/:
/usr
   |- bin/
   |- etc/
   |- games/
   |- include/
   |- kerberos/
   |- lib/
   |- libexec/
   |- local/
   |- sbin/
   |- share/
   |- src/
   |- tmp -> ../var/tmp/
Under the /usr/ directory, the bin/ subdirectory contains executables, etc/ contains system-wide configuration files, games is for games, include/ contains C header files, kerberos/ contains binaries and other Kerberos-related files, and lib/ contains object files and libraries that are not designed to be directly utilized by users or shell scripts. The libexec/ directory contains small helper programs called by other programs, sbin/ is for system administration binaries (those that do not belong in the /sbin/ directory), share/ contains files that are not architecture-specific, src/ is for source code.

1.2.1.13. The /usr/local/ Directory

The FHS says:
The /usr/local hierarchy is for use by the system administrator when installing software locally. It needs to be safe from being overwritten when the system software is updated. It may be used for programs and data that are shareable among a group of hosts, but not found in /usr.
The /usr/local/ directory is similar in structure to the /usr/ directory. It has the following subdirectories, which are similar in purpose to those in the /usr/ directory:
/usr/local
	|- bin/
	|- etc/
	|- games/
	|- include/
	|- lib/
	|- libexec/
	|- sbin/
	|- share/
	|- src/
In Red Hat Enterprise Linux, the intended use for the /usr/local/ directory is slightly different from that specified by the FHS. The FHS says that /usr/local/ should be where software that is to remain safe from system software upgrades is stored. Since software upgrades can be performed safely with RPM Package Manager (RPM), it is not necessary to protect files by putting them in /usr/local/. Instead, the /usr/local/ directory is used for software that is local to the machine.
For instance, if the /usr/ directory is mounted as a read-only NFS share from a remote host, it is still possible to install a package or program under the /usr/local/ directory.

1.2.1.14. The /var/ Directory

Since the FHS requires Linux to mount /usr/ as read-only, any programs that write log files or need spool/ or lock/ directories should write them to the /var/ directory. The FHS states /var/ is for:
...variable data files. This includes spool directories and files, administrative and logging data, and transient and temporary files.
Below are some of the directories found within the /var/ directory:
/var
   |- account/
   |- arpwatch/
   |- cache/
   |- crash/
   |- db/
   |- empty/
   |- ftp/
   |- gdm/
   |- kerberos/
   |- lib/
   |- local/
   |- lock/
   |- log/
   |- mail -> spool/mail/
   |- mailman/
   |- named/
   |- nis/
   |- opt/
   |- preserve/
   |- run/
   +- spool/
       |- at/
       |- clientmqueue/
       |- cron/
       |- cups/
       |- exim/
       |- lpd/
       |- mail/
       |- mailman/
       |- mqueue/
       |- news/
       |- postfix/
       |- repackage/
       |- rwho/
       |- samba/
       |- squid/
       |- squirrelmail/
       |- up2date/
       |- uucp
       |- uucppublic/
       |- vbox/
|- tmp/
|- tux/
|- www/
|- yp/
System log files, such as messages and lastlog, go in the /var/log/ directory. The /var/lib/rpm/ directory contains RPM system databases. Lock files go in the /var/lock/ directory, usually in directories for the program using the file. The /var/spool/ directory has subdirectories for programs in which data files are stored.

1.3. Special File Locations Under Red Hat Enterprise Linux

Red Hat Enterprise Linux extends the FHS structure slightly to accommodate special files.
Most files pertaining to RPM are kept in the /var/lib/rpm/ directory. For more information on RPM, refer to the chapter Chapter 12, Package Management with RPM.
The /var/cache/yum/ directory contains files used by the Package Updater, including RPM header information for the system. This location may also be used to temporarily store RPMs downloaded while updating the system. For more information about Red Hat Network, refer to Chapter 15, Registering a System and Managing Subscriptions.
Another location specific to Red Hat Enterprise Linux is the /etc/sysconfig/ directory. This directory stores a variety of configuration information. Many scripts that run at boot time use the files in this directory. Refer to Chapter 32, The sysconfig Directory for more information about what is within this directory and the role these files play in the boot process.

Chapter 2. Using the mount Command

On Linux, UNIX, and similar operating systems, file systems on different partitions and removable devices like CDs, DVDs, or USB flash drives can be attached to a certain point (that is, the mount point) in the directory tree, and detached again. To attach or detach a file system, you can use the mount or umount command respectively. This chapter describes the basic usage of these commands, and covers some advanced topics such as moving a mount point or creating shared subtrees.

2.1. Listing Currently Mounted File Systems

To display all currently attached file systems, run the mount command with no additional arguments:
mount
This command displays the list of known mount points. Each line provides important information about the device name, the file system type, the directory in which it is mounted, and relevant mount options in the following form:
device on directory type type (options)
By default, the output includes various virtual file systems such as sysfs, tmpfs, and others. To display only the devices with a certain file system type, supply the -t option on the command line:
mount -t type
For a list of common file system types, refer to Table 2.1, “Common File System Types”. For an example on how to use the mount command to list the mounted file systems, see Example 2.1, “Listing Currently Mounted ext3 File Systems”.

Example 2.1. Listing Currently Mounted ext3 File Systems

Usually, both / and /boot partitions are formatted to use ext3. To display only the mount points that use this file system, type the following at a shell prompt:
~]$ mount -t ext3
/dev/mapper/VolGroup00-LogVol00 on / type ext3 (rw)
/dev/vda1 on /boot type ext3 (rw)

2.2. Mounting a File System

To attach a certain file system, use the mount command in the following form:
mount [option] device directory
When the mount command is run, it reads the content of the /etc/fstab configuration file to see if the given file system is listed. This file contains a list of device names and the directory in which the selected file systems should be mounted, as well as the file system type and mount options. Because of this, when you are mounting a file system that is specified in this file, you can use one of the following variants of the command:
mount [option] directory
mount [option] device
Note that unless you are logged in as root, you must have permissions to mount the file system (see Section 2.2.2, “Specifying the Mount Options”).

2.2.1. Specifying the File System Type

In most cases, mount detects the file system automatically. However, there are certain file systems, such as NFS (Network File System) or CIFS (Common Internet File System), that are not recognized, and need to be specified manually. To specify the file system type, use the mount command in the following form:
mount -t type device directory
Table 2.1, “Common File System Types” provides a list of common file system types that can be used with the mount command. For a complete list of all available file system types, consult the relevant manual page as referred to in Section 2.4.1, “Installed Documentation”.

Table 2.1. Common File System Types

Type Description
ext2 The ext2 file system.
ext3 The ext3 file system.
ext4 The ext4 file system.
iso9660 The ISO 9660 file system. It is commonly used by optical media, typically CDs.
jfs The JFS file system created by IBM.
nfs The NFS file system. It is commonly used to access files over the network.
nfs4 The NFSv4 file system. It is commonly used to access files over the network.
ntfs The NTFS file system. It is commonly used on machines that are running the Windows operating system.
udf The UDF file system. It is commonly used by optical media, typically DVDs.
vfat The FAT file system. It is commonly used on machines that are running the Windows operating system, and on certain digital media such as USB flash drives or floppy disks.

Example 2.2. Mounting a USB Flash Drive

Older USB flash drives often use the FAT file system. Assuming that such drive uses the /dev/sdc1 device and that the /media/flashdisk/ directory exists, you can mount it to this directory by typing the following at a shell prompt as root:
~]# mount -t vfat /dev/sdc1 /media/flashdisk

2.2.2. Specifying the Mount Options

To specify additional mount options, use the command in the following form:
mount -o options
When supplying multiple options, do not insert a space after a comma, or mount will incorrectly interpret the values following spaces as additional parameters.
Table 2.2, “Common Mount Options” provides a list of common mount options. For a complete list of all available options, consult the relevant manual page as referred to in Section 2.4.1, “Installed Documentation”.

Table 2.2. Common Mount Options

Option Description
async Allows the asynchronous input/output operations on the file system.
auto Allows the file system to be mounted automatically using the mount -a command.
defaults Provides an alias for async,auto,dev,exec,nouser,rw,suid.
exec Allows the execution of binary files on the particular file system.
loop Mounts an image as a loop device.
noauto Disallows the automatic mount of the file system using the mount -a command.
noexec Disallows the execution of binary files on the particular file system.
nouser Disallows an ordinary user (that is, other than root) to mount and unmount the file system.
remount Remounts the file system in case it is already mounted.
ro Mounts the file system for reading only.
rw Mounts the file system for both reading and writing.
user Allows an ordinary user (that is, other than root) to mount and unmount the file system.

See Example 2.3, “Mounting an ISO Image” for an example usage.

Example 2.3. Mounting an ISO Image

An ISO image (or a disk image in general) can be mounted by using the loop device. Assuming that the ISO image of the Fedora 14 installation disc is present in the current working directory and that the /media/cdrom/ directory exists, you can mount the image to this directory by running the following command as root:
~]# mount -o ro,loop Fedora-14-x86_64-Live-Desktop.iso /media/cdrom
Note that ISO 9660 is by design a read-only file system.

2.2.3. Sharing Mounts

Occasionally, certain system administration tasks require access to the same file system from more than one place in the directory tree (for example, when preparing a chroot environment). To address such requirements, the mount command implements the --bind option that provides a means for duplicating certain mounts. Its usage is as follows:
mount --bind old_directory new_directory
Although the above command allows a user to access the file system from both places, it does not apply on the file systems that are mounted within the original directory. To include these mounts as well, type:
mount --rbind old_directory new_directory
Additionally, to provide as much flexibility as possible, Red Hat Enterprise Linux 5.10 implements the functionality known as shared subtrees. This feature allows you to use the following four mount types:
Shared Mount
A shared mount allows you to create an exact replica of a given mount point. When a shared mount is created, any mount within the original mount point is reflected in it, and vice versa. To create a shared mount, type the following at a shell prompt:
mount --make-shared mount_point
Alternatively, you can change the mount type for the selected mount point and all mount points under it:
mount --make-rshared mount_point

Example 2.4. Creating a Shared Mount Point

There are two places where other file systems are commonly mounted: the /media directory for removable media, and the /mnt directory for temporarily mounted file systems. By using a shared mount, you can make these two directories share the same content. To do so, as root, mark the /media directory as shared:
~]# mount --bind /media /media
~]# mount --make-shared /media
Then create its duplicate in /mnt by using the following command:
~]# mount --bind /media /mnt
You can now verify that a mount within /media also appears in /mnt. For example, if you have non-empty media in your CD-ROM drive and the /media/cdrom/ directory exists, run the following commands:
~]# mount /dev/cdrom /media/cdrom
~]# ls /media/cdrom
EFI  GPL  isolinux  LiveOS
~]# ls /mnt/cdrom
EFI  GPL  isolinux  LiveOS
Similarly, you can verify that any file system mounted in the /mnt directory is reflected in /media. For instance, if you have a non-empty USB flash drive that uses the /dev/sdc1 device plugged in and the /mnt/flashdisk/ directory is present, type:
~]# mount /dev/sdc1 /mnt/flashdisk
~]# ls /media/flashdisk
en-US  publican.cfg
~]# ls /mnt/flashdisk
en-US  publican.cfg

Slave Mount
A slave mount allows you to create a limited duplicate of a given mount point. When a slave mount is created, any mount within the original mount point is reflected in it, but no mount within a slave mount is reflected in its original. To create a slave mount, type the following at a shell prompt:
mount --make-slave mount_point
Alternatively, you can change the mount type for the selected mount point and all mount points under it:
mount --make-rslave mount_point

Example 2.5. Creating a Slave Mount Point

Imagine you want the content of the /media directory to appear in /mnt as well, but you do not want any mounts in the /mnt directory to be reflected in /media. To do so, as root, first mark the /media directory as shared:
~]# mount --bind /media /media
~]# mount --make-shared /media
Then create its duplicate in /mnt, but mark it as slave:
~]# mount --bind /media /mnt
~]# mount --make-slave /mnt
You can now verify that a mount within /media also appears in /mnt. For example, if you have non-empty media in your CD-ROM drive and the /media/cdrom/ directory exists, run the following commands:
~]# mount /dev/cdrom /media/cdrom
~]# ls /media/cdrom
EFI  GPL  isolinux  LiveOS
~]# ls /mnt/cdrom
EFI  GPL  isolinux  LiveOS
You can also verify that file systems mounted in the /mnt directory are not reflected in /media. For instance, if you have a non-empty USB flash drive that uses the /dev/sdc1 device plugged in and the /mnt/flashdisk/ directory is present, type: :
~]# mount /dev/sdc1 /mnt/flashdisk
~]# ls /media/flashdisk
~]# ls /mnt/flashdisk
en-US  publican.cfg

Private Mount
A private mount allows you to create an ordinary mount. When a private mount is created, no subsequent mounts within the original mount point are reflected in it, and no mount within a private mount is reflected in its original. To create a private mount, type the following at a shell prompt:
mount --make-private mount_point
Alternatively, you can change the mount type for the selected mount point and all mount points under it:
mount --make-rprivate mount_point

Example 2.6. Creating a Private Mount Point

Taking into account the scenario in Example 2.4, “Creating a Shared Mount Point”, assume that you have previously created a shared mount point by using the following commands as root:
~]# mount --bind /media /media
~]# mount --make-shared /media
~]# mount --bind /media /mnt
To mark the /mnt directory as private, type:
~]# mount --make-private /mnt
You can now verify that none of the mounts within /media appears in /mnt. For example, if you have non-empty media in your CD-ROM drive and the /media/cdrom/ directory exists, run the following commands:
~]# mount /dev/cdrom /media/cdrom
~]# ls /media/cdrom
EFI  GPL  isolinux  LiveOS
~]# ls /mnt/cdrom
~]#
You can also verify that file systems mounted in the /mnt directory are not reflected in /media. For instance, if you have a non-empty USB flash drive that uses the /dev/sdc1 device plugged in and the /mnt/flashdisk/ directory is present, type:
~]# mount /dev/sdc1 /mnt/flashdisk
~]# ls /media/flashdisk
~]# ls /mnt/flashdisk
en-US  publican.cfg

Unbindable Mount
An unbindable mount allows you to prevent a given mount point from being duplicated whatsoever. To create an unbindable mount, type the following at a shell prompt:
mount --make-unbindable mount_point
Alternatively, you can change the mount type for the selected mount point and all mount points under it:
mount --make-runbindable mount_point

Example 2.7. Creating an Unbindable Mount Point

To prevent the /media directory from being shared, as root, type the following at a shell prompt:
~]# mount --bind /media /media
~]# mount --make-unbindable /media
This way, any subsequent attempt to make a duplicate of this mount will fail with an error:
~]# mount --bind /media /mnt
mount: wrong fs type, bad option, bad superblock on /media/,
       missing code page or other error
       In some cases useful info is found in syslog - try
       dmesg | tail  or so

2.2.4. Moving a Mount Point

To change the directory in which a file system is mounted, use the following command:
mount --move old_directory new_directory

Example 2.8. Moving an Existing NFS Mount Point

Imagine that you have an NFS storage that contains user directories. Assuming that this storage is already mounted in /mnt/userdirs/, as root, you can move this mount point to /home by using the following command:
~]# mount --move /mnt/userdirs /home
To verify the mount point has been moved, list the content of both directories:
~]# ls /mnt/userdirs
~]# ls /home
jill  joe

2.3. Unmounting a File System

To detach a previously mounted file system, use either of the following variants of the umount command:
umount directory
umount device
Note that unless you are logged in as root, you must have permissions to unmount the file system (see Section 2.2.2, “Specifying the Mount Options”). See Example 2.9, “Unmounting a CD” for an example usage.

Important: Make Sure the File System Is Not in Use

When a file system is in use (for example, when a process is reading a file on this file system), running the umount command will fail with an error. To determine which processes are accessing the file system, use the fuser command in the following form:
fuser -m directory
For example, to list the processes that are accessing a file system mounted to the /media/cdrom/ directory, type:
~]$ fuser -m /media/cdrom
/media/cdrom:         1793  2013  2022  2435 10532c 10672c

Example 2.9. Unmounting a CD

To unmount a CD that was previously mounted to the /media/cdrom/ directory, type the following at a shell prompt:
~]$ umount /media/cdrom

2.4. Additional Resources

The following resources provide an in-depth documentation on the subject.

2.4.1. Installed Documentation

  • man 8 mount — The manual page for the mount command that provides a full documentation on its usage.
  • man 8 umount — The manual page for the umount command that provides a full documentation on its usage.
  • man 5 fstab — The manual page providing a thorough description of the /etc/fstab file format.

2.4.2. Useful Websites

  • Shared subtrees — An LWN article covering the concept of shared subtrees.
  • sharedsubtree.txt — Extensive documentation that is shipped with the shared subtrees patches.

Chapter 3. The ext3 File System

The default file system is the journaling ext3 file system.

3.1. Features of ext3

The ext3 file system is essentially an enhanced version of the ext2 file system. These improvements provide the following advantages:
Availability
After an unexpected power failure or system crash (also called an unclean system shutdown), each mounted ext2 file system on the machine must be checked for consistency by the e2fsck program. This is a time-consuming process that can delay system boot time significantly, especially with large volumes containing a large number of files. During this time, any data on the volumes is unreachable.
The journaling provided by the ext3 file system means that this sort of file system check is no longer necessary after an unclean system shutdown. The only time a consistency check occurs using ext3 is in certain rare hardware failure cases, such as hard drive failures. The time to recover an ext3 file system after an unclean system shutdown does not depend on the size of the file system or the number of files; rather, it depends on the size of the journal used to maintain consistency. The default journal size takes about a second to recover, depending on the speed of the hardware.
Data Integrity
The ext3 file system prevents loss of data integrity in the event that an unclean system shutdown occurs. The ext3 file system allows you to choose the type and level of protection that your data receives. By default, the ext3 volumes are configured to keep a high level of data consistency with regard to the state of the file system.
Speed
Despite writing some data more than once, ext3 has a higher throughput in most cases than ext2 because ext3's journaling optimizes hard drive head motion. You can choose from three journaling modes to optimize speed, but doing so means trade-offs in regards to data integrity if the system was to fail.
Easy Transition
It is easy to migrate from ext2 to ext3 and gain the benefits of a robust journaling file system without reformatting. Refer to Section 3.3, “Converting to an ext3 File System” for more on how to perform this task.
The following sections walk you through the steps for creating and tuning ext3 partitions. For ext2 partitions, skip the partitioning and formatting sections below and go directly to Section 3.3, “Converting to an ext3 File System”.

3.2. Creating an ext3 File System

After installation, it is sometimes necessary to create a new ext3 file system. For example, if you add a new disk drive to the system, you may want to partition the drive and use the ext3 file system.
The steps for creating an ext3 file system are as follows:
  1. Format the partition with the ext3 file system using mkfs.
  2. Label the partition using e2label.

3.3. Converting to an ext3 File System

The tune2fs allows you to convert an ext2 filesystem to ext3.

Note

Always use the e2fsck utility to check your filesystem before and after using tune2fs. A default installation of Red Hat Enterprise Linux uses ext3 for all file systems.
To convert an ext2 filesystem to ext3, log in as root and type the following command in a terminal:
tune2fs -j <block_device>
where <block_device> contains the ext2 filesystem you wish to convert.
A valid block device could be one of two types of entries:
  • A mapped device — A logical volume in a volume group, for example, /dev/mapper/VolGroup00-LogVol02.
  • A static device — A traditional storage volume, for example, /dev/hdbX, where hdb is a storage device name and X is the partition number.
Issue the df command to display mounted file systems.
For the remainder of this section, the sample commands use the following value for the block device:
/dev/mapper/VolGroup00-LogVol02
You must recreate the initrd image so that it will contain the ext3 kernel module. To create this, run the mkinitrd program. For information on using the mkinitrd command, type man mkinitrd. Also, make sure your GRUB configuration loads the initrd.
If you fail to make this change, the system still boots, but the file system is mounted as ext2 instead of ext3.

3.4. Reverting to an ext2 File System

If you wish to revert a partition from ext3 to ext2 for any reason, you must first unmount the partition by logging in as root and typing,
umount /dev/mapper/VolGroup00-LogVol02
Next, change the file system type to ext2 by typing the following command as root:
tune2fs -O ^has_journal /dev/mapper/VolGroup00-LogVol02
Check the partition for errors by typing the following command as root:
e2fsck -y /dev/mapper/VolGroup00-LogVol02
Then mount the partition again as ext2 file system by typing:
mount -t ext2 /dev/mapper/VolGroup00-LogVol02 /mount/point
In the above command, replace /mount/point with the mount point of the partition.
Next, remove the .journal file at the root level of the partition by changing to the directory where it is mounted and typing:
rm -f .journal
You now have an ext2 partition.
If you want to permanently change the partition to ext2, remember to update the /etc/fstab file.

Chapter 4. The ext4 File System

4.1. Features of ext4

The ext4 file system is a scalable extension of the ext3 file system, which is the default file system of Red Hat Enterprise Linux 5. The ext4 file system can support files and file systems of up to 16 terabytes in size. It also supports an unlimited number of sub-directories (the ext3 file system only supports up to 32,000), though once the link count exceeds 65,000 it resets to 1 and is no longer increased. The following are the most important features of ext4:
Main Features
The ext4 file system uses extents (as opposed to the traditional block mapping scheme used by ext2 and ext3), which improves performance when using large files and reduces metadata overhead for large files. In addition, ext4 also labels unallocated block groups and inode table sections accordingly, which allows them to be skipped during a file system check. This makes for quicker file system checks, which becomes more beneficial as the file system grows in size.
Allocation Features
The ext4 file system features the following allocation schemes:
  • Persistent pre-allocation
  • Delayed allocation
  • Multi-block allocation
  • Stripe-aware allocation
Because of delayed allocation and other performance optimizations, ext4's behavior of writing files to disk is different from ext3. In ext4, a program's writes to the file system are not guaranteed to be on-disk unless the program issues an fsync() call afterwards.
By default, ext3 automatically forces newly created files to disk almost immediately even without fsync(). This behavior hid bugs in programs that did not use fsync() to ensure that written data was on-disk. The ext4 file system, on the other hand, often waits several seconds to write out changes to disk, allowing it to combine and reorder writes for better disk performance than ext3.

Warning

Unlike ext3, the ext4 file system does not force data to disk on transaction commit. As such, it takes longer for buffered writes to be flushed to disk. As with any file system, use data integrity calls such as fsync() to ensure that data is written to permanent storage.
Other ext4 Features
The ext4 file system also supports the following:
  • Extended attributes (xattr), which allows the system to associate several additional name/value pairs per file.
  • Quota journaling, which avoids the need for lengthy quota consistency checks after a crash.

    Note

    The only supported journaling mode in ext4 is data=ordered (default).
  • Subsecond timestamps, which allow to specify inode timestamp fields in nanosecond resolution.

4.2. Managing an ext4 File System

In order to manage ext4 file systems on Red Hat Eterprise Linux 5, it is necessary to install the e4fsprogs package. You can use the Yum utility to install the package:
~]# yum install e4fsprogs
The e4fsprogs package contains renamed static binaries from the equivalent upstream e2fsprogs release. This has been done to ensure stability of the e2fsprogs core utilities with all the changes for ext4 included. The most important of these utilities are:
  • mke4fs — A utility used to create an ext4 file system.
  • mkfs.ext4 — Another command used to create an ext4 file system.
  • e4fsck — A utility used to repair inconsistencies of an ext4 file system.
  • tune4fs — A utility used to modify ext4 file system attributes.
  • resize4fs — A utility used to resize an ext4 file system.
  • e4label — A utility used to display or modify the label of the ext4 file system.
  • dumpe4fs — A utility used to display the super block and blocks group information for the ext4 file system.
  • debuge4fs — An interactive file system debugger, used to examine ext4 file systems, manually repair corrupted file systems and create test cases for e4fsck.
The following sections walk you through the steps for creating and tuning ext4 partitions.

4.3. Creating an ext4 File System

After installation, it is sometimes necessary to create a new ext4 file system. For example, if you add a new disk drive to the system, you may want to partition the drive and use the ext4 file system.
The default options are optimal for most usage scenarios but if you need to set your ext4 file system in a specific way, see manual pages for the mke4fs and mkfs.ext4 commands for available options. Also, you may want to examine and modify the configuration file of mke4fs, /etc/mke4fs.conf, if you plan to create ext4 file systems more often.
The steps for creating an ext4 file system are as follows:
  1. Format the partition with the ext4 file system using the mkfs.ext4 or mke4fs command:
    ~]# mkfs.ext4 block_device
    ~]# mke4fs -t ext4 block_device
    where block_device is a partition which will contain the ext4 filesystem you wish to create.
  2. Label the partition using the e4label command.
    ~]# e4label <block_device> new-label
  3. Create a mount point and mount the new file system to that mount point:
    ~]# mkdir /mount/point
    ~]# mount block_device /mount/point
A valid block device could be one of two types of entries:
  • A mapped device — A logical volume in a volume group, for example, /dev/mapper/VolGroup00-LogVol02.
  • A static device — A traditional storage volume, for example, /dev/hdbX, where hdb is a storage device name and X is the partition number.
For striped block devices (for example RAID5 arrays), the stripe geometry can be specified at the time of file system creation. Using proper stripe geometry greatly enhances performance of an ext4 file system.
When creating file systems on lvm or md volumes, mkfs.ext4 chooses an optimal geometry. This may also be true on some hardware RAIDs which export geometry information to the operating system.
To specify stripe geometry, use the -E option of mkfs.ext4 (that is, extended file system options) with the following sub-options:
stride=value
Specifies the RAID chunk size.
stripe-width=value
Specifies the number of data disks in a RAID device, or the number of stripe units in the stripe.
For both sub-options, value must be specified in file system block units. For example, to create a file system with a 64k stride (that is, 16 x 4096) on a 4k-block file system, use the following command:
~]# mkfs.ext4 -E stride=16,stripe-width=64 block_device
For more information about creating file systems, refer to man mkfs.ext4.

4.4. Mounting an ext4 File System

An ext4 file system can be mounted with no extra options, same as any other file system:
~]# mount block_device /mount/point
The default mount options are optimal for most users. Options, such as acl, noacl, data, quota, noquota, user_xattr, nouser_xattr, and many others that were already used with the ext2 and ext3 file systems, are backward compatible and have the same usage and functionality. Also, with the ext4 file system, several new ext4-specific mount options have been added, for example:
barrier / nobarrier
By default, ext4 uses write barriers to ensure file system integrity even when power is lost to a device with write caches enabled. For devices without write caches, or with battery-backed write caches, you disable barriers using the nobarrier option:
~]# mount -o nobarrier block_device /mount/point
stripe=value
This option allows you to specify the number of file system blocks allocated for a single file operation. For RAID5 this number should be equal the RAID chunk size multiplied by the number of disks.
journal_ioprio=value
This option allows you to set priority of I/O operations submitted during a commit operation. The option can have a value from 7 to 0 (0 is the highest priority), and is set to 3 by default, which is slightly higher priority than the default I/O priority.
Default mount options can be also set in the file system superblock using the tune4fs utility. For example, the following command sets the file system on the /dev/mapper/VolGroup00-LogVol02 device to be mounted by default with debugging disabled and user-specified extended attributes and Posix access control lists enabled:
~]# tune4fs -o ^debug,user_xattr,acl /dev/mapper/VolGroup00-LogVol02
For more information on this topic, refer to the tune4fs(8) manual page.
An ext3 file system can also be mounted as ext4 without changing the format, allowing it to be mounted as ext3 again in the future. To do so, run the following command on a block device that contains an ext3 file system:
~]# mount -t ext4 block_device /mount/point
Doing so will only allow the ext3 file system to use ext4-specific features that do not require a file format conversion. These features include delayed allocation and multi-block allocation, and exclude features such as extent mapping.

Warning

Using the ext4 driver to mount an ext3 file system has not been fully tested on Red Hat Enterprise Linux 5. Therefore, this action is not supported because Red Hat cannot guarantee consistent performance and predictable behavior for ext3 file systems in this way.
For more information on mount options for the ext4 file system, see Section 2.2.2, “Specifying the Mount Options” and the mount(8) manual page.

Note

If you want to enable persistent mounting of the file system, remember to update the /etc/fstab file accordingly. For example:
/dev/mapper/VolGroup00-LogVol02    /test    ext4    defaults    0 0

4.5. Resizing an ext4 File System

Before growing an ext4 file system, ensure that the underlying block device is of an appropriate size to hold the file system later. Use the appropriate resizing methods for the affected block device.
When grown, the ext4 filesystem can be mounted. When shrunk, the ext4 file system has to be unmounted. You can resize an ext4 file system using the resize4fs command:
~]# resize4fs block_devicenew_size
When resizing an ext4 file system, the resize2fs utility reads the size in units of file system block size, unless a suffix indicating a specific unit is used. The following suffixes indicate specific units:
  • s — 512 byte sectors
  • K — kilobytes
  • M — megabytes
  • G — gigabytes
The size parameter is optional (and often redundant) when expanding. The resize4fs automatically expands to fill all available space of the container, usually a logical volume or partition. For more information about resizing an ext4 file system, refer to the resize4fs(8) manual page.

Chapter 5. The proc File System

The Linux kernel has two primary functions: to control access to physical devices on the computer and to schedule when and how processes interact with these devices. The /proc/ directory — also called the proc file system — contains a hierarchy of special files which represent the current state of the kernel — allowing applications and users to peer into the kernel's view of the system.
Within the /proc/ directory, one can find a wealth of information detailing the system hardware and any processes currently running. In addition, some of the files within the /proc/ directory tree can be manipulated by users and applications to communicate configuration changes to the kernel.

5.1. A Virtual File System

Under Linux, all data are stored as files. Most users are familiar with the two primary types of files: text and binary. But the /proc/ directory contains another type of file called a virtual file. It is for this reason that /proc/ is often referred to as a virtual file system.
These virtual files have unique qualities. Most of them are listed as zero bytes in size and yet when one is viewed, it can contain a large amount of information. In addition, most of the time and date settings on virtual files reflect the current time and date, indicative of the fact they are constantly updated.
Virtual files such as /proc/interrupts, /proc/meminfo, /proc/mounts, and /proc/partitions provide an up-to-the-moment glimpse of the system's hardware. Others, like the /proc/filesystems file and the /proc/sys/ directory provide system configuration information and interfaces.
For organizational purposes, files containing information on a similar topic are grouped into virtual directories and sub-directories. For instance, /proc/ide/ contains information for all physical IDE devices. Likewise, process directories contain information about each running process on the system.

5.1.1. Viewing Virtual Files

By using the cat, more, or less commands on files within the /proc/ directory, users can immediately access enormous amounts of information about the system. For example, to display the type of CPU a computer has, type cat /proc/cpuinfo to receive output similar to the following:
processor	: 0
vendor_id	: AuthenticAMD
cpu family	: 5
model		: 9
model name	: AMD-K6(tm) 3D+
Processor stepping	: 1 cpu
MHz		: 400.919
cache size	: 256 KB
fdiv_bug	: no
hlt_bug		: no
f00f_bug	: no
coma_bug	: no
fpu		: yes
fpu_exception	: yes
cpuid level	: 1
wp		: yes
flags		: fpu vme de pse tsc msr mce cx8 pge mmx syscall 3dnow k6_mtrr
bogomips	: 799.53
When viewing different virtual files in the /proc/ file system, some of the information is easily understandable while some is not human-readable. This is in part why utilities exist to pull data from virtual files and display it in a useful way. Examples of these utilities include lspci, apm, free, and top.

Note

Some of the virtual files in the /proc/ directory are readable only by the root user.

5.1.2. Changing Virtual Files

As a general rule, most virtual files within the /proc/ directory are read-only. However, some can be used to adjust settings in the kernel. This is especially true for files in the /proc/sys/ subdirectory.
To change the value of a virtual file, use the echo command and a greater than symbol (>) to redirect the new value to the file. For example, to change the hostname on the fly, type:
echo www.example.com > /proc/sys/kernel/hostname 
Other files act as binary or Boolean switches. Typing cat /proc/sys/net/ipv4/ip_forward returns either a 0 or a 1. A 0 indicates that the kernel is not forwarding network packets. Using the echo command to change the value of the ip_forward file to 1 immediately turns packet forwarding on.

Tip

Another command used to alter settings in the /proc/sys/ subdirectory is /sbin/sysctl. For more information on this command, refer to Section 5.4, “Using the sysctl Command”
For a listing of some of the kernel configuration files available in the /proc/sys/ subdirectory, refer to Section 5.3.9, “ /proc/sys/.

5.1.3. Restricting Access to Process Directories

On multi-user systems, it is often useful to secure the process directories stored in /proc/ so that they can be viewed only by the root user. You can restrict the access to these directories with the use of the hidepid option.
To change the file system parameters, you can use the mount command with the -o remount option. As root, type:
mount -o remount,hidepid=value /proc
Here, value passed to hidepid is one of:
  • 0 (default) — every user can read all world-readable files stored in a process directory.
  • 1 — users can access only their own process directories. This protects the sensitive files like cmdline, sched, or status from access by non-root users. This setting does not affect the actual file permissions.
  • 2 — process files are invisible to non-root users. The existence of a process can be learned by other means, but its effective UID and GID is hidden. Hiding these IDs complicates an intruder's task of gathering information about running processes.

Example 5.1. Restricting access to process directories

To make process files accessible only to the root user, type:
~]# mount -o remount,hidepid=1 /proc
With hidepid=1, a non-root user cannot access the contents of process directories. An attempt to do so fails with the following message:
~]$ ls /proc/1/       
ls: /proc/1/: Operation not permitted
With hidepid=2 enabled, process directories are made invisible to non-root users:
~]$ ls /proc/1/       
ls: /proc/1/: No such file or directory

Also, you can specify a user group that will have access to process files even when hidepid is set to 1 or 2. To do this, use the gid option. As root, type:
mount -o remount,hidepid=value,gid=gid /proc
Replace gid with the specific group id. For members of selected group, the process files will act as if hidepid was set to 0. However, users which are not supposed to monitor the tasks in the whole system should not be added to the group. For more information on managing users and groups see Chapter 37, Users and Groups.

5.2. Top-level Files within the proc File System

Below is a list of some of the more useful virtual files in the top-level of the /proc/ directory.

Note

In most cases, the content of the files listed in this section are not the same as those installed on your machine. This is because much of the information is specific to the hardware on which Red Hat Enterprise Linux is running for this documentation effort.

5.2.1.  /proc/apm

This file provides information about the state of the Advanced Power Management (APM) system and is used by the apm command. If a system with no battery is connected to an AC power source, this virtual file would look similar to the following:
1.16 1.2 0x07 0x01 0xff 0x80 -1% -1 ?
Running the apm -v command on such a system results in output similar to the following:
APM BIOS 1.2 (kernel driver 1.16ac) AC on-line, no system battery
For systems which do not use a battery as a power source, apm is able do little more than put the machine in standby mode. The apm command is much more useful on laptops. For example, the following output is from the command cat /proc/apm on a laptop while plugged into a power outlet:
1.16 1.2 0x03 0x01 0x03 0x09 100% -1 ?
When the same laptop is unplugged from its power source for a few minutes, the content of the apm file changes to something like the following:
1.16 1.2 0x03 0x00 0x00 0x01 99% 1792 min
The apm -v command now yields more useful data, such as the following:
APM BIOS 1.2 (kernel driver 1.16) AC off-line, battery status high: 99% (1 day, 5:52)

5.2.2.  /proc/buddyinfo

This file is used primarily for diagnosing memory fragmentation issues. Using the buddy algorithm, each column represents the number of pages of a certain order (a certain size) that are available at any given time. For example, for zone DMA (direct memory access), there are 90 of 2^(0*PAGE_SIZE) chunks of memory. Similarly, there are 6 of 2^(1*PAGE_SIZE) chunks, and 2 of 2^(2*PAGE_SIZE) chunks of memory available.
The DMA row references the first 16 MB on a system, the HighMem row references all memory greater than 4 GB on a system, and the Normal row references all memory in between.
The following is an example of the output typical of /proc/buddyinfo:
Node 0, zone      DMA     90      6      2      1      1      ...
Node 0, zone   Normal   1650    310      5      0      0      ...
Node 0, zone  HighMem      2      0      0      1      1      ...

5.2.3.  /proc/cmdline

This file shows the parameters passed to the kernel at the time it is started. A sample /proc/cmdline file looks like the following:
ro root=/dev/VolGroup00/LogVol00 rhgb quiet 3
This output tells us the following:
ro
The root device is mounted read-only at boot time. The presence of ro on the kernel boot line overrides any instances of rw.
root=/dev/VolGroup00/LogVol00
This tells us on which disk device or, in this case, on which logical volume, the root filesystem image is located. With our sample /proc/cmdline output, the root filesystem image is located on the first logical volume (LogVol00) of the first LVM volume group (VolGroup00). On a system not using Logical Volume Management, the root file system might be located on /dev/sda1 or /dev/sda2, meaning on either the first or second partition of the first SCSI or SATA disk drive, depending on whether we have a separate (preceding) boot or swap partition on that drive.
For more information on LVM used in Red Hat Enterprise Linux, refer to http://www.tldp.org/HOWTO/LVM-HOWTO/index.html.
rhgb
A short lowercase acronym that stands for Red Hat Graphical Boot, providing "rhgb" on the kernel command line signals that graphical booting is supported, assuming that /etc/inittab shows that the default runlevel is set to 5 with a line like this:
id:5:initdefault:
quiet
Indicates that all verbose kernel messages except those which are extremely serious should be suppressed at boot time.

5.2.4.  /proc/cpuinfo

This virtual file identifies the type of processor used by your system. The following is an example of the output typical of /proc/cpuinfo:
processor	: 0
vendor_id	: GenuineIntel
cpu family	: 15
model		: 2
model name	: Intel(R) Xeon(TM) CPU 2.40GHz
stepping	: 7 cpu
MHz		: 2392.371
cache size	: 512 KB
physical id	: 0
siblings	: 2
runqueue	: 0
fdiv_bug	: no
hlt_bug		: no
f00f_bug	: no
coma_bug	: no
fpu		: yes
fpu_exception	: yes
cpuid level	: 2
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca  cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm
bogomips	: 4771.02
  • processor — Provides each processor with an identifying number. On systems that have one processor, only a 0 is present.
  • cpu family — Authoritatively identifies the type of processor in the system. For an Intel-based system, place the number in front of "86" to determine the value. This is particularly helpful for those attempting to identify the architecture of an older system such as a 586, 486, or 386. Because some RPM packages are compiled for each of these particular architectures, this value also helps users determine which packages to install.
  • model name — Displays the common name of the processor, including its project name.
  • cpu MHz — Shows the precise speed in megahertz for the processor to the thousandths decimal place.
  • cache size — Displays the amount of level 2 memory cache available to the processor.
  • siblings — Displays the number of sibling CPUs on the same physical CPU for architectures which use hyper-threading.
  • flags — Defines a number of different qualities about the processor, such as the presence of a floating point unit (FPU) and the ability to process MMX instructions.

5.2.5.  /proc/crypto

This file lists all installed cryptographic ciphers used by the Linux kernel, including additional details for each. A sample /proc/crypto file looks like the following:
name         : sha1
module       : kernel
type         : digest
blocksize    : 64
digestsize   : 20
name         : md5
module       : md5
type         : digest
blocksize    : 64
digestsize   : 16

5.2.6.  /proc/devices

This file displays the various character and block devices currently configured (not including devices whose modules are not loaded). Below is a sample output from this file:
Character devices:
  1 mem
  4 /dev/vc/0
  4 tty
  4 ttyS
  5 /dev/tty
  5 /dev/console
  5 /dev/ptmx
  7 vcs
  10 misc
  13 input
  29 fb
  36 netlink
  128 ptm
  136 pts
  180 usb

Block devices:
  1 ramdisk
  3 ide0
  9 md
  22 ide1
  253 device-mapper
  254 mdp
The output from /proc/devices includes the major number and name of the device, and is broken into two major sections: Character devices and Block devices.
Character devices are similar to block devices, except for two basic differences:
  1. Character devices do not require buffering. Block devices have a buffer available, allowing them to order requests before addressing them. This is important for devices designed to store information — such as hard drives — because the ability to order the information before writing it to the device allows it to be placed in a more efficient order.
  2. Character devices send data with no preconfigured size. Block devices can send and receive information in blocks of a size configured per device.
For more information about devices refer to the following installed documentation:
/usr/share/doc/kernel-doc-<version>/Documentation/devices.txt

5.2.7.  /proc/dma

This file contains a list of the registered ISA DMA channels in use. A sample /proc/dma files looks like the following:
4: cascade

5.2.8.  /proc/execdomains

This file lists the execution domains currently supported by the Linux kernel, along with the range of personalities they support.
0-0   Linux           [kernel]
Think of execution domains as the "personality" for an operating system. Because other binary formats, such as Solaris, UnixWare, and FreeBSD, can be used with Linux, programmers can change the way the operating system treats system calls from these binaries by changing the personality of the task. Except for the PER_LINUX execution domain, different personalities can be implemented as dynamically loadable modules.

5.2.9.  /proc/fb

This file contains a list of frame buffer devices, with the frame buffer device number and the driver that controls it. Typical output of /proc/fb for systems which contain frame buffer devices looks similar to the following:
0 VESA VGA

5.2.10.  /proc/filesystems

This file displays a list of the file system types currently supported by the kernel. Sample output from a generic /proc/filesystems file looks similar to the following:
nodev   sysfs
nodev   rootfs
nodev   bdev
nodev   proc
nodev   sockfs
nodev   binfmt_misc
nodev   usbfs
nodev   usbdevfs
nodev   futexfs
nodev   tmpfs
nodev   pipefs
nodev   eventpollfs
nodev   devpts
	ext2
nodev   ramfs
nodev   hugetlbfs
	iso9660
nodev   mqueue
	ext3
nodev   rpc_pipefs
nodev   autofs
The first column signifies whether the file system is mounted on a block device. Those beginning with nodev are not mounted on a device. The second column lists the names of the file systems supported.
The mount command cycles through the file systems listed here when one is not specified as an argument.

5.2.11.  /proc/interrupts

This file records the number of interrupts per IRQ on the x86 architecture. A standard /proc/interrupts looks similar to the following:
  CPU0
  0:   80448940          XT-PIC  timer
  1:     174412          XT-PIC  keyboard
  2:          0          XT-PIC  cascade
  8:          1          XT-PIC  rtc
 10:     410964          XT-PIC  eth0
 12:      60330          XT-PIC  PS/2 Mouse
 14:    1314121          XT-PIC  ide0
 15:    5195422          XT-PIC  ide1
NMI:          0
ERR:          0
For a multi-processor machine, this file may look slightly different:
	   CPU0       CPU1
  0: 1366814704          0          XT-PIC  timer
  1:        128        340    IO-APIC-edge  keyboard
  2:          0          0          XT-PIC  cascade
  8:          0          1    IO-APIC-edge  rtc
 12:       5323       5793    IO-APIC-edge  PS/2 Mouse
 13:          1          0          XT-PIC  fpu
 16:   11184294   15940594   IO-APIC-level  Intel EtherExpress Pro 10/100 Ethernet
 20:    8450043   11120093   IO-APIC-level  megaraid
 30:      10432      10722   IO-APIC-level  aic7xxx
 31:         23         22   IO-APIC-level  aic7xxx
NMI:          0
ERR:          0
The first column refers to the IRQ number. Each CPU in the system has its own column and its own number of interrupts per IRQ. The next column reports the type of interrupt, and the last column contains the name of the device that is located at that IRQ.
Each of the types of interrupts seen in this file, which are architecture-specific, mean something different. For x86 machines, the following values are common:
  • XT-PIC — This is the old AT computer interrupts.
  • IO-APIC-edge — The voltage signal on this interrupt transitions from low to high, creating an edge, where the interrupt occurs and is only signaled once. This kind of interrupt, as well as the IO-APIC-level interrupt, are only seen on systems with processors from the 586 family and higher.
  • IO-APIC-level — Generates interrupts when its voltage signal is high until the signal is low again.

5.2.12.  /proc/iomem

This file shows you the current map of the system's memory for each physical device:
00000000-0009fbff : System RAM
0009fc00-0009ffff : reserved
000a0000-000bffff : Video RAM area
000c0000-000c7fff : Video ROM
000f0000-000fffff : System ROM
00100000-07ffffff : System RAM
00100000-00291ba8 : Kernel code
00291ba9-002e09cb : Kernel data
e0000000-e3ffffff : VIA Technologies, Inc. VT82C597 [Apollo VP3] e4000000-e7ffffff : PCI Bus #01
e4000000-e4003fff : Matrox Graphics, Inc. MGA G200 AGP
e5000000-e57fffff : Matrox Graphics, Inc. MGA G200 AGP
e8000000-e8ffffff : PCI Bus #01
e8000000-e8ffffff : Matrox Graphics, Inc. MGA G200 AGP
ea000000-ea00007f : Digital Equipment Corporation DECchip 21140 [FasterNet]
ea000000-ea00007f : tulip ffff0000-ffffffff : reserved
The first column displays the memory registers used by each of the different types of memory. The second column lists the kind of memory located within those registers and displays which memory registers are used by the kernel within the system RAM or, if the network interface card has multiple Ethernet ports, the memory registers assigned for each port.

5.2.13.  /proc/ioports

The output of /proc/ioports provides a list of currently registered port regions used for input or output communication with a device. This file can be quite long. The following is a partial listing:
0000-001f : dma1
0020-003f : pic1
0040-005f : timer
0060-006f : keyboard
0070-007f : rtc
0080-008f : dma page reg
00a0-00bf : pic2
00c0-00df : dma2
00f0-00ff : fpu
0170-0177 : ide1
01f0-01f7 : ide0
02f8-02ff : serial(auto)
0376-0376 : ide1
03c0-03df : vga+
03f6-03f6 : ide0
03f8-03ff : serial(auto)
0cf8-0cff : PCI conf1
d000-dfff : PCI Bus #01
e000-e00f : VIA Technologies, Inc. Bus Master IDE
e000-e007 : ide0
e008-e00f : ide1
e800-e87f : Digital Equipment Corporation DECchip 21140 [FasterNet]
e800-e87f : tulip
The first column gives the I/O port address range reserved for the device listed in the second column.

5.2.14.  /proc/kcore

This file represents the physical memory of the system and is stored in the core file format. Unlike most /proc/ files, kcore displays a size. This value is given in bytes and is equal to the size of the physical memory (RAM) used plus 4 KB.
The contents of this file are designed to be examined by a debugger, such as gdb, and is not human readable.

Caution

Do not view the /proc/kcore virtual file. The contents of the file scramble text output on the terminal. If this file is accidentally viewed, press Ctrl+C to stop the process and then type reset to bring back the command line prompt.

5.2.15.  /proc/kmsg

This file is used to hold messages generated by the kernel. These messages are then picked up by other programs, such as /sbin/klogd or /bin/dmesg.

5.2.16.  /proc/loadavg

This file provides a look at the load average in regard to both the CPU and IO over time, as well as additional data used by uptime and other commands. A sample /proc/loadavg file looks similar to the following:
0.20 0.18 0.12 1/80 11206
The first three columns measure CPU and IO utilization of the last one, five, and 15 minute periods. The fourth column shows the number of currently running processes and the total number of processes. The last column displays the last process ID used.
In addition, load average also refers to the number of processes ready to run (i.e. in the run queue, waiting for a CPU share.

5.2.17.  /proc/locks

This file displays the files currently locked by the kernel. The contents of this file contain internal kernel debugging data and can vary tremendously, depending on the use of the system. A sample /proc/locks file for a lightly loaded system looks similar to the following:
1: POSIX  ADVISORY  WRITE 3568 fd:00:2531452 0 EOF
2: FLOCK  ADVISORY  WRITE 3517 fd:00:2531448 0 EOF
3: POSIX  ADVISORY  WRITE 3452 fd:00:2531442 0 EOF
4: POSIX  ADVISORY  WRITE 3443 fd:00:2531440 0 EOF
5: POSIX  ADVISORY  WRITE 3326 fd:00:2531430 0 EOF
6: POSIX  ADVISORY  WRITE 3175 fd:00:2531425 0 EOF
7: POSIX  ADVISORY  WRITE 3056 fd:00:2548663 0 EOF
Each lock has its own line which starts with a unique number. The second column refers to the class of lock used, with FLOCK signifying the older-style UNIX file locks from a flock system call and POSIX representing the newer POSIX locks from the lockf system call.
The third column can have two values: ADVISORY or MANDATORY. ADVISORY means that the lock does not prevent other people from accessing the data; it only prevents other attempts to lock it. MANDATORY means that no other access to the data is permitted while the lock is held. The fourth column reveals whether the lock is allowing the holder READ or WRITE access to the file. The fifth column shows the ID of the process holding the lock. The sixth column shows the ID of the file being locked, in the format of MAJOR-DEVICE:MINOR-DEVICE:INODE-NUMBER . The seventh and eighth column shows the start and end of the file's locked region.

5.2.18.  /proc/mdstat

This file contains the current information for multiple-disk, RAID configurations. If the system does not contain such a configuration, then /proc/mdstat looks similar to the following:
Personalities :  read_ahead not set unused devices: <none>
This file remains in the same state as seen above unless a software RAID or md device is present. In that case, view /proc/mdstat to find the current status of mdX RAID devices.
The /proc/mdstat file below shows a system with its md0 configured as a RAID 1 device, while it is currently re-syncing the disks:
Personalities : [linear] [raid1] read_ahead 1024 sectors
md0: active raid1 sda2[1] sdb2[0] 9940 blocks [2/2] [UU] resync=1% finish=12.3min algorithm 2 [3/3] [UUU]
unused devices: <none>

5.2.19.  /proc/meminfo

This is one of the more commonly used files in the /proc/ directory, as it reports a large amount of valuable information about the systems RAM usage.
The following sample /proc/meminfo virtual file is from a system with 256 MB of RAM and 512 MB of swap space:
MemTotal:       255908 kB
MemFree:         69936 kB
Buffers:         15812 kB
Cached:         115124 kB
SwapCached:          0 kB
Active:          92700 kB
Inactive:        63792 kB
HighTotal:           0 kB
HighFree:            0 kB
LowTotal:       255908 kB
LowFree:         69936 kB
SwapTotal:      524280 kB
SwapFree:       524280 kB
Dirty:               4 kB
Writeback:           0 kB
Mapped:          42236 kB
Slab:            25912 kB
Committed_AS:   118680 kB
PageTables:       1236 kB
VmallocTotal:  3874808 kB
VmallocUsed:      1416 kB
VmallocChunk:  3872908 kB
HugePages_Total:     0
HugePages_Free:      0
Hugepagesize:     4096 kB
Much of the information here is used by the free, top, and ps commands. In fact, the output of the free command is similar in appearance to the contents and structure of /proc/meminfo. But by looking directly at /proc/meminfo, more details are revealed:
  • MemTotal — Total amount of physical RAM, in kilobytes.
  • MemFree — The amount of physical RAM, in kilobytes, left unused by the system.
  • Buffers — The amount of physical RAM, in kilobytes, used for file buffers.
  • Cached — The amount of physical RAM, in kilobytes, used as cache memory.
  • SwapCached — The amount of swap, in kilobytes, used as cache memory.
  • Active — The total amount of buffer or page cache memory, in kilobytes, that is in active use. This is memory that has been recently used and is usually not reclaimed for other purposes.
  • Inactive — The total amount of buffer or page cache memory, in kilobytes, that are free and available. This is memory that has not been recently used and can be reclaimed for other purposes.
  • HighTotal and HighFree — The total and free amount of memory, in kilobytes, that is not directly mapped into kernel space. The HighTotal value can vary based on the type of kernel used.
  • LowTotal and LowFree — The total and free amount of memory, in kilobytes, that is directly mapped into kernel space. The LowTotal value can vary based on the type of kernel used.
  • SwapTotal — The total amount of swap available, in kilobytes.
  • SwapFree — The total amount of swap free, in kilobytes.
  • Dirty — The total amount of memory, in kilobytes, waiting to be written back to the disk.
  • Writeback — The total amount of memory, in kilobytes, actively being written back to the disk.
  • Mapped — The total amount of memory, in kilobytes, which have been used to map devices, files, or libraries using the mmap command.
  • Slab — The total amount of memory, in kilobytes, used by the kernel to cache data structures for its own use.
  • Committed_AS — The total amount of memory, in kilobytes, estimated to complete the workload. This value represents the worst case scenario value, and also includes swap memory.
  • PageTables — The total amount of memory, in kilobytes, dedicated to the lowest page table level.
  • VMallocTotal — The total amount of memory, in kilobytes, of total allocated virtual address space.
  • VMallocUsed — The total amount of memory, in kilobytes, of used virtual address space.
  • VMallocChunk — The largest contiguous block of memory, in kilobytes, of available virtual address space.
  • HugePages_Total — The total number of hugepages for the system. The number is derived by dividing Hugepagesize by the megabytes set aside for hugepages specified in /proc/sys/vm/hugetlb_pool. This statistic only appears on the x86, Itanium, and AMD64 architectures.
  • HugePages_Free — The total number of hugepages available for the system. This statistic only appears on the x86, Itanium, and AMD64 architectures.
  • Hugepagesize — The size for each hugepages unit in kilobytes. By default, the value is 4096 KB on uniprocessor kernels for 32 bit architectures. For SMP, hugemem kernels, and AMD64, the default is 2048 KB. For Itanium architectures, the default is 262144 KB. This statistic only appears on the x86, Itanium, and AMD64 architectures.

5.2.20.  /proc/misc

This file lists miscellaneous drivers registered on the miscellaneous major device, which is device number 10:
63 device-mapper 175 agpgart 135 rtc 134 apm_bios
The first column is the minor number of each device, while the second column shows the driver in use.

5.2.21.  /proc/modules

This file displays a list of all modules loaded into the kernel. Its contents vary based on the configuration and use of your system, but it should be organized in a similar manner to this sample /proc/modules file output:

Note

This example has been reformatted into a readable format. Most of this information can also be viewed via the /sbin/lsmod command.
nfs      170109  0 -          Live 0x129b0000
lockd    51593   1 nfs,       Live 0x128b0000
nls_utf8 1729    0 -          Live 0x12830000
vfat     12097   0 -          Live 0x12823000
fat      38881   1 vfat,      Live 0x1287b000
autofs4  20293   2 -          Live 0x1284f000
sunrpc   140453  3 nfs,lockd, Live 0x12954000
3c59x    33257   0 -          Live 0x12871000
uhci_hcd 28377   0 -          Live 0x12869000
md5      3777    1 -          Live 0x1282c000
ipv6     211845 16 -          Live 0x128de000
ext3     92585   2 -          Live 0x12886000
jbd      65625   1 ext3,      Live 0x12857000
dm_mod   46677   3 -          Live 0x12833000
The first column contains the name of the module.
The second column refers to the memory size of the module, in bytes.
The third column lists how many instances of the module are currently loaded. A value of zero represents an unloaded module.
The fourth column states if the module depends upon another module to be present in order to function, and lists those other modules.
The fifth column lists what load state the module is in: Live, Loading, or Unloading are the only possible values.
The sixth column lists the current kernel memory offset for the loaded module. This information can be useful for debugging purposes, or for profiling tools such as oprofile.

5.2.22.  /proc/mounts

This file provides a list of all mounts in use by the system:
rootfs / rootfs rw 0 0
/proc /proc proc rw,nodiratime 0 0 none
/dev ramfs rw 0 0
/dev/mapper/VolGroup00-LogVol00 / ext3 rw 0 0
none /dev ramfs rw 0 0
/proc /proc proc rw,nodiratime 0 0
/sys /sys sysfs rw 0 0
none /dev/pts devpts rw 0 0
usbdevfs /proc/bus/usb usbdevfs rw 0 0
/dev/hda1 /boot ext3 rw 0 0
none /dev/shm tmpfs rw 0 0
none /proc/sys/fs/binfmt_misc binfmt_misc rw 0 0
sunrpc /var/lib/nfs/rpc_pipefs rpc_pipefs rw 0 0
The output found here is similar to the contents of /etc/mtab, except that /proc/mount is more up-to-date.
The first column specifies the device that is mounted, the second column reveals the mount point, and the third column tells the file system type, and the fourth column tells you if it is mounted read-only (ro) or read-write (rw). The fifth and sixth columns are dummy values designed to match the format used in /etc/mtab.

5.2.23.  /proc/mtrr

This file refers to the current Memory Type Range Registers (MTRRs) in use with the system. If the system architecture supports MTRRs, then the /proc/mtrr file may look similar to the following:
reg00: base=0x00000000 (   0MB), size= 256MB: write-back, count=1
reg01: base=0xe8000000 (3712MB), size=  32MB: write-combining, count=1
MTRRs are used with the Intel P6 family of processors (Pentium II and higher) and control processor access to memory ranges. When using a video card on a PCI or AGP bus, a properly configured /proc/mtrr file can increase performance more than 150%.
Most of the time, this value is properly configured by default. More information on manually configuring this file can be found locally at the following location:
/usr/share/doc/kernel-doc-<version>/Documentation/mtrr.txt

5.2.24.  /proc/partitions

This file contains partition block allocation information. A sampling of this file from a basic system looks similar to the following:
major minor  #blocks  name
  3     0   19531250 hda
  3     1     104391 hda1
  3     2   19422585 hda2
253     0   22708224 dm-0
253     1     524288 dm-1
Most of the information here is of little importance to the user, except for the following columns:
  • major — The major number of the device with this partition. The major number in the /proc/partitions, (3), corresponds with the block device ide0, in /proc/devices.
  • minor — The minor number of the device with this partition. This serves to separate the partitions into different physical devices and relates to the number at the end of the name of the partition.
  • #blocks — Lists the number of physical disk blocks contained in a particular partition.
  • name — The name of the partition.

5.2.25.  /proc/pci

This file contains a full listing of every PCI device on the system. Depending on the number of PCI devices, /proc/pci can be rather long. A sampling of this file from a basic system looks similar to the following:
Bus  0, device 0, function 0: Host bridge: Intel Corporation 440BX/ZX - 82443BX/ZX Host bridge (rev 3). Master Capable. Latency=64. Prefetchable 32 bit memory at 0xe4000000 [0xe7ffffff].
Bus  0, device 1, function 0: PCI bridge: Intel Corporation 440BX/ZX - 82443BX/ZX AGP bridge (rev 3).   Master Capable. Latency=64. Min Gnt=128.
Bus  0, device 4, function 0: ISA bridge: Intel Corporation 82371AB PIIX4 ISA (rev 2).
Bus  0, device 4, function 1: IDE interface: Intel Corporation 82371AB PIIX4 IDE (rev 1). Master Capable. Latency=32. I/O at 0xd800 [0xd80f].
Bus  0, device 4, function 2: USB Controller: Intel Corporation 82371AB PIIX4 USB (rev 1). IRQ 5. Master Capable. Latency=32. I/O at 0xd400 [0xd41f].
Bus  0, device 4, function 3: Bridge: Intel Corporation 82371AB PIIX4 ACPI (rev 2). IRQ 9.
Bus  0, device 9, function 0: Ethernet controller: Lite-On Communications Inc LNE100TX (rev 33). IRQ 5. Master Capable. Latency=32. I/O at 0xd000 [0xd0ff].
Bus  0, device 12, function  0: VGA compatible controller: S3 Inc. ViRGE/DX or /GX (rev 1). IRQ 11. Master Capable. Latency=32. Min Gnt=4.Max Lat=255.
This output shows a list of all PCI devices, sorted in the order of bus, device, and function. Beyond providing the name and version of the device, this list also gives detailed IRQ information so an administrator can quickly look for conflicts.

Tip

To get a more readable version of this information, type:
lspci -vb

5.2.26.  /proc/slabinfo

This file gives full information about memory usage on the slab level. Linux kernels greater than version 2.2 use slab pools to manage memory above the page level. Commonly used objects have their own slab pools.
Instead of parsing the highly verbose /proc/slabinfo file manually, the /usr/bin/slabtop program displays kernel slab cache information in real time. This program allows for custom configurations, including column sorting and screen refreshing.
A sample screen shot of /usr/bin/slabtop usually looks like the following example:
Active / Total Objects (% used)    : 133629 / 147300 (90.7%)
Active / Total Slabs (% used)      : 11492 / 11493 (100.0%)
Active / Total Caches (% used)     : 77 / 121 (63.6%)
Active / Total Size (% used)       : 41739.83K / 44081.89K (94.7%)
Minimum / Average / Maximum Object : 0.01K / 0.30K / 128.00K
OBJS   ACTIVE USE      OBJ   SIZE     SLABS OBJ/SLAB CACHE SIZE NAME
44814  43159  96%    0.62K   7469      6     29876K ext3_inode_cache
36900  34614  93%    0.05K    492     75      1968K buffer_head
35213  33124  94%    0.16K   1531     23      6124K dentry_cache
7364   6463  87%    0.27K    526      14      2104K radix_tree_node
2585   1781  68%    0.08K     55      47       220K vm_area_struct
2263   2116  93%    0.12K     73      31       292K size-128
1904   1125  59%    0.03K     16      119        64K size-32
1666    768  46%    0.03K     14      119        56K anon_vma
1512   1482  98%    0.44K    168       9       672K inode_cache
1464   1040  71%    0.06K     24      61        96K size-64
1320    820  62%    0.19K     66      20       264K filp
678    587  86%    0.02K      3      226        12K dm_io
678    587  86%    0.02K      3      226        12K dm_tio
576    574  99%    0.47K     72        8       288K proc_inode_cache
528    514  97%    0.50K     66        8       264K size-512
492    372  75%    0.09K     12       41        48K bio
465    314  67%    0.25K     31       15       124K size-256
452    331  73%    0.02K      2      226         8K biovec-1
420    420 100%    0.19K     21       20        84K skbuff_head_cache
305    256  83%    0.06K      5       61        20K biovec-4
290      4   1%    0.01K      1      290         4K revoke_table
264    264 100%    4.00K    264        1      1056K size-4096
260    256  98%    0.19K     13       20        52K biovec-16
260    256  98%    0.75K     52        5       208K biovec-64
Some of the more commonly used statistics in /proc/slabinfo that are included into /usr/bin/slabtop include:
  • OBJS — The total number of objects (memory blocks), including those in use (allocated), and some spares not in use.
  • ACTIVE — The number of objects (memory blocks) that are in use (allocated).
  • USE — Percentage of total objects that are active. ((ACTIVE/OBJS)(100))
  • OBJ SIZE — The size of the objects.
  • SLABS — The total number of slabs.
  • OBJ/SLAB — The number of objects that fit into a slab.
  • CACHE SIZE — The cache size of the slab.
  • NAME — The name of the slab.
For more information on the /usr/bin/slabtop program, refer to the slabtop man page.

5.2.27.  /proc/stat

This file keeps track of a variety of different statistics about the system since it was last restarted. The contents of /proc/stat, which can be quite long, usually begins like the following example:
cpu  259246 7001 60190 34250993 137517 772 0
cpu0 259246 7001 60190 34250993 137517 772 0
intr 354133732 347209999 2272 0 4 4 0 0 3 1 1249247 0 0 80143 0 422626 5169433
ctxt 12547729
btime 1093631447
processes 130523
procs_running 1
procs_blocked 0
preempt 5651840
cpu  209841 1554 21720 118519346 72939 154 27168
cpu0 42536 798 4841 14790880 14778 124 3117
cpu1 24184 569 3875 14794524 30209 29 3130
cpu2 28616 11 2182 14818198 4020 1 3493
cpu3 35350 6 2942 14811519 3045 0 3659
cpu4 18209 135 2263 14820076 12465 0 3373
cpu5 20795 35 1866 14825701 4508 0 3615
cpu6 21607 0 2201 14827053 2325 0 3334
cpu7 18544 0 1550 14831395 1589 0 3447
intr 15239682 14857833 6 0 6 6 0 5 0 1 0 0 0 29 0 2 0 0 0 0 0 0 0 94982 0 286812
ctxt 4209609
btime 1078711415
processes 21905
procs_running 1
procs_blocked 0
Some of the more commonly used statistics include:
  • cpu — Measures the number of jiffies (1/100 of a second for x86 systems) that the system has been in user mode, user mode with low priority (nice), system mode, idle task, I/O wait, IRQ (hardirq), and softirq respectively. The IRQ (hardirq) is the direct response to a hardware event. The IRQ takes minimal work for queuing the "heavy" work up for the softirq to execute. The softirq runs at a lower priority than the IRQ and therefore may be interrupted more frequently. The total for all CPUs is given at the top, while each individual CPU is listed below with its own statistics. The following example is a 4-way Intel Pentium Xeon configuration with multi-threading enabled, therefore showing four physical processors and four virtual processors totaling eight processors.
  • page — The number of memory pages the system has written in and out to disk.
  • swap — The number of swap pages the system has brought in and out.
  • intr — The number of interrupts the system has experienced.
  • btime — The boot time, measured in the number of seconds since January 1, 1970, otherwise known as the epoch.

5.2.28.  /proc/swaps

This file measures swap space and its utilization. For a system with only one swap partition, the output of /proc/swaps may look similar to the following:
Filename                          Type        Size     Used    Priority
/dev/mapper/VolGroup00-LogVol01   partition   524280   0       -1
While some of this information can be found in other files in the /proc/ directory, /proc/swaps provides a snapshot of every swap file name, the type of swap space, the total size, and the amount of space in use (in kilobytes). The priority column is useful when multiple swap files are in use. The lower the priority, the more likely the swap file is to be used.

5.2.29.  /proc/sysrq-trigger

Using the echo command to write to this file, a remote root user can execute most System Request Key commands remotely as if at the local terminal. To echo values to this file, the /proc/sys/kernel/sysrq must be set to a value other than 0. For more information about the System Request Key, refer to Section 5.3.9.3, “ /proc/sys/kernel/.
Although it is possible to write to this file, it cannot be read, even by the root user.

5.2.30.  /proc/uptime

This file contains information detailing how long the system has been on since its last restart. The output of /proc/uptime is quite minimal:
350735.47 234388.90
The first number is the total number of seconds the system has been up. The second number is how much of that time the machine has spent idle, in seconds.

5.2.31.  /proc/version

This file specifies the version of the Linux kernel and gcc in use, as well as the version of Red Hat Enterprise Linux installed on the system:
Linux version 2.6.8-1.523 (user@foo.redhat.com) (gcc version 3.4.1 20040714 \  (Red Hat Enterprise Linux 3.4.1-7)) #1 Mon Aug 16 13:27:03 EDT 2004
This information is used for a variety of purposes, including the version data presented when a user logs in.

5.3. Directories within /proc/

Common groups of information concerning the kernel are grouped into directories and subdirectories within the /proc/ directory.

5.3.1. Process Directories

Every /proc/ directory contains a number of directories with numerical names. A listing of them may be similar to the following:
dr-xr-xr-x    3 root     root            0 Feb 13 01:28 1
dr-xr-xr-x    3 root     root            0 Feb 13 01:28 1010
dr-xr-xr-x    3 xfs      xfs             0 Feb 13 01:28 1087
dr-xr-xr-x    3 daemon   daemon          0 Feb 13 01:28 1123
dr-xr-xr-x    3 root     root            0 Feb 13 01:28 11307
dr-xr-xr-x    3 apache   apache          0 Feb 13 01:28 13660
dr-xr-xr-x    3 rpc      rpc             0 Feb 13 01:28 637
dr-xr-xr-x    3 rpcuser  rpcuser         0 Feb 13 01:28 666
These directories are called process directories, as they are named after a program's process ID and contain information specific to that process. The owner and group of each process directory is set to the user running the process. When the process is terminated, its /proc/ process directory vanishes.
Each process directory contains the following files:
  • cmdline — Contains the command issued when starting the process.
  • cwd — A symbolic link to the current working directory for the process.
  • environ — A list of the environment variables for the process. The environment variable is given in all upper-case characters, and the value is in lower-case characters.
  • exe — A symbolic link to the executable of this process.
  • fd — A directory containing all of the file descriptors for a particular process. These are given in numbered links:
    total 0
    lrwx------    1 root     root           64 May  8 11:31 0 -> /dev/null
    lrwx------    1 root     root           64 May  8 11:31 1 -> /dev/null
    lrwx------    1 root     root           64 May  8 11:31 2 -> /dev/null
    lrwx------    1 root     root           64 May  8 11:31 3 -> /dev/ptmx
    lrwx------    1 root     root           64 May  8 11:31 4 -> socket:[7774817]
    lrwx------    1 root     root           64 May  8 11:31 5 -> /dev/ptmx
    lrwx------    1 root     root           64 May  8 11:31 6 -> socket:[7774829]
    lrwx------    1 root     root           64 May  8 11:31 7 -> /dev/ptmx
  • maps — A list of memory maps to the various executables and library files associated with this process. This file can be rather long, depending upon the complexity of the process, but sample output from the sshd process begins like the following:
    08048000-08086000 r-xp 00000000 03:03 391479     /usr/sbin/sshd
    08086000-08088000 rw-p 0003e000 03:03 391479	/usr/sbin/sshd
    08088000-08095000 rwxp 00000000 00:00 0
    40000000-40013000 r-xp 0000000 03:03 293205	/lib/ld-2.2.5.so
    40013000-40014000 rw-p 00013000 03:03 293205	/lib/ld-2.2.5.so
    40031000-40038000 r-xp 00000000 03:03 293282	/lib/libpam.so.0.75
    40038000-40039000 rw-p 00006000 03:03 293282	/lib/libpam.so.0.75
    40039000-4003a000 rw-p 00000000 00:00 0
    4003a000-4003c000 r-xp 00000000 03:03 293218	/lib/libdl-2.2.5.so
    4003c000-4003d000 rw-p 00001000 03:03 293218	/lib/libdl-2.2.5.so
  • mem — The memory held by the process. This file cannot be read by the user.
  • root — A link to the root directory of the process.
  • stat — The status of the process.
  • statm — The status of the memory in use by the process. Below is a sample /proc/statm file:
    263 210 210 5 0 205 0
    The seven columns relate to different memory statistics for the process. From left to right, they report the following aspects of the memory used:
    1. Total program size, in kilobytes.
    2. Size of memory portions, in kilobytes.
    3. Number of pages that are shared.
    4. Number of pages that are code.
    5. Number of pages of data/stack.
    6. Number of library pages.
    7. Number of dirty pages.
  • status — The status of the process in a more readable form than stat or statm. Sample output for sshd looks similar to the following:
    Name:	sshd
    State:	S (sleeping)
    Tgid:	797
    Pid:	797
    PPid:	1
    TracerPid:	0
    Uid:	0	0	0	0
    Gid:	0	0	0	0
    FDSize:	32
    Groups:
    VmSize:	    3072 kB
    VmLck:	       0 kB
    VmRSS:	     840 kB
    VmData:	     104 kB
    VmStk:	      12 kB
    VmExe:	     300 kB
    VmLib:	    2528 kB
    SigPnd:	0000000000000000
    SigBlk:	0000000000000000
    SigIgn:	8000000000001000
    SigCgt:	0000000000014005
    CapInh:	0000000000000000
    CapPrm:	00000000fffffeff
    CapEff:	00000000fffffeff
    The information in this output includes the process name and ID, the state (such as S (sleeping) or R (running)), user/group ID running the process, and detailed data regarding memory usage.

5.3.1.1.  /proc/self/

The /proc/self/ directory is a link to the currently running process. This allows a process to look at itself without having to know its process ID.
Within a shell environment, a listing of the /proc/self/ directory produces the same contents as listing the process directory for that process.

5.3.2.  /proc/bus/

This directory contains information specific to the various buses available on the system. For example, on a standard system containing PCI and USB buses, current data on each of these buses is available within a subdirectory within /proc/bus/ by the same name, such as /proc/bus/pci/.
The subdirectories and files available within /proc/bus/ vary depending on the devices connected to the system. However, each bus type has at least one directory. Within these bus directories are normally at least one subdirectory with a numerical name, such as 001, which contain binary files.
For example, the /proc/bus/usb/ subdirectory contains files that track the various devices on any USB buses, as well as the drivers required for them. The following is a sample listing of a /proc/bus/usb/ directory:
total 0 dr-xr-xr-x    1 root     root            0 May  3 16:25 001
-r--r--r--    1 root     root            0 May  3 16:25 devices
-r--r--r--    1 root     root            0 May  3 16:25 drivers
The /proc/bus/usb/001/ directory contains all devices on the first USB bus and the devices file identifies the USB root hub on the motherboard.
The following is a example of a /proc/bus/usb/devices file:
T:  Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=12  MxCh= 2
B:  Alloc=  0/900 us ( 0%), #Int=  0, #Iso=  0
D:  Ver= 1.00 Cls=09(hub  ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1
P:  Vendor=0000 ProdID=0000 Rev= 0.00
S:  Product=USB UHCI Root Hub
S:  SerialNumber=d400
C:* #Ifs= 1 Cfg#= 1 Atr=40 MxPwr=  0mA
I:  If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
E:  Ad=81(I) Atr=03(Int.) MxPS=   8 Ivl=255ms

5.3.3.  /proc/driver/

This directory contains information for specific drivers in use by the kernel.
A common file found here is rtc which provides output from the driver for the system's Real Time Clock (RTC), the device that keeps the time while the system is switched off. Sample output from /proc/driver/rtc looks like the following:
rtc_time        : 16:21:00
rtc_date        : 2004-08-31
rtc_epoch       : 1900
alarm           : 21:16:27
DST_enable      : no
BCD             : yes
24hr            : yes
square_wave     : no
alarm_IRQ       : no
update_IRQ      : no
periodic_IRQ    : no
periodic_freq   : 1024
batt_status     : okay
For more information about the RTC, refer to the following installed documentation:
/usr/share/doc/kernel-doc-<version>/Documentation/rtc.txt.

5.3.4.  /proc/fs

This directory shows which file systems are exported. If running an NFS server, typing cat /proc/fs/nfsd/exports displays the file systems being shared and the permissions granted for those file systems. For more on file system sharing with NFS, refer to Chapter 21, Network File System (NFS).

5.3.5.  /proc/ide/

This directory contains information about IDE devices on the system. Each IDE channel is represented as a separate directory, such as /proc/ide/ide0 and /proc/ide/ide1. In addition, a drivers file is available, providing the version number of the various drivers used on the IDE channels:
ide-floppy version 0.99.
newide ide-cdrom version 4.61
ide-disk version 1.18
Many chipsets also provide a file in this directory with additional data concerning the drives connected through the channels. For example, a generic Intel PIIX4 Ultra 33 chipset produces the /proc/ide/piix file which reveals whether DMA or UDMA is enabled for the devices on the IDE channels:
Intel PIIX4 Ultra 33 Chipset.
------------- Primary Channel ---------------- Secondary Channel -------------
		enabled                          enabled

------------- drive0 --------- drive1 -------- drive0 ---------- drive1 ------
DMA enabled:    yes              no              yes               no
UDMA enabled:   yes              no              no                no
UDMA enabled:   2                X               X                 X
UDMA DMA PIO
Navigating into the directory for an IDE channel, such as ide0, provides additional information. The channel file provides the channel number, while the model identifies the bus type for the channel (such as pci).

5.3.5.1. Device Directories

Within each IDE channel directory is a device directory. The name of the device directory corresponds to the drive letter in the /dev/ directory. For instance, the first IDE drive on ide0 would be hda.

Note

There is a symbolic link to each of these device directories in the /proc/ide/ directory.
Each device directory contains a collection of information and statistics. The contents of these directories vary according to the type of device connected. Some of the more useful files common to many devices include:
  • cache — The device cache.
  • capacity — The capacity of the device, in 512 byte blocks.
  • driver — The driver and version used to control the device.
  • geometry — The physical and logical geometry of the device.
  • media — The type of device, such as a disk.
  • model — The model name or number of the device.
  • settings — A collection of current device parameters. This file usually contains quite a bit of useful, technical information. A sample settings file for a standard IDE hard disk looks similar to the following:
    name                value          min          max          mode
    ----                -----          ---          ---          ----
    acoustic            0              0            254          rw
    address             0              0            2            rw
    bios_cyl            38752          0            65535        rw
    bios_head           16             0            255          rw
    bios_sect           63             0            63           rw
    bswap               0              0            1            r
    current_speed       68             0            70           rw
    failures            0              0            65535        rw
    init_speed          68             0            70           rw
    io_32bit            0              0            3            rw
    keepsettings        0              0            1            rw
    lun                 0              0            7            rw
    max_failures        1              0            65535        rw
    multcount           16             0            16           rw
    nice1               1              0            1            rw
    nowerr              0              0            1            rw
    number              0              0            3            rw
    pio_mode            write-only     0            255          w
    unmaskirq           0              0            1            rw
    using_dma           1              0            1            rw
    wcache              1              0            1            rw

5.3.6.  /proc/irq/

This directory is used to set IRQ to CPU affinity, which allows the system to connect a particular IRQ to only one CPU. Alternatively, it can exclude a CPU from handling any IRQs.
Each IRQ has its own directory, allowing for the individual configuration of each IRQ. The /proc/irq/prof_cpu_mask file is a bitmask that contains the default values for the smp_affinity file in the IRQ directory. The values in smp_affinity specify which CPUs handle that particular IRQ.
For more information about the /proc/irq/ directory, refer to the following installed documentation:
/usr/share/doc/kernel-doc-<version>/Documentation/filesystems/proc.txt

5.3.7.  /proc/net/

This directory provides a comprehensive look at various networking parameters and statistics. Each directory and virtual file within this directory describes aspects of the system's network configuration. Below is a partial list of the /proc/net/ directory:
  • arp — Lists the kernel's ARP table. This file is particularly useful for connecting a hardware address to an IP address on a system.
  • atm/ directory — The files within this directory contain Asynchronous Transfer Mode (ATM) settings and statistics. This directory is primarily used with ATM networking and ADSL cards.
  • dev — Lists the various network devices configured on the system, complete with transmit and receive statistics. This file displays the number of bytes each interface has sent and received, the number of packets inbound and outbound, the number of errors seen, the number of packets dropped, and more.
  • dev_mcast — Lists Layer2 multicast groups on which each device is listening.
  • igmp — Lists the IP multicast addresses which this system joined.
  • ip_conntrack — Lists tracked network connections for machines that are forwarding IP connections.
  • ip_tables_names — Lists the types of iptables in use. This file is only present if iptables is active on the system and contains one or more of the following values: filter, mangle, or nat.
  • ip_mr_cache — Lists the multicast routing cache.
  • ip_mr_vif — Lists multicast virtual interfaces.
  • netstat — Contains a broad yet detailed collection of networking statistics, including TCP timeouts, SYN cookies sent and received, and much more.
  • psched — Lists global packet scheduler parameters.
  • raw — Lists raw device statistics.
  • route — Lists the kernel's routing table.
  • rt_cache — Contains the current routing cache.
  • snmp — List of Simple Network Management Protocol (SNMP) data for various networking protocols in use.
  • sockstat — Provides socket statistics.
  • tcp — Contains detailed TCP socket information.
  • tr_rif — Lists the token ring RIF routing table.
  • udp — Contains detailed UDP socket information.
  • unix — Lists UNIX domain sockets currently in use.
  • wireless — Lists wireless interface data.

5.3.8.  /proc/scsi/

This directory is analogous to the /proc/ide/ directory, but it is for connected SCSI devices.
The primary file in this directory is /proc/scsi/scsi, which contains a list of every recognized SCSI device. From this listing, the type of device, as well as the model name, vendor, SCSI channel and ID data is available.
For example, if a system contains a SCSI CD-ROM, a tape drive, a hard drive, and a RAID controller, this file looks similar to the following:
Attached devices:
Host: scsi1
Channel: 00
Id: 05
Lun: 00
Vendor: NEC
Model: CD-ROM DRIVE:466
Rev: 1.06
Type:   CD-ROM
ANSI SCSI revision: 02
Host: scsi1
Channel: 00
Id: 06
Lun: 00
Vendor: ARCHIVE
Model: Python 04106-XXX
Rev: 7350
Type:   Sequential-Access
ANSI SCSI revision: 02
Host: scsi2
Channel: 00
Id: 06
Lun: 00
Vendor: DELL
Model: 1x6 U2W SCSI BP
Rev: 5.35
Type:   Processor
ANSI SCSI revision: 02
Host: scsi2
Channel: 02
Id: 00
Lun: 00
Vendor: MegaRAID
Model: LD0 RAID5 34556R
Rev: 1.01
Type:   Direct-Access
ANSI SCSI revision: 02
Each SCSI driver used by the system has its own directory within /proc/scsi/, which contains files specific to each SCSI controller using that driver. From the previous example, aic7xxx/ and megaraid/ directories are present, since two drivers are in use. The files in each of the directories typically contain an I/O address range, IRQ information, and statistics for the SCSI controller using that driver. Each controller can report a different type and amount of information. The Adaptec AIC-7880 Ultra SCSI host adapter's file in this example system produces the following output:
Adaptec AIC7xxx driver version: 5.1.20/3.2.4
Compile Options:
TCQ Enabled By Default : Disabled
AIC7XXX_PROC_STATS     : Enabled
AIC7XXX_RESET_DELAY    : 5
Adapter Configuration:
SCSI Adapter: Adaptec AIC-7880 Ultra SCSI host adapter
Ultra Narrow Controller     PCI MMAPed
I/O Base: 0xfcffe000
Adapter SEEPROM Config: SEEPROM found and used.
Adaptec SCSI BIOS: Enabled
IRQ: 30
SCBs: Active 0, Max Active 1, Allocated 15, HW 16, Page 255
Interrupts: 33726
BIOS Control Word: 0x18a6
Adapter Control Word: 0x1c5f
Extended Translation: Enabled
Disconnect Enable Flags: 0x00ff
Ultra Enable Flags: 0x0020
Tag Queue Enable Flags: 0x0000
Ordered Queue Tag Flags: 0x0000
Default Tag Queue Depth: 8
Tagged Queue By Device array for aic7xxx
host instance 1:       {255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255}
Actual queue depth per device for aic7xxx host instance 1:       {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
Statistics:

(scsi1:0:5:0) Device using Narrow/Sync transfers at 20.0 MByte/sec, offset 15
Transinfo settings: current(12/15/0/0), goal(12/15/0/0), user(12/15/0/0)
Total transfers 0 (0 reads and 0 writes)
		< 2K      2K+     4K+     8K+    16K+    32K+    64K+   128K+
Reads:        0       0       0       0       0       0       0       0
Writes:       0       0       0       0       0       0       0       0

(scsi1:0:6:0) Device using Narrow/Sync transfers at 10.0 MByte/sec, offset 15
Transinfo settings: current(25/15/0/0), goal(12/15/0/0), user(12/15/0/0)
Total transfers 132 (0 reads and 132 writes)
		< 2K      2K+     4K+     8K+    16K+    32K+    64K+   128K+
Reads:        0       0       0       0       0       0       0       0
Writes:       0       0       0       1     131       0       0       0
This output reveals the transfer speed to the SCSI devices connected to the controller based on channel ID, as well as detailed statistics concerning the amount and sizes of files read or written by that device. For example, this controller is communicating with the CD-ROM at 20 megabytes per second, while the tape drive is only communicating at 10 megabytes per second.

5.3.9.  /proc/sys/

The /proc/sys/ directory is different from others in /proc/ because it not only provides information about the system but also allows the system administrator to immediately enable and disable kernel features.

Caution

Use caution when changing settings on a production system using the various files in the /proc/sys/ directory. Changing the wrong setting may render the kernel unstable, requiring a system reboot.
For this reason, be sure the options are valid for that file before attempting to change any value in /proc/sys/.
A good way to determine if a particular file can be configured, or if it is only designed to provide information, is to list it with the -l option at the shell prompt. If the file is writable, it may be used to configure the kernel. For example, a partial listing of /proc/sys/fs looks like the following:
-r--r--r--    1 root     root            0 May 10 16:14 dentry-state
-rw-r--r--    1 root     root            0 May 10 16:14 dir-notify-enable
-r--r--r--    1 root     root            0 May 10 16:14 dquot-nr
-rw-r--r--    1 root     root            0 May 10 16:14 file-max
-r--r--r--    1 root     root            0 May 10 16:14 file-nr
In this listing, the files dir-notify-enable and file-max can be written to and, therefore, can be used to configure the kernel. The other files only provide feedback on current settings.
Changing a value within a /proc/sys/ file is done by echoing the new value into the file. For example, to enable the System Request Key on a running kernel, type the command:
echo 1 > /proc/sys/kernel/sysrq
This changes the value for sysrq from 0 (off) to 1 (on).
A few /proc/sys/ configuration files contain more than one value. To correctly send new values to them, place a space character between each value passed with the echo command, such as is done in this example:
echo 4 2 45 > /proc/sys/kernel/acct

Note

Any configuration changes made using the echo command disappear when the system is restarted. To make configuration changes take effect after the system is rebooted, refer to Section 5.4, “Using the sysctl Command”.
The /proc/sys/ directory contains several subdirectories controlling different aspects of a running kernel.

5.3.9.1.  /proc/sys/dev/

This directory provides parameters for particular devices on the system. Most systems have at least two directories, cdrom/ and raid/. Customized kernels can have other directories, such as parport/, which provides the ability to share one parallel port between multiple device drivers.
The cdrom/ directory contains a file called info, which reveals a number of important CD-ROM parameters:
CD-ROM information, Id: cdrom.c 3.20 2003/12/17
drive name:             hdc
drive speed:            48
drive # of slots:       1
Can close tray:         1
Can open tray:          1
Can lock tray:          1
Can change speed:       1
Can select disk:        0
Can read multisession:  1
Can read MCN:           1
Reports media changed:  1
Can play audio:         1
Can write CD-R:         0
Can write CD-RW:        0
Can read DVD:           0
Can write DVD-R:        0
Can write DVD-RAM:      0
Can read MRW:           0
Can write MRW:          0
Can write RAM:          0
This file can be quickly scanned to discover the qualities of an unknown CD-ROM. If multiple CD-ROMs are available on a system, each device is given its own column of information.
Various files in /proc/sys/dev/cdrom, such as autoclose and checkmedia, can be used to control the system's CD-ROM. Use the echo command to enable or disable these features.
If RAID support is compiled into the kernel, a /proc/sys/dev/raid/ directory becomes available with at least two files in it: speed_limit_min and speed_limit_max. These settings determine the acceleration of RAID devices for I/O intensive tasks, such as resyncing the disks.

5.3.9.2.  /proc/sys/fs/

This directory contains an array of options and information concerning various aspects of the file system, including quota, file handle, inode, and dentry information.
The binfmt_misc/ directory is used to provide kernel support for miscellaneous binary formats.
The important files in /proc/sys/fs/ include:
  • dentry-state — Provides the status of the directory cache. The file looks similar to the following:
    57411	52939	45	0	0	0
    The first number reveals the total number of directory cache entries, while the second number displays the number of unused entries. The third number tells the number of seconds between when a directory has been freed and when it can be reclaimed, and the fourth measures the pages currently requested by the system. The last two numbers are not used and display only zeros.
  • dquot-nr — Lists the maximum number of cached disk quota entries.
  • file-max — Lists the maximum number of file handles that the kernel allocates. Raising the value in this file can resolve errors caused by a lack of available file handles.
  • file-nr — Lists the number of allocated file handles, used file handles, and the maximum number of file handles.
  • overflowgid and overflowuid — Defines the fixed group ID and user ID, respectively, for use with file systems that only support 16-bit group and user IDs.
  • super-max — Controls the maximum number of superblocks available.
  • super-nr — Displays the current number of superblocks in use.

5.3.9.3.  /proc/sys/kernel/

This directory contains a variety of different configuration files that directly affect the operation of the kernel. Some of the most important files include:
  • acct — Controls the suspension of process accounting based on the percentage of free space available on the file system containing the log. By default, the file looks like the following:
    4	2	30
    The first value dictates the percentage of free space required for logging to resume, while the second value sets the threshold percentage of free space when logging is suspended. The third value sets the interval, in seconds, that the kernel polls the file system to see if logging should be suspended or resumed.
  • cap-bound — Controls the capability bounding settings, which provides a list of capabilities for any process on the system. If a capability is not listed here, then no process, no matter how privileged, can do it. The idea is to make the system more secure by ensuring that certain things cannot happen, at least beyond a certain point in the boot process.
    For a valid list of values for this virtual file, refer to the following installed documentation:
    /lib/modules/<kernel-version>/build/include/linux/capability.h.
  • ctrl-alt-del — Controls whether Ctrl+Alt+Delete gracefully restarts the computer using init (0) or forces an immediate reboot without syncing the dirty buffers to disk (1).
  • domainname — Configures the system domain name, such as example.com.
  • exec-shield — Configures the Exec Shield feature of the kernel. Exec Shield provides protection against certain types of buffer overflow attacks.
    There are two possible values for this virtual file:
    • 0 — Disables Exec Shield.
    • 1 — Enables Exec Shield. This is the default value.

    Important

    If a system is running security-sensitive applications that were started while Exec Shield was disabled, these applications must be restarted when Exec Shield is enabled in order for Exec Shield to take effect.
  • exec-shield-randomize — Enables location randomization of various items in memory. This helps deter potential attackers from locating programs and daemons in memory. Each time a program or daemon starts, it is put into a different memory location each time, never in a static or absolute memory address.
    There are two possible values for this virtual file:
    • 0 — Disables randomization of Exec Shield. This may be useful for application debugging purposes.
    • 1 — Enables randomization of Exec Shield. This is the default value. Note: The exec-shield file must also be set to 1 for exec-shield-randomize to be effective.
  • hostname — Configures the system hostname, such as www.example.com.
  • hotplug — Configures the utility to be used when a configuration change is detected by the system. This is primarily used with USB and Cardbus PCI. The default value of /sbin/hotplug should not be changed unless testing a new program to fulfill this role.
  • modprobe — Sets the location of the program used to load kernel modules. The default value is /sbin/modprobe which means kmod calls it to load the module when a kernel thread calls kmod.
  • msgmax — Sets the maximum size of any message sent from one process to another and is set to 8192 bytes by default. Be careful when raising this value, as queued messages between processes are stored in non-swappable kernel memory. Any increase in msgmax would increase RAM requirements for the system.
  • msgmnb — Sets the maximum number of bytes in a single message queue. The default is 16384.
  • msgmni — Sets the maximum number of message queue identifiers. The default is 16.
  • osrelease — Lists the Linux kernel release number. This file can only be altered by changing the kernel source and recompiling.
  • ostype — Displays the type of operating system. By default, this file is set to Linux, and this value can only be changed by changing the kernel source and recompiling.
  • overflowgid and overflowuid — Defines the fixed group ID and user ID, respectively, for use with system calls on architectures that only support 16-bit group and user IDs.
  • panic — Defines the number of seconds the kernel postpones rebooting when the system experiences a kernel panic. By default, the value is set to 0, which disables automatic rebooting after a panic.
  • printk — This file controls a variety of settings related to printing or logging error messages. Each error message reported by the kernel has a loglevel associated with it that defines the importance of the message. The loglevel values break down in this order:
    • 0 — Kernel emergency. The system is unusable.
    • 1 — Kernel alert. Action must be taken immediately.
    • 2 — Condition of the kernel is considered critical.
    • 3 — General kernel error condition.
    • 4 — General kernel warning condition.
    • 5 — Kernel notice of a normal but significant condition.
    • 6 — Kernel informational message.
    • 7 — Kernel debug-level messages.
    Four values are found in the printk file:
    6     4     1     7
    Each of these values defines a different rule for dealing with error messages. The first value, called the console loglevel, defines the lowest priority of messages printed to the console. (Note that, the lower the priority, the higher the loglevel number.) The second value sets the default loglevel for messages without an explicit loglevel attached to them. The third value sets the lowest possible loglevel configuration for the console loglevel. The last value sets the default value for the console loglevel.
  • random/ directory — Lists a number of values related to generating random numbers for the kernel.
  • rtsig-max — Configures the maximum number of POSIX real-time signals that the system may have queued at any one time. The default value is 1024.
  • rtsig-nr — Lists the current number of POSIX real-time signals queued by the kernel.
  • sem — Configures semaphore settings within the kernel. A semaphore is a System V IPC object that is used to control utilization of a particular process.
  • shmall— Sets the total amount of shared memory pages that can be used at one time, system-wide. By default, this value is 2097152.
  • shmmax — Sets the largest shared memory segment size allowed by the kernel. By default, this value is 33554432. However, the kernel supports much larger values than this.
  • shmmni — Sets the maximum number of shared memory segments for the whole system. By default, this value is 4096.
  • sysrq — Activates the System Request Key, if this value is set to anything other than zero (0), the default.
    The System Request Key allows immediate input to the kernel through simple key combinations. For example, the System Request Key can be used to immediately shut down or restart a system, sync all mounted file systems, or dump important information to the console. To initiate a System Request Key, type Alt+SysRq+ <system request code> . Replace <system request code> with one of the following system request codes:
    • r — Disables raw mode for the keyboard and sets it to XLATE (a limited keyboard mode which does not recognize modifiers such as Alt, Ctrl, or Shift for all keys).
    • k — Kills all processes active in a virtual console. Also called Secure Access Key (SAK), it is often used to verify that the login prompt is spawned from init and not a Trojan copy designed to capture usernames and passwords.
    • b — Reboots the kernel without first unmounting file systems or syncing disks attached to the system.
    • c — Crashes the system without first unmounting file systems or syncing disks attached to the system.
    • o — Shuts off the system.
    • s — Attempts to sync disks attached to the system.
    • u — Attempts to unmount and remount all file systems as read-only.
    • p — Outputs all flags and registers to the console.
    • t — Outputs a list of processes to the console.
    • m — Outputs memory statistics to the console.
    • 0 through 9 — Sets the log level for the console.
    • e — Kills all processes except init using SIGTERM.
    • i — Kills all processes except init using SIGKILL.
    • l — Kills all processes using SIGKILL (including init). The system is unusable after issuing this System Request Key code.
    • h — Displays help text.
    This feature is most beneficial when using a development kernel or when experiencing system freezes.

    Caution

    The System Request Key feature is considered a security risk because an unattended console provides an attacker with access to the system. For this reason, it is turned off by default.
    Refer to /usr/share/doc/kernel-doc-<version>/Documentation/sysrq.txt for more information about the System Request Key.
  • sysrq-key — Defines the key code for the System Request Key (84 is the default).
  • sysrq-sticky — Defines whether the System Request Key is a chorded key combination. The accepted values are as follows:
    • 0Alt+SysRq and the system request code must be pressed simultaneously. This is the default value.
    • 1Alt+SysRq must be pressed simultaneously, but the system request code can be pressed anytime before the number of seconds specified in /proc/sys/kernel/sysrq-timer elapses.
  • sysrq-timer — Specifies the number of seconds allowed to pass before the system request code must be pressed. The default value is 10.
  • tainted — Indicates whether a non-GPL module is loaded.
    • 0 — No non-GPL modules are loaded.
    • 1 — At least one module without a GPL license (including modules with no license) is loaded.
    • 2 — At least one module was force-loaded with the command insmod -f.
  • threads-max — Sets the maximum number of threads to be used by the kernel, with a default value of 2048.
  • version — Displays the date and time the kernel was last compiled. The first field in this file, such as #3, relates to the number of times a kernel was built from the source base.

5.3.9.4.  /proc/sys/net/

This directory contains subdirectories concerning various networking topics. Various configurations at the time of kernel compilation make different directories available here, such as ethernet/, ipv4/, ipx/, and ipv6/. By altering the files within these directories, system administrators are able to adjust the network configuration on a running system.
Given the wide variety of possible networking options available with Linux, only the most common /proc/sys/net/ directories are discussed.
The /proc/sys/net/core/ directory contains a variety of settings that control the interaction between the kernel and networking layers. The most important of these files are:
  • message_burst — Sets the amount of time in tenths of a second required to write a new warning message. This setting is used to mitigate Denial of Service (DoS) attacks. The default setting is 50.
  • message_cost — Sets a cost on every warning message. The higher the value of this file (default of 5), the more likely the warning message is ignored. This setting is used to mitigate DoS attacks.
    The idea of a DoS attack is to bombard the targeted system with requests that generate errors and fill up disk partitions with log files or require all of the system's resources to handle the error logging. The settings in message_burst and message_cost are designed to be modified based on the system's acceptable risk versus the need for comprehensive logging.
  • netdev_max_backlog — Sets the maximum number of packets allowed to queue when a particular interface receives packets faster than the kernel can process them. The default value for this file is 300.
  • optmem_max — Configures the maximum ancillary buffer size allowed per socket.
  • rmem_default — Sets the receive socket buffer default size in bytes.
  • rmem_max — Sets the receive socket buffer maximum size in bytes.
  • wmem_default — Sets the send socket buffer default size in bytes.
  • wmem_max — Sets the send socket buffer maximum size in bytes.
The /proc/sys/net/ipv4/ directory contains additional networking settings. Many of these settings, used in conjunction with one another, are useful in preventing attacks on the system or when using the system to act as a router.

Caution

An erroneous change to these files may affect remote connectivity to the system.
The following is a list of some of the more important files within the /proc/sys/net/ipv4/ directory:
  • icmp_destunreach_rate, icmp_echoreply_rate, icmp_paramprob_rate, and icmp_timeexeed_rate — Set the maximum ICMP send packet rate, in 1/100 of a second, to hosts under certain conditions. A setting of 0 removes any delay and is not a good idea.
  • icmp_echo_ignore_all and icmp_echo_ignore_broadcasts — Allows the kernel to ignore ICMP ECHO packets from every host or only those originating from broadcast and multicast addresses, respectively. A value of 0 allows the kernel to respond, while a value of 1 ignores the packets.
  • ip_default_ttl — Sets the default Time To Live (TTL), which limits the number of hops a packet may make before reaching its destination. Increasing this value can diminish system performance.
  • ip_forward — Permits interfaces on the system to forward packets to one other. By default, this file is set to 0. Setting this file to 1 enables network packet forwarding.
  • ip_local_port_range — Specifies the range of ports to be used by TCP or UDP when a local port is needed. The first number is the lowest port to be used and the second number specifies the highest port. Any systems that expect to require more ports than the default 1024 to 4999 should use a range from 32768 to 61000.
  • tcp_syn_retries — Provides a limit on the number of times the system re-transmits a SYN packet when attempting to make a connection.
  • tcp_retries1 — Sets the number of permitted re-transmissions attempting to answer an incoming connection. Default of 3.
  • tcp_retries2 — Sets the number of permitted re-transmissions of TCP packets. Default of 15.
The file called
/usr/share/doc/kernel-doc-<version>/Documentation/networking/ ip-sysctl.txt
contains a complete list of files and options available in the /proc/sys/net/ipv4/ directory.
A number of other directories exist within the /proc/sys/net/ipv4/ directory and each covers a different aspect of the network stack. The /proc/sys/net/ipv4/conf/ directory allows each system interface to be configured in different ways, including the use of default settings for unconfigured devices (in the /proc/sys/net/ipv4/conf/default/ subdirectory) and settings that override all special configurations (in the /proc/sys/net/ipv4/conf/all/ subdirectory).
The /proc/sys/net/ipv4/neigh/ directory contains settings for communicating with a host directly connected to the system (called a network neighbor) and also contains different settings for systems more than one hop away.
Routing over IPV4 also has its own directory, /proc/sys/net/ipv4/route/. Unlike conf/ and neigh/, the /proc/sys/net/ipv4/route/ directory contains specifications that apply to routing with any interfaces on the system. Many of these settings, such as max_size, max_delay, and min_delay, relate to controlling the size of the routing cache. To clear the routing cache, write any value to the flush file.
Additional information about these directories and the possible values for their configuration files can be found in:
/usr/share/doc/kernel-doc-<version>/Documentation/filesystems/proc.txt

5.3.9.5.  /proc/sys/vm/

This directory facilitates the configuration of the Linux kernel's virtual memory (VM) subsystem. The kernel makes extensive and intelligent use of virtual memory, which is commonly referred to as swap space.
The following files are commonly found in the /proc/sys/vm/ directory:
  • block_dump — Configures block I/O debugging when enabled. All read/write and block dirtying operations done to files are logged accordingly. This can be useful if diagnosing disk spin up and spin downs for laptop battery conservation. All output when block_dump is enabled can be retrieved via dmesg. The default value is 0.

    Tip

    If block_dump is enabled at the same time as kernel debugging, it is prudent to stop the klogd daemon, as it generates erroneous disk activity caused by block_dump.
  • dirty_background_ratio — Starts background writeback of dirty data at this percentage of total memory, via a pdflush daemon. The default value is 10.
  • dirty_expire_centisecs — Defines when dirty in-memory data is old enough to be eligible for writeout. Data which has been dirty in-memory for longer than this interval is written out next time a pdflush daemon wakes up. The default value is 3000, expressed in hundredths of a second.
  • dirty_ratio — Starts active writeback of dirty data at this percentage of total memory for the generator of dirty data, via pdflush. The default value is 40.
  • dirty_writeback_centisecs — Defines the interval between pdflush daemon wakeups, which periodically writes dirty in-memory data out to disk. The default value is 500, expressed in hundredths of a second.
  • laptop_mode — Minimizes the number of times that a hard disk needs to spin up by keeping the disk spun down for as long as possible, therefore conserving battery power on laptops. This increases efficiency by combining all future I/O processes together, reducing the frequency of spin ups. The default value is 0, but is automatically enabled in case a battery on a laptop is used.
    This value is controlled automatically by the acpid daemon once a user is notified battery power is enabled. No user modifications or interactions are necessary if the laptop supports the ACPI (Advanced Configuration and Power Interface) specification.
    For more information, refer to the following installed documentation:
    /usr/share/doc/kernel-doc-<version>/Documentation/laptop-mode.txt
  • lower_zone_protection — Determines how aggressive the kernel is in defending lower memory allocation zones. This is effective when utilized with machines configured with highmem memory space enabled. The default value is 0, no protection at all. All other integer values are in megabytes, and lowmem memory is therefore protected from being allocated by users.
    For more information, refer to the following installed documentation:
    /usr/share/doc/kernel-doc-<version>/Documentation/filesystems/proc.txt
  • max_map_count — Configures the maximum number of memory map areas a process may have. In most cases, the default value of 65536 is appropriate.
  • min_free_kbytes — Forces the Linux VM (virtual memory manager) to keep a minimum number of kilobytes free. The VM uses this number to compute a pages_min value for each lowmem zone in the system. The default value is in respect to the total memory on the machine.
  • nr_hugepages — Indicates the current number of configured hugetlb pages in the kernel.
    For more information, refer to the following installed documentation:
    /usr/share/doc/kernel-doc-<version>/Documentation/vm/hugetlbpage.txt
  • nr_pdflush_threads — Indicates the number of pdflush daemons that are currently running. This file is read-only, and should not be changed by the user. Under heavy I/O loads, the default value of two is increased by the kernel.
  • overcommit_memory — Configures the conditions under which a large memory request is accepted or denied. The following three modes are available:
    • 0 — The kernel performs heuristic memory over commit handling by estimating the amount of memory available and failing requests that are blatantly invalid. Unfortunately, since memory is allocated using a heuristic rather than a precise algorithm, this setting can sometimes allow available memory on the system to be overloaded. This is the default setting.
    • 1 — The kernel performs no memory over commit handling. Under this setting, the potential for memory overload is increased, but so is performance for memory intensive tasks (such as those executed by some scientific software).
    • 2 — The kernel fails requests for memory that add up to all of swap plus the percent of physical RAM specified in /proc/sys/vm/overcommit_ratio. This setting is best for those who desire less risk of memory overcommitment.

      Note

      This setting is only recommended for systems with swap areas larger than physical memory.
  • overcommit_ratio — Specifies the percentage of physical RAM considered when /proc/sys/vm/overcommit_memory is set to 2. The default value is 50.
  • page-cluster — Sets the number of pages read in a single attempt. The default value of 3, which actually relates to 16 pages, is appropriate for most systems.
  • swappiness — Determines how much a machine should swap. The higher the value, the more swapping occurs. The default value, as a percentage, is set to 60.
All kernel-based documentation can be found in the following locally installed location:
/usr/share/doc/kernel-doc-<version>/Documentation/, which contains additional information.

5.3.10.  /proc/sysvipc/

This directory contains information about System V IPC resources. The files in this directory relate to System V IPC calls for messages (msg), semaphores (sem), and shared memory (shm).

5.3.11.  /proc/tty/

This directory contains information about the available and currently used tty devices on the system. Originally called teletype devices, any character-based data terminals are called tty devices.
In Linux, there are three different kinds of tty devices. Serial devices are used with serial connections, such as over a modem or using a serial cable. Virtual terminals create the common console connection, such as the virtual consoles available when pressing Alt+<F-key> at the system console. Pseudo terminals create a two-way communication that is used by some higher level applications, such as XFree86. The drivers file is a list of the current tty devices in use, as in the following example:
serial               /dev/cua        5  64-127 serial:callout
serial               /dev/ttyS       4  64-127 serial
pty_slave            /dev/pts      136   0-255 pty:slave
pty_master           /dev/ptm      128   0-255 pty:master
pty_slave            /dev/ttyp       3   0-255 pty:slave
pty_master           /dev/pty        2   0-255 pty:master
/dev/vc/0            /dev/vc/0       4       0 system:vtmaster
/dev/ptmx            /dev/ptmx       5       2 system
/dev/console         /dev/console    5       1 system:console
/dev/tty             /dev/tty        5       0 system:/dev/tty
unknown              /dev/vc/%d      4    1-63 console
The /proc/tty/driver/serial file lists the usage statistics and status of each of the serial tty lines.
In order for tty devices to be used as network devices, the Linux kernel enforces line discipline on the device. This allows the driver to place a specific type of header with every block of data transmitted over the device, making it possible for the remote end of the connection to a block of data as just one in a stream of data blocks. SLIP and PPP are common line disciplines, and each are commonly used to connect systems to one other over a serial link.
Registered line disciplines are stored in the ldiscs file, and more detailed information is available within the ldisc/ directory.

5.3.12.  /proc/<PID>/

Out of Memory (OOM) refers to a computing state where all available memory, including swap space, has been allocated. When this situation occurs, it will cause the system to panic and stop functioning as expected. There is a switch that controls OOM behavior in /proc/sys/vm/panic_on_oom. When set to 1 the kernel will panic on OOM. A setting of 0 instructs the kernel to call a function named oom_killer on an OOM. Usually, oom_killer can kill rogue processes and the system will survive.
The easiest way to change this is to echo the new value to /proc/sys/vm/panic_on_oom.
~]# cat /proc/sys/vm/panic_on_oom
1
~]# echo 0 > /proc/sys/vm/panic_on_oom
~]# cat /proc/sys/vm/panic_on_oom
0
It is also possible to prioritize which processes get killed by adjusting the oom_killer score. In /proc/<PID>/ there are two tools labelled oom_adj and oom_score. Valid scores for oom_adj are in the range -16 to +15. To see the current oom_killer score, view the oom_score for the process. oom_killer will kill processes with the highest scores first.
This example adjusts the oom_score of a process with a PID of 12465 to make it less likely that oom_killer will kill it.
~]# cat /proc/12465/oom_score
79872
~]# echo -5 > /proc/12465/oom_adj
~]# cat /proc/12465/oom_score
78
There is also a special value of -17, which disables oom_killer for that process. In the example below, oom_score returns a value of 0, indicating that this process would not be killed.
~]# cat /proc/12465/oom_score
78
~]# echo -17 > /proc/12465/oom_adj
~]# cat /proc/12465/oom_score
0
A function called badness() is used to determine the actual score for each process. This is done by adding up 'points' for each examined process. The process scoring is done in the following way:
  1. The basis of each process's score is its memory size.
  2. The memory size of any of the process's children (not including a kernel thread) is also added to the score
  3. The process's score is increased for 'niced' processes and decreased for long running processes.
  4. Processes with the CAP_SYS_ADMIN and CAP_SYS_RAWIO capabilities have their scores reduced.
  5. The final score is then bitshifted by the value saved in the oom_adj file.
Thus, a process with the highest oom_score value will most probably be a non-privileged, recently started process that, along with its children, uses a large amount of memory, has been 'niced', and handles no raw I/O.

5.4. Using the sysctl Command

The /sbin/sysctl command is used to view, set, and automate kernel settings in the /proc/sys/ directory.
For a quick overview of all settings configurable in the /proc/sys/ directory, type the /sbin/sysctl -a command as root. This creates a large, comprehensive list, a small portion of which looks something like the following:
net.ipv4.route.min_delay = 2 kernel.sysrq = 0 kernel.sem = 250     32000     32     128
This is the same information seen if each of the files were viewed individually. The only difference is the file location. For example, the /proc/sys/net/ipv4/route/min_delay file is listed as net.ipv4.route.min_delay, with the directory slashes replaced by dots and the proc.sys portion assumed.
The sysctl command can be used in place of echo to assign values to writable files in the /proc/sys/ directory. For example, instead of using the command
echo 1 > /proc/sys/kernel/sysrq
use the equivalent sysctl command as follows:
~]# sysctl -w kernel.sysrq="1"
kernel.sysrq = 1
While quickly setting single values like this in /proc/sys/ is helpful during testing, this method does not work as well on a production system as special settings within /proc/sys/ are lost when the machine is rebooted. To preserve custom settings, add them to the /etc/sysctl.conf file.
Each time the system boots, the init program runs the /etc/rc.d/rc.sysinit script. This script contains a command to execute sysctl using /etc/sysctl.conf to determine the values passed to the kernel. Any values added to /etc/sysctl.conf therefore take effect each time the system boots.

5.5. Additional Resources

Below are additional sources of information about proc file system.

5.5.1. Installed Documentation

Some of the best documentation about the proc file system is installed on the system by default.
  • /usr/share/doc/kernel-doc-<version>/Documentation/filesystems/proc.txt — Contains assorted, but limited, information about all aspects of the /proc/ directory.
  • /usr/share/doc/kernel-doc-<version>/Documentation/sysrq.txt — An overview of System Request Key options.
  • /usr/share/doc/kernel-doc-<version>/Documentation/sysctl/ — A directory containing a variety of sysctl tips, including modifying values that concern the kernel (kernel.txt), accessing file systems (fs.txt), and virtual memory use (vm.txt).
  • /usr/share/doc/kernel-doc-<version>/Documentation/networking/ip-sysctl.txt — A detailed overview of IP networking options.

5.5.2. Useful Websites

  • http://www.linuxhq.com/ — This website maintains a complete database of source, patches, and documentation for various versions of the Linux kernel.

Chapter 6. Redundant Array of Independent Disks (RAID)

The basic idea behind RAID is to combine multiple small, inexpensive disk drives into an array to accomplish performance or redundancy goals not attainable with one large and expensive drive. This array of drives appears to the computer as a single logical storage unit or drive.

6.1. What is RAID?

RAID allows information to access several disks. RAID uses techniques such as disk striping (RAID Level 0), disk mirroring (RAID Level 1), and disk striping with parity (RAID Level 5) to achieve redundancy, lower latency, increased bandwidth, and maximized ability to recover from hard disk crashes.
RAID consistently distributes data across each drive in the array. RAID then breaks down the data into consistently-sized chunks (commonly 32K or 64k, although other values are acceptable). Each chunk is then written to a hard drive in the RAID array according to the RAID level employed. When the data is read, the process is reversed, giving the illusion that the multiple drives in the array are actually one large drive.

6.1.1. Who Should Use RAID?

System Administrators and others who manage large amounts of data would benefit from using RAID technology. Primary reasons to deploy RAID include:
  • Enhances speed
  • Increases storage capacity using a single virtual disk
  • Minimizes disk failure

6.1.2. Hardware RAID versus Software RAID

There are two possible RAID approaches: hardware RAID and software RAID.
Hardware RAID
The hardware-based array manages the RAID subsystem independently from the host. It presents a single disk per RAID array to the host.
A hardware RAID device connects to the SCSI controller and presents the RAID arrays as a single SCSI drive. An external RAID system moves all RAID handling intelligence into a controller located in the external disk subsystem. The whole subsystem is connected to the host via a normal SCSI controller and appears to the host as a single disk.
RAID controller cards function like a SCSI controller to the operating system, and handle all the actual drive communications. The user plugs the drives into the RAID controller (just like a normal SCSI controller) and then adds them to the RAID controllers configuration, and the operating system won't know the difference.
Software RAID
Software RAID implements the various RAID levels in the kernel disk (block device) code. It offers the cheapest possible solution, as expensive disk controller cards or hot-swap chassis[1] are not required. Software RAID also works with cheaper IDE disks as well as SCSI disks. With today's faster CPUs, software RAID outperforms hardware RAID.
The Linux kernel contains an MD driver that allows the RAID solution to be completely hardware independent. The performance of a software-based array depends on the server CPU performance and load.
To learn more about software RAID, here are the key features:
  • Threaded rebuild process
  • Kernel-based configuration
  • Portability of arrays between Linux machines without reconstruction
  • Backgrounded array reconstruction using idle system resources
  • Hot-swappable drive support
  • Automatic CPU detection to take advantage of certain CPU optimizations

6.1.3. RAID Levels and Linear Support

RAID supports various configurations, including levels 0, 1, 4, 5, and linear. These RAID types are defined as follows:
Level 0
RAID level 0, often called striping, is a performance-oriented striped data mapping technique. This means the data being written to the array is broken down into strips and written across the member disks of the array, allowing high I/O performance at low inherent cost but provides no redundancy. The storage capacity of a level 0 array is equal to the total capacity of the member disks in a hardware RAID or the total capacity of member partitions in a software RAID.
Level 1
RAID level 1, or mirroring, has been used longer than any other form of RAID. Level 1 provides redundancy by writing identical data to each member disk of the array, leaving a mirrored copy on each disk. Mirroring remains popular due to its simplicity and high level of data availability. Level 1 operates with two or more disks that may use parallel access for high data-transfer rates when reading but more commonly operate independently to provide high I/O transaction rates. Level 1 provides very good data reliability and improves performance for read-intensive applications but at a relatively high cost. The storage capacity of the level 1 array is equal to the capacity of one of the mirrored hard disks in a hardware RAID or one of the mirrored partitions in a software RAID.

Note

RAID level 1 comes at a high cost because you write the same information to all of the disks in the array, which wastes drive space. For example, if you have RAID level 1 set up so that your root (/) partition exists on two 40G drives, you have 80G total but are only able to access 40G of that 80G. The other 40G acts like a mirror of the first 40G.
Level 4
RAID level 4 uses parity[2] concentrated on a single disk drive to protect data. It is better suited to transaction I/O rather than large file transfers. Because the dedicated parity disk represents an inherent bottleneck, level 4 is seldom used without accompanying technologies such as write-back caching. Although RAID level 4 is an option in some RAID partitioning schemes, it is not an option allowed in Red Hat Enterprise Linux RAID installations. The storage capacity of hardware RAID level 4 is equal to the capacity of member disks, minus the capacity of one member disk. The storage capacity of software RAID level 4 is equal to the capacity of the member partitions, minus the size of one of the partitions if they are of equal size.

Note

RAID level 4 takes up the same amount of space as RAID level 5, but level 5 has more advantages. For this reason, level 4 is not supported.
Level 5
RAID level 5 is the most common type of RAID. By distributing parity across some or all of an array's member disk drives, RAID level 5 eliminates the write bottleneck inherent in level 4. The only performance bottleneck is the parity calculation process. With modern CPUs and software RAID, that usually is not a very big problem. As with level 4, the result is asymmetrical performance, with reads substantially outperforming writes. Level 5 is often used with write-back caching to reduce the asymmetry. The storage capacity of hardware RAID level 5 is equal to the capacity of member disks, minus the capacity of one member disk. The storage capacity of software RAID level 5 is equal to the capacity of the member partitions, minus the size of one of the partitions if they are of equal size.
Linear RAID
Linear RAID is a simple grouping of drives to create a larger virtual drive. In linear RAID, the chunks are allocated sequentially from one member drive, going to the next drive only when the first is completely filled. This grouping provides no performance benefit, as it is unlikely that any I/O operations will be split between member drives. Linear RAID also offers no redundancy and, in fact, decreases reliability — if any one member drive fails, the entire array cannot be used. The capacity is the total of all member disks.

6.2. Configuring Software RAID

Users can configure software RAID during the graphical installation process, the text-based installation process, or during a kickstart installation. This section discusses software RAID configuration during the installation process using the Disk Druid application, and covers the following steps:
  1. Creating software RAID partitions on physical hard drives.
  2. Creating RAID devices from the software RAID partitions.
  3. (Optional) Configuring LVM from the RAID devices.
  4. Creating file systems from the RAID devices.
To configure software RAID, select Create custom layout from the pulldown list on the Disk Partitioning Setup screen, click the Next button, and follow the instructions in the rest of this section. The example screenshots in this section use two 10 GB disk drives (/dev/hda and /dev/hdb) to illustrate the creation of simple RAID 1 and RAID 0 configurations, and detail how to create a simple RAID configuration by implementing multiple RAID devices.

6.2.1. Creating the RAID Partitions

In a typical situation, the disk drives are new or are formatted. Both drives are shown as raw devices with no partition configuration in Figure 6.1, “Two Blank Drives, Ready For Configuration”.
Two Blank Drives, Ready For Configuration

Figure 6.1. Two Blank Drives, Ready For Configuration


  1. In Disk Druid, click the RAID button to enter the software RAID creation screen.
  2. Choose Create a software RAID partition to create a RAID partition as shown in Figure 6.2, “RAID Partition Options”. Note that no other RAID options (such as entering a mount point) are available until RAID partitions, as well as RAID devices, are created. Click OK to confirm the choice.
    RAID Partition Options

    Figure 6.2. RAID Partition Options


  3. A software RAID partition must be constrained to one drive. For Allowable Drives, select the drive to use for RAID. If you have multiple drives, by default all drives are selected and you must deselect the drives you do not want.
    Adding a RAID Partition

    Figure 6.3. Adding a RAID Partition


  4. Edit the Size (MB) field, and enter the size that you want the partition to be (in MB).
  5. Select Fixed Size to specify partition size. Select Fill all space up to (MB) and enter a value (in MB) to specify partition size range. Select Fill to maximum allowable size to allow maximum available space of the hard disk. Note that if you make more than one space growable, they share the available free space on the disk.
  6. Select Force to be a primary partition if you want the partition to be a primary partition. A primary partition is one of the first four partitions on the hard drive. If unselected, the partition is created as a logical partition. If other operating systems are already on the system, unselecting this option should be considered. For more information on primary versus logical/extended partitions, refer to the appendix section of the Red Hat Enterprise Linux Installation Guide.
Repeat these steps to create as many partitions as needed for your RAID setup. Notice that all the partitions do not have to be RAID partitions. For example, you can configure only the /boot partition as a software RAID device, leaving the root partition (/), /home, and swap as regular file systems. Figure 6.4, “RAID 1 Partitions Ready, Pre-Device and Mount Point Creation” shows successfully allocated space for the RAID 1 configuration (for /boot), which is now ready for RAID device and mount point creation:
RAID 1 Partitions Ready, Pre-Device and Mount Point Creation

Figure 6.4. RAID 1 Partitions Ready, Pre-Device and Mount Point Creation


6.2.2. Creating the RAID Devices and Mount Points

Once you create all of your partitions as software RAID partitions, you must create the RAID device and mount point.
  1. On the main partitioning screen, click the RAID button. The RAID Options dialog appears as shown in Figure 6.5, “RAID Options”.
    RAID Options

    Figure 6.5. RAID Options


  2. Select the Create a RAID device option, and click OK. As shown in Figure 6.6, “Making a RAID Device and Assigning a Mount Point”, the Make RAID Device dialog appears, allowing you to make a RAID device and assign a mount point.
    Making a RAID Device and Assigning a Mount Point

    Figure 6.6. Making a RAID Device and Assigning a Mount Point


  3. Select a mount point from the Mount Point pulldown list.
  4. Choose the file system type for the partition from the File System Type pulldown list. At this point you can either configure a dynamic LVM file system or a traditional static ext2/ext3 file system. For more information on LVM and its configuration during the installation process, refer to Chapter 11, LVM (Logical Volume Manager). If LVM is not required, continue on with the following instructions.
  5. From the RAID Device pulldown list, select a device name such as md0.
  6. From the RAID Level, choose the required RAID level.

    Note

    If you are making a RAID partition of /boot, you must choose RAID level 1, and it must use one of the first two drives (IDE first, SCSI second). If you are not creating a separate RAID partition of /boot, and you are making a RAID partition for the root file system (that is, /), it must be RAID level 1 and must use one of the first two drives (IDE first, SCSI second).
  7. The RAID partitions created appear in the RAID Members list. Select which of these partitions should be used to create the RAID device.
  8. If configuring RAID 1 or RAID 5, specify the number of spare partitions in the Number of spares field. If a software RAID partition fails, the spare is automatically used as a replacement. For each spare you want to specify, you must create an additional software RAID partition (in addition to the partitions for the RAID device). Select the partitions for the RAID device and the partition(s) for the spare(s).
  9. Click OK to confirm the setup. The RAID device appears in the Drive Summary list.
  10. Repeat this chapter's entire process for configuring additional partitions, devices, and mount points, such as the root partition (/), home partition (/home), or swap.
After completing the entire configuration, the figure as shown in Figure 6.7, “Sample RAID Configuration” resembles the default configuration, except for the use of RAID.
Sample RAID Configuration

Figure 6.7. Sample RAID Configuration


The figure as shown in Figure 6.8, “Sample RAID With LVM Configuration” is an example of a RAID and LVM configuration.
Sample RAID With LVM Configuration

Figure 6.8. Sample RAID With LVM Configuration


You can proceed with your installation process by clicking Next. Refer to the Red Hat Enterprise Linux Installation Guide for further instructions.

6.3. Managing Software RAID

This section discusses software RAID configuration and management after the installation, and covers the following topics:
  • Reviewing existing software RAID configuration.
  • Creating a new RAID device.
  • Replacing a faulty device in an array.
  • Adding a new device to an existing array.
  • Deactivating and removing an existing RAID device.
  • Saving the configuration.
All examples in this section use the software RAID configuration from the previous section.

6.3.1. Reviewing RAID Configuration

When a software RAID is in use, basic information about all presently active RAID devices are stored in the /proc/mdstat special file. To list these devices, display the content of this file by typing the following at a shell prompt:
cat /proc/mdstat
To determine whether a certain device is a RAID device or a component device, run the command in the following form as root:
mdadm --query device
In order to examine a RAID device in more detail, use the following command:
mdadm --detail raid_device
Similarly, to examine a component device, type:
mdadm --examine component_device
While the mdadm --detail command displays information about a RAID device, mdadm --examine only relays information about a RAID device as it relates to a given component device. This distinction is particularly important when working with a RAID device that itself is a component of another RAID device.
The mdadm --query command, as well as both mdadm --detail and mdadm --examine commands allow you to specify multiple devices at once.

Example 6.1. Reviewing RAID configuration

Assume the system uses configuration from Figure 6.7, “Sample RAID Configuration”. You can verify that /dev/md0 is a RAID device by typing the following at a shell prompt:
~]# mdadm --query /dev/md0
/dev/md0: 125.38MiB raid1 2 devices, 0 spares. Use mdadm --detail for more detail.
/dev/md0: No md super block found, not an md component.
As you can see, the above command produces only a brief overview of the RAID device and its configuration. To display more detailed information, use the following command instead:
~]# mdadm --detail /dev/md0
/dev/md0:
        Version : 0.90
  Creation Time : Tue Jun 28 16:05:49 2011
     Raid Level : raid1
     Array Size : 128384 (125.40 MiB 131.47 MB)
  Used Dev Size : 128384 (125.40 MiB 131.47 MB)
   Raid Devices : 2
  Total Devices : 2
Preferred Minor : 0
    Persistence : Superblock is persistent

    Update Time : Thu Jun 30 17:06:34 2011
          State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

           UUID : 49c5ac74:c2b79501:5c28cb9c:16a6dd9f
         Events : 0.6

    Number   Major   Minor   RaidDevice State
       0       3        1        0      active sync   /dev/hda1
       1       3       65        1      active sync   /dev/hdb1
Finally, to list all presently active RAID devices, type:
~]$ cat /proc/mdstat
Personalities : [raid0] [raid1]
md0 : active raid1 hdb1[1] hda1[0]
      128384 blocks [2/2] [UU]
      
md1 : active raid0 hdb2[1] hda2[0]
      1573888 blocks 256k chunks

md2 : active raid0 hdb3[1] hda3[0]
      19132928 blocks 256k chunks

unused devices: <none>

6.3.2. Creating a New RAID Device

To create a new RAID device, use the command in the following form as root:
mdadm --create raid_device --level=level --raid-devices=number component_device
This is the simplest way to create a RAID array. There are many more options that allow you to specify the number of spare devices, the block size of a stripe array, if the array has a write-intent bitmap, and much more. All these options can have a significant impact on the performance, but are beyond the scope of this document. For more detailed information, refer to the CREATE MODE section of the mdadm(8) manual page.

Example 6.2. Creating a new RAID device

Assume that the system has two unused SCSI disk drives available, and that each of these devices has exactly one partition of the same size:
~]# ls /dev/sd*
/dev/sda  /dev/sda1  /dev/sdb  /dev/sdb1
To create /dev/md3 as a new RAID level 1 array from /dev/sda1 and /dev/sdb1, run the following command:
~]# mdadm --create /dev/md3 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1
mdadm: array /dev/md3 started.

6.3.3. Replacing a Faulty Device

To replace a particular device in a software RAID, first make sure it is marked as faulty by running the following command as root:
mdadm raid_device --fail component_device
Then remove the faulty device from the array by using the command in the following form:
mdadm raid_device --remove component_device
Once the device is operational again, you can re-add it to the array:
mdadm raid_device --add component_device

Example 6.3. Replacing a faulty device

Assume the system has an active RAID device, /dev/md3, with the following layout (that is, the RAID device created in Example 6.2, “Creating a new RAID device”):
~]# mdadm --detail /dev/md3 | tail -n 3
    Number   Major   Minor   RaidDevice State
       0       8        1        0      active sync   /dev/sda1
       1       8       17        1      active sync   /dev/sdb1
Imagine the first disk drive fails and needs to be replaced. To do so, first mark the /dev/sdb1 device as faulty:
~]# mdadm /dev/md3 --fail /dev/sdb1
mdadm: set /dev/sdb1 faulty in /dev/md3
Then remove it from the RAID device:
~]# mdadm /dev/md3 --remove /dev/sdb1
mdadm: hot removed /dev/sdb1
As soon as the hardware is replaced, you can add the device back to the array by using the following command:
~]# mdadm /dev/md3 --add /dev/sdb1
mdadm: added /dev/sdb1

6.3.4. Extending a RAID Device

To add a new device to an existing array, use the command in the following form as root:
mdadm raid_device --add component_device
This will add the device as a spare device. To grow the array to use this device actively, type the following at a shell prompt:
mdadm --grow raid_device --raid-devices=number

Example 6.4. Extending a RAID device

Assume the system has an active RAID device, /dev/md3, with the following layout (that is, the RAID device created in Example 6.2, “Creating a new RAID device”):
~]# mdadm --detail /dev/md3 | tail -n 3
    Number   Major   Minor   RaidDevice State
       0       8        1        0      active sync   /dev/sda1
       1       8       17        1      active sync   /dev/sdb1
Also assume that a new SCSI disk drive, /dev/sdc, has been added and has exactly one partition. To add it to the /dev/md3 array, type the following at a shell prompt:
~]# mdadm /dev/md3 --add /dev/sdc1
mdadm: added /dev/sdc1
This will add /dev/sdc1 as a spare device. To change the size of the array to actually use it, type:
~]# mdadm --grow /dev/md3 --raid-devices=3

6.3.5. Removing a RAID Device

To remove an existing RAID device, first deactivate it by running the following command as root:
mdadm --stop raid_device
Once deactivated, remove the RAID device itself:
mdadm --remove raid_device
Finally, zero superblocks on all devices that were associated with the particular array:
mdadm --zero-superblock component_device

Example 6.5. Removing a RAID device

Assume the system has an active RAID device, /dev/md3, with the following layout (that is, the RAID device created in Example 6.4, “Extending a RAID device”):
~]# mdadm --detail /dev/md3 | tail -n 4
    Number   Major   Minor   RaidDevice State
       0       8        1        0      active sync   /dev/sda1
       1       8       17        1      active sync   /dev/sdb1
       2       8       33        2      active sync   /dev/sdc1
In order to remove this device, first stop it by typing the following at a shell prompt:
~]# mdadm --stop /dev/md3
mdadm: stopped /dev/md3
Once stopped, you can remove the /dev/md3 device by running the following command:
~]# mdadm --remove /dev/md3
Finally, to remove the superblocks from all associated devices, type:
~]# mdadm --zero-superblock /dev/sda1 /dev/sdb1 /dev/sdc1

6.3.6. Preserving the Configuration

By default, changes made by the mdadm command only apply to the current session, and will not survive a system restart. At boot time, the mdmonitor service reads the content of the /etc/mdadm.conf configuration file to see which RAID devices to start. If the software RAID was configured during the graphical installation process, this file contains directives listed in Table 6.1, “Common mdadm.conf directives” by default.

Table 6.1. Common mdadm.conf directives

Option Description
ARRAY
Allows you to identify a particular array.
DEVICE
Allows you to specify a list of devices to scan for a RAID component (for example, /dev/hda1). You can also use the keyword partitions to use all partitions listed in /proc/partitions, or containers to specify an array container.
MAILADDR Allows you to specify an email address to use in case of an alert.

To list what ARRAY lines are presently in use regardless of the configuration, run the following command as root:
mdadm --detail --scan
Use the output of this command to determine which lines to add to the /etc/mdadm.conf file. You can also display the ARRAY line for a particular device:
mdadm --detail --brief raid_device
By redirecting the output of this command, you can add such a line to the configuration file with a single command:
mdadm --detail --brief raid_device >> /etc/mdadm.conf

Example 6.6. Preserving the configuration

By default, the /etc/mdadm.conf contains the software RAID configuration created during the system installation:
# mdadm.conf written out by anaconda
DEVICE partitions
MAILADDR root
ARRAY /dev/md0 level=raid1 num-devices=2 UUID=49c5ac74:c2b79501:5c28cb9c:16a6dd9f
ARRAY /dev/md1 level=raid0 num-devices=2 UUID=76914c11:5bfa2c00:dc6097d1:a1f4506d
ARRAY /dev/md2 level=raid0 num-devices=2 UUID=2b5d38d0:aea898bf:92be20e2:f9d893c5
Assuming you have created the /dev/md3 device as shown in Example 6.2, “Creating a new RAID device”, you can make it persistent by running the following command:
~]# mdadm --detail --brief /dev/md3 >> /etc/mdadm.conf

6.4. Additional Resources

For more information on RAID, refer to the following resources.

6.4.1. Installed Documentation

  • mdadm man page — A manual page for the mdadm utility.
  • mdadm.conf man page — A manual page that provides a comprehensive list of available /etc/mdadm.conf configuration options.


[1] A hot-swap chassis allows you to remove a hard drive without having to power-down your system.
[2] Parity information is calculated based on the contents of the rest of the member disks in the array. This information can then be used to reconstruct data when one disk in the array fails. The reconstructed data can then be used to satisfy I/O requests to the failed disk before it is replaced and to repopulate the failed disk after it has been replaced.

Chapter 7. Swap Space

7.1. What is Swap Space?

Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM. Swap space is located on hard drives, which have a slower access time than physical memory.
Swap space can be a dedicated swap partition (recommended), a swap file, or a combination of swap partitions and swap files.
In years past, the recommended amount of swap space increased linearly with the amount of RAM in the system. But because the amount of memory in modern systems has increased into the hundreds of gigabytes, it is now recognized that the amount of swap space that a system needs is a function of the memory workload running on that system. However, given that swap space is usually designated at install time, and that it can be difficult to determine beforehand the memory workload of a system, we recommend determining system swap using the following table.

Table 7.1. Recommended System Swap Space

Amount of RAM in the System Recommended Amount of Swap Space
4GB of RAM or less a minimum of 2GB of swap space
4GB to 16GB of RAM a minimum of 4GB of swap space
16GB to 64GB of RAM a minimum of 8GB of swap space
64GB to 256GB of RAM a minimum of 16GB of swap space
256GB to 512GB of RAM a minimum of 32GB of swap space

Important

File systems and LVM2 volumes assigned as swap space cannot be in use when being modified. For example, no system processes can be assigned the swap space, as well as no amount of swap should be allocated and used by the kernel. Use the free and cat /proc/swaps commands to verify how much and where swap is in use.
The best way to achieve swap space modifications is to boot your system in rescue mode, and then follow the instructions (for each scenario) in the remainder of this chapter. Refer to the Red Hat Enterprise Linux Installation Guide for instructions on booting into rescue mode. When prompted to mount the file system, select Skip.

7.2. Adding Swap Space

Sometimes it is necessary to add more swap space after installation. For example, you may upgrade the amount of RAM in your system from 128 MB to 256 MB, but there is only 256 MB of swap space. It might be advantageous to increase the amount of swap space to 512 MB if you perform memory-intense operations or run applications that require a large amount of memory.
You have three options: create a new swap partition, create a new swap file, or extend swap on an existing LVM2 logical volume. It is recommended that you extend an existing logical volume.

7.2.1. Extending Swap on an LVM2 Logical Volume

To extend an LVM2 swap logical volume (assuming /dev/VolGroup00/LogVol01 is the volume you want to extend):
  1. Disable swapping for the associated logical volume:
    swapoff -v /dev/VolGroup00/LogVol01
  2. Resize the LVM2 logical volume by 256 MB:
    lvm lvresize /dev/VolGroup00/LogVol01 -L +256M
  3. Format the new swap space:
    mkswap /dev/VolGroup00/LogVol01
  4. Enable the extended logical volume:
    swapon -va
  5. Test that the logical volume has been extended properly:
    cat /proc/swaps
    free

7.2.2. Creating an LVM2 Logical Volume for Swap

To add a swap volume group (assuming /dev/VolGroup00/LogVol02 is the swap volume you want to add):
  1. Create the LVM2 logical volume of size 256 MB:
    lvm lvcreate VolGroup00 -n LogVol02 -L 256M
  2. Format the new swap space:
    mkswap /dev/VolGroup00/LogVol02
  3. Add the following entry to the /etc/fstab file:
    /dev/VolGroup00/LogVol02   swap     swap    defaults     0 0
  4. Enable the extended logical volume:
    swapon -va
  5. Test that the logical volume has been extended properly:
    cat /proc/swaps
    free

7.2.3. Creating a Swap File

To add a swap file:
  1. Determine the size of the new swap file in megabytes and multiply by 1024 to determine the number of blocks. For example, the block size of a 64 MB swap file is 65536.
  2. At a shell prompt as root, type the following command with count being equal to the desired block size:
    dd if=/dev/zero of=/swapfile bs=1024 count=65536
  3. Setup the swap file with the command:
    mkswap /swapfile
  4. To enable the swap file immediately but not automatically at boot time:
    swapon /swapfile
  5. To enable it at boot time, edit /etc/fstab to include the following entry:
    /swapfile          swap            swap    defaults        0 0
    The next time the system boots, it enables the new swap file.
  6. After adding the new swap file and enabling it, verify it is enabled by viewing the output of the command cat /proc/swaps or free.

7.3. Removing Swap Space

Sometimes it can be prudent to reduce swap space after installation. For example, say you downgraded the amount of RAM in your system from 1 GB to 512 MB, but there is 2 GB of swap space still assigned. It might be advantageous to reduce the amount of swap space to 1 GB, since the larger 2 GB could be wasting disk space.
You have three options: remove an entire LVM2 logical volume used for swap, remove a swap file, or reduce swap space on an existing LVM2 logical volume.

7.3.1. Reducing Swap on an LVM2 Logical Volume

To reduce an LVM2 swap logical volume (assuming /dev/VolGroup00/LogVol01 is the volume you want to reduce):
  1. Disable swapping for the associated logical volume:
    swapoff -v /dev/VolGroup00/LogVol01
  2. Reduce the LVM2 logical volume by 512 MB:
    lvm lvreduce /dev/VolGroup00/LogVol01 -L -512M
  3. Format the new swap space:
    mkswap /dev/VolGroup00/LogVol01
  4. Enable the extended logical volume:
    swapon -va
  5. Test that the logical volume has been reduced properly:
    cat /proc/swaps
    free

7.3.2. Removing an LVM2 Logical Volume for Swap

The swap logical volume cannot be in use (no system locks or processes on the volume). The easiest way to achieve this is to boot your system in rescue mode. Refer to the Red Hat Enterprise Linux Installation Guide for instructions on booting into rescue mode. When prompted to mount the file system, select Skip.
To remove a swap volume group (assuming /dev/VolGroup00/LogVol02 is the swap volume you want to remove):
  1. Disable swapping for the associated logical volume:
    swapoff -v /dev/VolGroup00/LogVol02
  2. Remove the LVM2 logical volume of size 512 MB:
    lvm lvremove /dev/VolGroup00/LogVol02
  3. Remove the following entry from the /etc/fstab file:
    /dev/VolGroup00/LogVol02   swap     swap    defaults     0 0
  4. Test that the logical volume has been removed:
    cat /proc/swaps
    free

7.3.3. Removing a Swap File

To remove a swap file:
  1. At a shell prompt as root, execute the following command to disable the swap file (where /swapfile is the swap file):
    swapoff -v /swapfile
  2. Remove its entry from the /etc/fstab file.
  3. Remove the actual file:
    rm /swapfile

7.4. Moving Swap Space

To move swap space from one location to another, follow the steps for removing swap space, and then follow the steps for adding swap space.

Chapter 8. Managing Disk Storage

8.1. Standard Partitions using parted

The utility parted allows users to:
  • View the existing partition table
  • Change the size of existing partitions
  • Add partitions from free space or additional hard drives
If you want to view the system's disk space usage or monitor the disk space usage, refer to Section 42.3, “File Systems”.
By default, the parted package is included when installing Red Hat Enterprise Linux. To start parted, log in as root and type the command parted /dev/sda at a shell prompt (where /dev/sda is the device name for the drive you want to configure).
If you want to remove or resize a partition, the device on which that partition resides must not be in use. Creating a new partition on a device which is in use—while possible—is not recommended.
For a device to not be in use, none of the partitions on the device can be mounted, and any swap space on the device must not be enabled.
As well, the partition table should not be modified while it is in use because the kernel may not properly recognize the changes. If the partition table does not match the actual state of the mounted partitions, information could be written to the wrong partition, resulting in lost and overwritten data.
The easiest way to achieve this is to boot your system in rescue mode. When prompted to mount the file system, select Skip.
Alternately, if the drive does not contain any partitions in use (system processes that use or lock the file system from being unmounted), you can unmount them with the umount command and turn off all the swap space on the hard drive with the swapoff command.
Table 8.1, “parted commands” contains a list of commonly used parted commands. The sections that follow explain some of these commands and arguments in more detail.

Table 8.1. parted commands

Command Description
check minor-num Perform a simple check of the file system
cp from to Copy file system from one partition to another; from and to are the minor numbers of the partitions
help Display list of available commands
mklabel label Create a disk label for the partition table
mkfs minor-num file-system-type Create a file system of type file-system-type
mkpart part-type fs-type start-mb end-mb Make a partition without creating a new file system
mkpartfs part-type fs-type start-mb end-mb Make a partition and create the specified file system
move minor-num start-mb end-mb Move the partition
name minor-num name Name the partition for Mac and PC98 disklabels only
print Display the partition table
quit Quit parted
rescue start-mb end-mb Rescue a lost partition from start-mb to end-mb
resize minor-num start-mb end-mb Resize the partition from start-mb to end-mb
rm minor-num Remove the partition
select device Select a different device to configure
set minor-num flag state Set the flag on a partition; state is either on or off
toggle [NUMBER [FLAG] Toggle the state of FLAG on partition NUMBER
unit UNIT Set the default unit to UNIT

8.1.1. Viewing the Partition Table

After starting parted, use the command print to view the partition table. A table similar to the following appears:
Model: ATA ST3160812AS (scsi)
Disk /dev/sda: 160GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End    Size    Type      File system  Flags
 1      32.3kB  107MB  107MB   primary   ext3         boot
 2      107MB   105GB  105GB   primary   ext3
 3      105GB   107GB  2147MB  primary   linux-swap
 4      107GB   160GB  52.9GB  extended		      root
 5      107GB   133GB  26.2GB  logical   ext3
 6      133GB   133GB  107MB   logical   ext3
 7      133GB   160GB  26.6GB  logical                lvm
The first line contains the disk type, manufacturer, model number and interface, and the second line displays the disk label type. The remaining output below the fourth line shows the partition table.
In the partition table, the Minor number is the partition number. For example, the partition with minor number 1 corresponds to /dev/sda1. The Start and End values are in megabytes. Valid Type are metadata, free, primary, extended, or logical. The Filesystem is the file system type, which can be any of the following:
  • ext2
  • ext3
  • fat16
  • fat32
  • hfs
  • jfs
  • linux-swap
  • ntfs
  • reiserfs
  • hp-ufs
  • sun-ufs
  • xfs
If a Filesystem of a device shows no value, this means that its file system type is unknown.
The Flags column lists the flags set for the partition. Available flags are boot, root, swap, hidden, raid, lvm, or lba.

Tip

To select a different device without having to restart parted, use the select command followed by the device name (for example, /dev/sda). Doing so allows you to view or configure the partition table of a device.

8.1.2. Creating a Partition

Warning

Do not attempt to create a partition on a device that is in use.
Before creating a partition, boot into rescue mode (or unmount any partitions on the device and turn off any swap space on the device).
Start parted, where /dev/sda is the device on which to create the partition:
parted /dev/sda
View the current partition table to determine if there is enough free space:
print
If there is not enough free space, you can resize an existing partition. Refer to Section 8.1.4, “Resizing a Partition” for details.

8.1.2.1. Making the Partition

From the partition table, determine the start and end points of the new partition and what partition type it should be. You can only have four primary partitions (with no extended partition) on a device. If you need more than four partitions, you can have three primary partitions, one extended partition, and multiple logical partitions within the extended. For an overview of disk partitions, refer to the appendix An Introduction to Disk Partitions in the Red Hat Enterprise Linux Installation Guide.
For example, to create a primary partition with an ext3 file system from 1024 megabytes until 2048 megabytes on a hard drive type the following command:
mkpart primary ext3 1024 2048

Tip

If you use the mkpartfs command instead, the file system is created after the partition is created. However, parted does not support creating an ext3 file system. Thus, if you wish to create an ext3 file system, use mkpart and create the file system with the mkfs command as described later.
The changes start taking place as soon as you press Enter, so review the command before executing to it.
After creating the partition, use the print command to confirm that it is in the partition table with the correct partition type, file system type, and size. Also remember the minor number of the new partition so that you can label it. You should also view the output of
cat /proc/partitions
to make sure the kernel recognizes the new partition.

8.1.2.2. Formatting the Partition

The partition still does not have a file system. Create the file system:
mkfs -t ext3 /dev/sda6

Warning

Formatting the partition permanently destroys any data that currently exists on the partition.

8.1.2.3. Labeling the Partition

Next, give the partition a label. For example, if the new partition is /dev/sda6 and you want to label it /work:
e2label /dev/sda6 /work
By default, the installation program uses the mount point of the partition as the label to make sure the label is unique. You can use any label you want.

8.1.2.4. Creating the Mount Point

As root, create the mount point:
mkdir /work

8.1.2.5. Add to /etc/fstab

As root, edit the /etc/fstab file to include the new partition. The new line should look similar to the following:
LABEL=/work           /work                 ext3    defaults        1 2
The first column should contain LABEL= followed by the label you gave the partition. The second column should contain the mount point for the new partition, and the next column should be the file system type (for example, ext3 or swap). If you need more information about the format, read the man page with the command man fstab.
If the fourth column is the word defaults, the partition is mounted at boot time. To mount the partition without rebooting, as root, type the command:
mount /work

8.1.3. Removing a Partition

Warning

Do not attempt to remove a partition on a device that is in use.
Before removing a partition, boot into rescue mode (or unmount any partitions on the device and turn off any swap space on the device).
Start parted, where /dev/sda is the device on which to remove the partition:
parted /dev/sda
View the current partition table to determine the minor number of the partition to remove:
print
Remove the partition with the command rm. For example, to remove the partition with minor number 3:
rm 3
The changes start taking place as soon as you press Enter, so review the command before committing to it.
After removing the partition, use the print command to confirm that it is removed from the partition table. You should also view the output of
cat /proc/partitions
to make sure the kernel knows the partition is removed.
The last step is to remove it from the /etc/fstab file. Find the line that declares the removed partition, and remove it from the file.

8.1.4. Resizing a Partition

Warning

Do not attempt to resize a partition on a device that is in use.
Before resizing a partition, boot into rescue mode (or unmount any partitions on the device and turn off any swap space on the device).
Start parted, where /dev/sda is the device on which to resize the partition:
parted /dev/sda
View the current partition table to determine the minor number of the partition to resize as well as the start and end points for the partition:
print
To resize the partition, use the resize command followed by the minor number for the partition, the starting place in megabytes, and the end place in megabytes. For example:
resize 3 1024 2048

Warning

A partition cannot be made larger than the space available on the device
After resizing the partition, use the print command to confirm that the partition has been resized correctly, is the correct partition type, and is the correct file system type.
After rebooting the system into normal mode, use the command df to make sure the partition was mounted and is recognized with the new size.

8.2. LVM Partition Management

The following commands can be found by issuing lvm help at a command prompt.

Table 8.2. LVM commands

Command Description
dumpconfig Dump the active configuration
formats List the available metadata formats
help Display the help commands
lvchange Change the attributes of logical volume(s)
lvcreate Create a logical volume
lvdisplay Display information about a logical volume
lvextend Add space to a logical volume
lvmchange Due to use of the device mapper, this command has been deprecated
lvmdiskscan List devices that may be used as physical volumes
lvmsadc Collect activity data
lvmsar Create activity report
lvreduce Reduce the size of a logical volume
lvremove Remove logical volume(s) from the system
lvrename Rename a logical volume
lvresize Resize a logical volume
lvs Display information about logical volumes
lvscan List all logical volumes in all volume groups
pvchange Change attributes of physical volume(s)
pvcreate Initialize physical volume(s) for use by LVM
pvdata Display the on-disk metadata for physical volume(s)
pvdisplay Display various attributes of physical volume(s)
pvmove Move extents from one physical volume to another
pvremove Remove LVM label(s) from physical volume(s)
pvresize Resize a physical volume in use by a volume group
pvs Display information about physical volumes
pvscan List all physical volumes
segtypes List available segment types
vgcfgbackup Backup volume group configuration
vgcfgrestore Restore volume group configuration
vgchange Change volume group attributes
vgck Check the consistency of a volume group
vgconvert Change volume group metadata format
vgcreate Create a volume group
vgdisplay Display volume group information
vgexport Unregister a volume group from the system
vgextend Add physical volumes to a volume group
vgimport Register exported volume group with system
vgmerge Merge volume groups
vgmknodes Create the special files for volume group devices in /dev/
vgreduce Remove a physical volume from a volume group
vgremove Remove a volume group
vgrename Rename a volume group
vgs Display information about volume groups
vgscan Search for all volume groups
vgsplit Move physical volumes into a new volume group
version Display software and driver version information

Chapter 9. Implementing Disk Quotas

Disk space can be restricted by implementing disk quotas which alert a system administrator before a user consumes too much disk space or a partition becomes full.
Disk quotas can be configured for individual users as well as user groups. This makes it possible to manage the space allocated for user-specific files (such as email) separately from the space allocated to the projects a user works on (assuming the projects are given their own groups).
In addition, quotas can be set not just to control the number of disk blocks consumed but to control the number of inodes (data structures that contain information about files in UNIX file systems). Because inodes are used to contain file-related information, this allows control over the number of files that can be created.
The quota RPM must be installed to implement disk quotas.

Note

For more information on installing RPM packages, refer to Part II, “Package Management”.

9.1. Configuring Disk Quotas

To implement disk quotas, use the following steps:
  1. Enable quotas per file system by modifying the /etc/fstab file.
  2. Remount the file system(s).
  3. Create the quota database files and generate the disk usage table.
  4. Assign quota policies.
Each of these steps is discussed in detail in the following sections.

9.1.1. Enabling Quotas

As root, using a text editor, edit the /etc/fstab file. Add the usrquota and/or grpquota options to the file systems that require quotas:
/dev/VolGroup00/LogVol00 /         ext3    defaults        1 1
LABEL=/boot              /boot     ext3    defaults        1 2
none                     /dev/pts  devpts  gid=5,mode=620  0 0
none                     /dev/shm  tmpfs   defaults        0 0
none                     /proc     proc    defaults        0 0
none                     /sys      sysfs   defaults        0 0
/dev/VolGroup00/LogVol02 /home     ext3    defaults,usrquota,grpquota  1 2
/dev/VolGroup00/LogVol01 swap      swap    defaults        0 0 . . .
In this example, the /home file system has both user and group quotas enabled.

Note

The following examples assume that a separate /home partition was created during the installation of Red Hat Enterprise Linux. The root (/) partition can be used for setting quota policies in the /etc/fstab file.

9.1.2. Remounting the File Systems

After adding the usrquota and/or grpquota options, remount each file system whose fstab entry has been modified. If the file system is not in use by any process, use one of the following methods:
  • Issue the umount command followed by the mount command to remount the file system.(See the man page for both umount and mount for the specific syntax for mounting and unmounting various filesystem types.)
  • Issue the mount -o remount <file-system> command (where <file-system> is the name of the file system) to remount the file system. For example, to remount the /home file system, the command to issue is mount -o remount /home.
If the file system is currently in use, the easiest method for remounting the file system is to reboot the system.

9.1.3. Creating the Quota Database Files

After each quota-enabled file system is remounted, the system is capable of working with disk quotas. However, the file system itself is not yet ready to support quotas. The next step is to run the quotacheck command.
The quotacheck command examines quota-enabled file systems and builds a table of the current disk usage per file system. The table is then used to update the operating system's copy of disk usage. In addition, the file system's disk quota files are updated.
To create the quota files (aquota.user and aquota.group) on the file system, use the -c option of the quotacheck command. For example, if user and group quotas are enabled for the /home file system, create the files in the /home directory:
quotacheck -cug /home
The -c option specifies that the quota files should be created for each file system with quotas enabled, the -u option specifies to check for user quotas, and the -g option specifies to check for group quotas.
If neither the -u or -g options are specified, only the user quota file is created. If only -g is specified, only the group quota file is created.
After the files are created, run the following command to generate the table of current disk usage per file system with quotas enabled:
quotacheck -avug
The options used are as follows:
  • a — Check all quota-enabled, locally-mounted file systems
  • v — Display verbose status information as the quota check proceeds
  • u — Check user disk quota information
  • g — Check group disk quota information
After quotacheck has finished running, the quota files corresponding to the enabled quotas (user and/or group) are populated with data for each quota-enabled locally-mounted file system such as /home.

9.1.4. Assigning Quotas per User

The last step is assigning the disk quotas with the edquota command.
To configure the quota for a user, as root in a shell prompt, execute the command:
edquota username
Perform this step for each user who needs a quota. For example, if a quota is enabled in /etc/fstab for the /home partition (/dev/VolGroup00/LogVol02 in the example below) and the command edquota testuser is executed, the following is shown in the editor configured as the default for the system:
Disk quotas for user testuser (uid 501):
Filesystem                blocks     soft     hard    inodes   soft   hard
/dev/VolGroup00/LogVol02  440436        0        0     37418      0      0

Note

The text editor defined by the EDITOR environment variable is used by edquota. To change the editor, set the EDITOR environment variable in your ~/.bash_profile file to the full path of the editor of your choice.
The first column is the name of the file system that has a quota enabled for it. The second column shows how many blocks the user is currently using. The next two columns are used to set soft and hard block limits for the user on the file system. The inodes column shows how many inodes the user is currently using. The last two columns are used to set the soft and hard inode limits for the user on the file system.
The hard block limit is the absolute maximum amount of disk space that a user or group can use. Once this limit is reached, no further disk space can be used.
The soft block limit defines the maximum amount of disk space that can be used. However, unlike the hard limit, the soft limit can be exceeded for a certain amount of time. That time is known as the grace period. The grace period can be expressed in seconds, minutes, hours, days, weeks, or months.
If any of the values are set to 0, that limit is not set. In the text editor, change the desired limits. For example:
Disk quotas for user testuser (uid 501):
Filesystem                blocks     soft     hard   inodes   soft   hard
/dev/VolGroup00/LogVol02  440436   500000   550000    37418      0      0
To verify that the quota for the user has been set, use the command:
quota testuser

9.1.5. Assigning Quotas per Group

Quotas can also be assigned on a per-group basis. For example, to set a group quota for the devel group (the group must exist prior to setting the group quota), use the command:
edquota -g devel
This command displays the existing quota for the group in the text editor:
Disk quotas for group devel (gid 505):
Filesystem                blocks    soft     hard    inodes    soft    hard
/dev/VolGroup00/LogVol02  440400       0        0     37418       0       0
Modify the limits, then save the file.
To verify that the group quota has been set, use the command:
quota -g devel

9.1.6. Setting the Grace Period for Soft Limits

If soft limits are set for a given quota (whether inode or block and for either users or groups) the grace period, or amount of time a soft limit can be exceeded, should be set with the command:
edquota -t
While other edquota commands operate on a particular user's or group's quota, the -t option operates on every filesystem with quotas enabled.

9.2. Managing Disk Quotas

If quotas are implemented, they need some maintenance — mostly in the form of watching to see if the quotas are exceeded and making sure the quotas are accurate.
Of course, if users repeatedly exceed their quotas or consistently reach their soft limits, a system administrator has a few choices to make depending on what type of users they are and how much disk space impacts their work. The administrator can either help the user determine how to use less disk space or increase the user's disk quota.

9.2.1. Enabling and Disabling

It is possible to disable quotas without setting them to 0. To turn all user and group quotas off, use the following command:
quotaoff -vaug
If neither the -u or -g options are specified, only the user quotas are disabled. If only -g is specified, only group quotas are disabled. The -v switch causes verbose status information to display as the command executes.
To enable quotas again, use the quotaon command with the same options.
For example, to enable user and group quotas for all file systems, use the following command:
quotaon -vaug
To enable quotas for a specific file system, such as /home, use the following command:
quotaon -vug /home
If neither the -u or -g options are specified, only the user quotas are enabled. If only -g is specified, only group quotas are enabled.

9.2.2. Reporting on Disk Quotas

Creating a disk usage report entails running the repquota utility. For example, the command repquota /home produces this output:
*** Report for user quotas on device /dev/mapper/VolGroup00-LogVol02
Block grace time: 7days; Inode grace time: 7days
                        Block limits                File limits
User            used    soft    hard  grace    used  soft  hard  grace
----------------------------------------------------------------------
root      --      36       0       0              4     0     0
kristin   --     540       0       0            125     0     0
testuser  --  440400  500000  550000          37418     0     0
To view the disk usage report for all (option -a) quota-enabled file systems, use the command:
repquota -a
While the report is easy to read, a few points should be explained. The -- displayed after each user is a quick way to determine whether the block or inode limits have been exceeded. If either soft limit is exceeded, a + appears in place of the corresponding -; the first - represents the block limit, and the second represents the inode limit.
The grace columns are normally blank. If a soft limit has been exceeded, the column contains a time specification equal to the amount of time remaining on the grace period. If the grace period has expired, none appears in its place.

9.2.3. Keeping Quotas Accurate

Whenever a file system is not unmounted cleanly (due to a system crash, for example), it is necessary to run quotacheck. However, quotacheck can be run on a regular basis, even if the system has not crashed. Safe methods for periodically running quotacheck include:
Ensuring quotacheck runs on next reboot

Best method for most systems

This method works best for (busy) multiuser systems which are periodically rebooted.
As root, place a shell script into the /etc/cron.daily/ or /etc/cron.weekly/ directory—or schedule one using the crontab -e command—that contains the touch /forcequotacheck command. This creates an empty forcequotacheck file in the root directory, which the system init script looks for at boot time. If it is found, the init script runs quotacheck. Afterward, the init script removes the /forcequotacheck file; thus, scheduling this file to be created periodically with cron ensures that quotacheck is run during the next reboot.
Refer to Chapter 39, Automated Tasks for more information about configuring cron.
Running quotacheck in single user mode
An alternative way to safely run quotacheck is to (re-)boot the system into single-user mode to prevent the possibility of data corruption in quota files and run:
~]# quotaoff -vaug /<file_system>
~]# quotacheck -vaug /<file_system>
~]# quotaon -vaug /<file_system>
Running quotacheck on a running system
If necessary, it is possible to run quotacheck on a machine during a time when no users are logged in, and thus have no open files on the file system being checked. Run the command quotacheck -vaug <file_system> ; this command will fail if quotacheck cannot remount the given <file_system> as read-only. Note that, following the check, the file system will be remounted read-write.

Do not run quotacheck on a live file system

Running quotacheck on a live file system mounted read-write is not recommended due to the possibility of quota file corruption.
Refer to Chapter 39, Automated Tasks for more information about configuring cron.

9.3. Additional Resources

For more information on disk quotas, refer to the following resources.

9.3.1. Installed Documentation

  • The quotacheck, edquota, repquota, quota, quotaon, and quotaoff man pages

9.3.2. Related Books

  • Red Hat Enterprise Linux Introduction to System Administration; Red Hat, Inc. — Available at http://www.redhat.com/docs/ and on the Documentation CD, this manual contains background information on storage management (including disk quotas) for new Red Hat Enterprise Linux system administrators.

Chapter 10. Access Control Lists

Files and directories have permission sets for the owner of the file, the group associated with the file, and all other users for the system. However, these permission sets have limitations. For example, different permissions cannot be configured for different users. Thus, Access Control Lists (ACLs) were implemented.
The Red Hat Enterprise Linux 5 kernel provides ACL support for the ext3 file system and NFS-exported file systems. ACLs are also recognized on ext3 file systems accessed via Samba.
Along with support in the kernel, the acl package is required to implement ACLs. It contains the utilities used to add, modify, remove, and retrieve ACL information.
The cp and mv commands copy or move any ACLs associated with files and directories.

10.1. Mounting File Systems

Before using ACLs for a file or directory, the partition for the file or directory must be mounted with ACL support. If it is a local ext3 file system, it can mounted with the following command:
mount -t ext3 -o acl <device-name> <partition>
For example:
mount -t ext3 -o acl /dev/VolGroup00/LogVol02 /work
Alternatively, if the partition is listed in the /etc/fstab file, the entry for the partition can include the acl option:
LABEL=/work      /work       ext3    acl        1 2
If an ext3 file system is accessed via Samba and ACLs have been enabled for it, the ACLs are recognized because Samba has been compiled with the --with-acl-support option. No special flags are required when accessing or mounting a Samba share.

10.1.1. NFS

By default, if the file system being exported by an NFS server supports ACLs and the NFS client can read ACLs, ACLs are utilized by the client system.
To disable ACLs on NFS shares when configuring the server, include the no_acl option in the /etc/exports file. To disable ACLs on an NFS share when mounting it on a client, mount it with the no_acl option via the command line or the /etc/fstab file.

10.2. Setting Access ACLs

There are two types of ACLs: access ACLs and default ACLs. An access ACL is the access control list for a specific file or directory. A default ACL can only be associated with a directory; if a file within the directory does not have an access ACL, it uses the rules of the default ACL for the directory. Default ACLs are optional.
ACLs can be configured:
  1. Per user
  2. Per group
  3. Via the effective rights mask
  4. For users not in the user group for the file
The setfacl utility sets ACLs for files and directories. Use the -m option to add or modify the ACL of a file or directory:
setfacl -m <rules> <files>
Rules (<rules>) must be specified in the following formats. Multiple rules can be specified in the same command if they are separated by commas.
u:<uid>:<perms>
Sets the access ACL for a user. The user name or UID may be specified. The user may be any valid user on the system.
g:<gid>:<perms>
Sets the access ACL for a group. The group name or GID may be specified. The group may be any valid group on the system.
m:<perms>
Sets the effective rights mask. The mask is the union of all permissions of the owning group and all of the user and group entries.
o:<perms>
Sets the access ACL for users other than the ones in the group for the file.
White space is ignored. Permissions (<perms>) must be a combination of the characters r, w, and x for read, write, and execute.
If a file or directory already has an ACL, and the setfacl command is used, the additional rules are added to the existing ACL or the existing rule is modified.
For example, to give read and write permissions to user andrius:
setfacl -m u:andrius:rw /project/somefile
To remove all the permissions for a user, group, or others, use the -x option and do not specify any permissions:
setfacl -x <rules> <files>
For example, to remove all permissions from the user with UID 500:
setfacl -x u:500 /project/somefile

10.3. Setting Default ACLs

To set a default ACL, add d: before the rule and specify a directory instead of a file name.
For example, to set the default ACL for the /share/ directory to read and execute for users not in the user group (an access ACL for an individual file can override it):
setfacl -m d:o:rx /share

10.4. Retrieving ACLs

To determine the existing ACLs for a file or directory, use the getfacl command. In the example below, the getfacl is used to determine the existing ACLs for a file.
getfacl home/john/picture.png
The above command returns the following output:
# file: home/john/picture.png
# owner: john
# group: john
user::rw-
group::r--
other::r--
If a directory with a default ACL is specified, the default ACL is also displayed as illustrated below.
[john@main /]$ getfacl home/sales/
# file: home/sales/
# owner: john
# group: john
user::rw-
user:barryg:r--
group::r--
mask::r--
other::r--
default:user::rwx
default:user:john:rwx
default:group::r-x
default:mask::rwx
default:other::r-x

10.5. Archiving File Systems With ACLs

Warning

The tar and dump commands do not backup ACLs.
The star utility is similar to the tar utility in that it can be used to generate archives of files; however, some of its options are different. Refer to Table 10.1, “Command Line Options for star for a listing of more commonly used options. For all available options, refer to the star man page. The star package is required to use this utility.

Table 10.1. Command Line Options for star

Option Description
-c Creates an archive file.
-n Do not extract the files; use in conjunction with -x to show what extracting the files does.
-r Replaces files in the archive. The files are written to the end of the archive file, replacing any files with the same path and file name.
-t Displays the contents of the archive file.
-u Updates the archive file. The files are written to the end of the archive if they do not exist in the archive or if the files are newer than the files of the same name in the archive. This option only work if the archive is a file or an unblocked tape that may backspace.
-x Extracts the files from the archive. If used with -U and a file in the archive is older than the corresponding file on the file system, the file is not extracted.
-help Displays the most important options.
-xhelp Displays the least important options.
-/ Do not strip leading slashes from file names when extracting the files from an archive. By default, they are striped when files are extracted.
-acl When creating or extracting, archive or restore any ACLs associated with the files and directories.

10.6. Compatibility with Older Systems

If an ACL has been set on any file on a given file system, that file system has the ext_attr attribute. This attribute can be seen using the following command:
tune2fs -l <filesystem-device>
A file system that has acquired the ext_attr attribute can be mounted with older kernels, but those kernels do not enforce any ACLs which have been set.
Versions of the e2fsck utility included in version 1.22 and higher of the e2fsprogs package (including the versions in Red Hat Enterprise Linux 2.1 and 4) can check a file system with the ext_attr attribute. Older versions refuse to check it.

10.7. Additional Resources

Refer to the follow resources for more information.

10.7.1. Installed Documentation

  • acl man page — Description of ACLs
  • getfacl man page — Discusses how to get file access control lists
  • setfacl man page — Explains how to set file access control lists
  • star man page — Explains more about the star utility and its many options

10.7.2. Useful Websites

Chapter 11. LVM (Logical Volume Manager)

11.1. What is LVM?

LVM is a tool for logical volume management which includes allocating disks, striping, mirroring and resizing logical volumes.
With LVM, a hard drive or set of hard drives is allocated to one or more physical volumes. LVM physical volumes can be placed on other block devices which might span two or more disks.
The physical volumes are combined into logical volumes, with the exception of the /boot partition. The /boot partition cannot be on a logical volume group because the boot loader cannot read it. If the root (/) partition is on a logical volume, create a separate /boot partition which is not a part of a volume group.
Since a physical volume cannot span over multiple drives, to span over more than one drive, create one or more physical volumes per drive.
Logical Volumes

Figure 11.1. Logical Volumes


The volume groups can be divided into logical volumes, which are assigned mount points, such as /home and / and file system types, such as ext2 or ext3. When "partitions" reach their full capacity, free space from the volume group can be added to the logical volume to increase the size of the partition. When a new hard drive is added to the system, it can be added to the volume group, and partitions that are logical volumes can be increased in size.
Logical Volumes

Figure 11.2. Logical Volumes


On the other hand, if a system is partitioned with the ext3 file system, the hard drive is divided into partitions of defined sizes. If a partition becomes full, it is not easy to expand the size of the partition. Even if the partition is moved to another hard drive, the original hard drive space has to be reallocated as a different partition or not used.
To learn how to configure LVM during the installation process, refer to Section 11.2, “LVM Configuration”.

11.1.1. What is LVM2?

LVM version 2, or LVM2, is the default for Red Hat Enterprise Linux 5, which uses the device mapper driver contained in the 2.6 kernel. LVM2 can be upgraded from versions of Red Hat Enterprise Linux running the 2.4 kernel.

11.2. LVM Configuration

LVM can be configured during the graphical installation process, the text-based installation process, or during a kickstart installation. You can use the system-config-lvm utility to create your own LVM configuration post-installation. The next two sections focus on using Disk Druid during installation to complete this task. The third section introduces the LVM utility (system-config-lvm) which allows you to manage your LVM volumes in X windows or graphically.
Read Section 11.1, “What is LVM?” first to learn about LVM. An overview of the steps required to configure LVM include:
  • Creating physical volumes from the hard drives.
  • Creating volume groups from the physical volumes.
  • Creating logical volumes from the volume groups and assign the logical volumes mount points.
Two 9.1 GB SCSI drives (/dev/sda and /dev/sdb) are used in the following examples. They detail how to create a simple configuration using a single LVM volume group with associated logical volumes during installation.

11.3. Automatic Partitioning

On the Disk Partitioning Setup screen, select Remove linux partitions on selected drives and create default layout from the pulldown list.
For Red Hat Enterprise Linux, LVM is the default method for disk partitioning. If you do not wish to have LVM implemented, or if you require RAID partitioning, manual disk partitioning through Disk Druid is required.
The following properties make up the automatically created configuration:
  • The /boot partition resides on its own non-LVM partition. In the following example, it is the first partition on the first drive (/dev/sda1). Bootable partitions cannot reside on LVM logical volumes.
  • A single LVM volume group (VolGroup00) is created, which spans all selected drives and all remaining space available. In the following example, the remainder of the first drive (/dev/sda2), and the entire second drive (/dev/sdb1) are allocated to the volume group.
  • Two LVM logical volumes (LogVol00 and LogVol01) are created from the newly created spanned volume group. In the following example, the recommended swap space is automatically calculated and assigned to LogVol01, and the remainder is allocated to the root file system, LogVol00.
Automatic LVM Configuration With Two SCSI Drives

Figure 11.3. Automatic LVM Configuration With Two SCSI Drives


Note

If enabling quotas are of interest to you, it may be best to modify the automatic configuration to include other mount points, such as /home or /var, so that each file system has its own independent quota configuration limits.
In most cases, the default automatic LVM partitioning is sufficient, but advanced implementations could warrant modification or manual configuration of the partition tables.

Note

If you anticipate future memory upgrades, leaving some free space in the volume group would allow for easy future expansion of the swap space logical volume on the system; in which case, the automatic LVM configuration should be modified to leave available space for future growth.

11.4. Manual LVM Partitioning

The following section explains how to manually configure LVM for Red Hat Enterprise Linux. Because there are numerous ways to manually configure a system with LVM, the following example is similar to the default configuration done in Section 11.3, “Automatic Partitioning”.
On the Disk Partitioning Setup screen, select Create custom layout from the pulldown list and click the Next button in the bottom right corner of the screen.

11.4.1. Creating the /boot Partition

In a typical situation, the disk drives are new, or formatted clean. The following figure, Figure 11.4, “Two Blank Drives, Ready for Configuration”, shows both drives as raw devices with no partitioning configured.
Two Blank Drives, Ready for Configuration

Figure 11.4. Two Blank Drives, Ready for Configuration


Warning

The /boot partition cannot reside on an LVM volume because the GRUB boot loader cannot read it.
  1. Select New.
  2. Select /boot from the Mount Point pulldown menu.
  3. Select ext3 from the File System Type pulldown menu.
  4. Select only the sda checkbox from the Allowable Drives area.
  5. Leave 100 (the default) in the Size (MB) menu.
  6. Leave the Fixed size (the default) radio button selected in the Additional Size Options area.
  7. Select Force to be a primary partition to make the partition be a primary partition. A primary partition is one of the first four partitions on the hard drive. If unselected, the partition is created as a logical partition. If other operating systems are already on the system, unselecting this option should be considered. For more information on primary versus logical/extended partitions, refer to the appendix section of the Red Hat Enterprise Linux Installation Guide.
Refer to Figure 11.5, “Creation of the Boot Partition” to verify your inputted values:
Creation of the Boot Partition

Figure 11.5. Creation of the Boot Partition


Click OK to return to the main screen. The following figure displays the boot partition correctly set:
The /boot Partition Displayed

Figure 11.6. The /boot Partition Displayed


11.4.2. Creating the LVM Physical Volumes

Once the boot partition is created, the remainder of all disk space can be allocated to LVM partitions. The first step in creating a successful LVM implementation is the creation of the physical volume(s).
  1. Select New.
  2. Select physical volume (LVM) from the File System Type pulldown menu as shown in Figure 11.7, “Creating a Physical Volume”.
    Creating a Physical Volume

    Figure 11.7. Creating a Physical Volume


  3. You cannot enter a mount point yet (you can once you have created all your physical volumes and then all volume groups).
  4. A physical volume must be constrained to one drive. For Allowable Drives, select the drive on which the physical volume are created. If you have multiple drives, all drives are selected, and you must deselect all but one drive.
  5. Enter the size that you want the physical volume to be.
  6. Select Fixed size to make the physical volume the specified size, select Fill all space up to (MB) and enter a size in MBs to give range for the physical volume size, or select Fill to maximum allowable size to make it grow to fill all available space on the hard disk. If you make more than one growable, they share the available free space on the disk.
  7. Select Force to be a primary partition if you want the partition to be a primary partition.
  8. Click OK to return to the main screen.
Repeat these steps to create as many physical volumes as needed for your LVM setup. For example, if you want the volume group to span over more than one drive, create a physical volume on each of the drives. The following figure shows both drives completed after the repeated process:
Two Physical Volumes Created

Figure 11.8. Two Physical Volumes Created


11.4.3. Creating the LVM Volume Groups

Once all the physical volumes are created, the volume groups can be created:
  1. Click the LVM button to collect the physical volumes into volume groups. A volume group is basically a collection of physical volumes. You can have multiple logical volumes, but a physical volume can only be in one volume group.

    Note

    There is overhead disk space reserved in the volume group. The volume group size is slightly less than the total of physical volume sizes.
    Creating an LVM Volume Group

    Figure 11.9. Creating an LVM Volume Group


  2. Change the Volume Group Name if desired.
  3. All logical volumes inside the volume group must be allocated in physical extent (PE) units. A physical extent is an allocation unit for data.
  4. Select which physical volumes to use for the volume group.

11.4.4. Creating the LVM Logical Volumes

Create logical volumes with mount points such as /, /home, and swap space. Remember that /boot cannot be a logical volume. To add a logical volume, click the Add button in the Logical Volumes section. A dialog window as shown in Figure 11.10, “Creating a Logical Volume” appears.
Creating a Logical Volume

Figure 11.10. Creating a Logical Volume


Repeat these steps for each volume group you want to create.

Tip

You may want to leave some free space in the volume group so you can expand the logical volumes later. The default automatic configuration does not do this, but this manual configuration example does — approximately 1 GB is left as free space for future expansion.
Pending Logical Volumes

Figure 11.11. Pending Logical Volumes


Click OK to apply the volume group and all associated logical volumes.
The following figure shows the final manual configuration:
Final Manual Configuration

Figure 11.12. Final Manual Configuration


11.5. Using the LVM utility system-config-lvm

The LVM utility allows you to manage logical volumes within X windows or graphically. You can access the application by selecting from your menu panel System > Administration > Logical Volume Management. Alternatively you can start the Logical Volume Management utility by typing system-config-lvm from a terminal.
In the example used in this section, the following are the details for the volume group that was created during the installation:
/boot - (Ext3) file system. Displayed under 'Uninitialized Entities'. (DO NOT initialize this partition).
LogVol00 - (LVM) contains the (/) directory (312 extents).
LogVol02 - (LVM) contains the (/home) directory (128 extents).
LogVol03 - (LVM) swap (28 extents).
The logical volumes above were created in disk entity /dev/hda2 while /boot was created in /dev/hda1. The system also consists of 'Uninitialized Entities' which are illustrated in Figure 11.17, “Uninitialized Entities”. The figure below illustrates the main window in the LVM utility. The logical and the physical views of the above configuration are illustrated below. The three logical volumes exist on the same physical volume (hda2).
Main LVM Window

Figure 11.13. Main LVM Window


The figure below illustrates the physical view for the volume. In this window, you can select and remove a volume from the volume group or migrate extents from the volume to another volume group. Steps to migrate extents are discussed in Figure 11.22, “Migrate Extents”.
Physical View Window

Figure 11.14. Physical View Window


The figure below illustrates the logical view for the selected volume group. The logical volume size is also indicated with the individual logical volume sizes illustrated.
Logical View Window

Figure 11.15. Logical View Window


On the left side column, you can select the individual logical volumes in the volume group to view more details about each. In this example the objective is to rename the logical volume name for 'LogVol03' to 'Swap'. To perform this operation select the respective logical volume and click on the Edit Properties button. This will display the Edit Logical Volume window from which you can modify the Logical volume name, size (in extents) and also use the remaining space available in a logical volume group. The figure below illustrates this.
Please note that this logical volume cannot be changed in size as there is currently no free space in the volume group. If there was remaining space, this option would be enabled (see Figure 11.31, “Edit logical volume”). Click on the OK button to save your changes (this will remount the volume). To cancel your changes click on the Cancel button. To revert to the last snapshot settings click on the Revert button. A snapshot can be created by clicking on the Create Snapshot button on the LVM utility window. If the selected logical volume is in use by the system (for example) the / (root) directory, this task will not be successful as the volume cannot be unmounted.
Edit Logical Volume

Figure 11.16. Edit Logical Volume


11.5.1. Utilizing uninitialized entities

'Uninitialized Entities' consist of unpartitioned space and non LVM file systems. In this example partitions 3, 4, 5, 6 and 7 were created during installation and some unpartitioned space was left on the hard disk. Please view each partition and ensure that you read the 'Properties for Disk Entity' on the right column of the window to ensure that you do not delete critical data. In this example partition 1 cannot be initialized as it is /boot. Uninitialized entities are illustrated below.
Uninitialized Entities

Figure 11.17. Uninitialized Entities


In this example, partition 3 will be initialized and added to an existing volume group. To initialize a partition or unpartioned space, select the partition and click on the Initialize Entity button. Once initialized, a volume will be listed in the 'Unallocated Volumes' list.

11.5.2. Adding Unallocated Volumes to a volume group

Once initialized, a volume will be listed in the 'Unallocated Volumes' list. The figure below illustrates an unallocated partition (Partition 3). The respective buttons at the bottom of the window allow you to:
  • create a new volume group,
  • add the unallocated volume to an existing volume group,
  • remove the volume from LVM.
To add the volume to an existing volume group, click on the Add to Existing Volume Group button.
Unallocated Volumes

Figure 11.18. Unallocated Volumes


Clicking on the Add to Existing Volume Group button will display a pop up window listing the existing volume groups to which you can add the physical volume you are about to initialize. A volume group may span across one or more hard disks. In this example only one volume group exists as illustrated below.
Add physical volume to volume group

Figure 11.19. Add physical volume to volume group


Once added to an existing volume group the new logical volume is automatically added to the unused space of the selected volume group. You can use the unused space to:
  • create a new logical volume (click on the Create New Logical Volume(s) button,
  • select one of the existing logical volumes and increase the extents (see Section 11.5.6, “Extending a volume group”),
  • select an existing logical volume and remove it from the volume group by clicking on the Remove Selected Logical Volume(s) button. Please note that you cannot select unused space to perform this operation.
The figure below illustrates the logical view of 'VolGroup00' after adding the new volume group.
Logical view of volume group

Figure 11.20. Logical view of volume group


In the figure below, the uninitialized entities (partitions 3, 5, 6 and 7) were added to 'VolGroup00'.
Logical view of volume group

Figure 11.21. Logical view of volume group


11.5.3. Migrating extents

To migrate extents from a physical volume, select the volume and click on the Migrate Selected Extent(s) From Volume button. Please note that you need to have a sufficient number of free extents to migrate extents within a volume group. An error message will be displayed if you do not have a sufficient number of free extents. To resolve this problem, please extend your volume group (see Section 11.5.6, “Extending a volume group”). If a sufficient number of free extents is detected in the volume group, a pop up window will be displayed from which you can select the destination for the extents or automatically let LVM choose the physical volumes (PVs) to migrate them to. This is illustrated below.
Migrate Extents

Figure 11.22. Migrate Extents


The figure below illustrates a migration of extents in progress. In this example, the extents were migrated to 'Partition 3'.
Migrating extents in progress

Figure 11.23. Migrating extents in progress


Once the extents have been migrated, unused space is left on the physical volume. The figure below illustrates the physical and logical view for the volume group. Please note that the extents of LogVol00 which were initially in hda2 are now in hda3. Migrating extents allows you to move logical volumes in case of hard disk upgrades or to manage your disk space better.
Logical and physical view of volume group

Figure 11.24. Logical and physical view of volume group


11.5.4. Adding a new hard disk using LVM

In this example, a new IDE hard disk was added. The figure below illustrates the details for the new hard disk. From the figure below, the disk is uninitialized and not mounted. To initialize a partition, click on the Initialize Entity button. For more details, see Section 11.5.1, “Utilizing uninitialized entities”. Once initialized, LVM will add the new volume to the list of unallocated volumes as illustrated in Figure 11.26, “Create new volume group”.
Uninitialized hard disk

Figure 11.25. Uninitialized hard disk


11.5.5. Adding a new volume group

Once initialized, LVM will add the new volume to the list of unallocated volumes where you can add it to an existing volume group or create a new volume group. You can also remove the volume from LVM. The volume if removed from LVM will be listed in the list of 'Uninitialized Entities' as illustrated in Figure 11.25, “Uninitialized hard disk”. In this example, a new volume group was created as illustrated below.
Create new volume group

Figure 11.26. Create new volume group


Once created a new volume group will be displayed in the list of existing volume groups as illustrated below. The logical view will display the new volume group with unused space as no logical volumes have been created. To create a logical volume, select the volume group and click on the Create New Logical Volume button as illustrated below. Please select the extents you wish to use on the volume group. In this example, all the extents in the volume group were used to create the new logical volume.
Create new logical volume

Figure 11.27. Create new logical volume


The figure below illustrates the physical view of the new volume group. The new logical volume named 'Backups' in this volume group is also listed.
Physical view of new volume group

Figure 11.28. Physical view of new volume group


11.5.6. Extending a volume group

In this example, the objective was to extend the new volume group to include an uninitialized entity (partition). This was to increase the size or number of extents for the volume group. To extend the volume group, click on the Extend Volume Group button. This will display the 'Extend Volume Group' window as illustrated below. On the 'Extend Volume Group' window, you can select disk entities (partitions) to add to the volume group. Please ensure that you check the contents of any 'Uninitialized Disk Entities' (partitions) to avoid deleting any critical data (see Figure 11.25, “Uninitialized hard disk”). In the example, the disk entity (partition) /dev/hda6 was selected as illustrated below.
Select disk entities

Figure 11.29. Select disk entities


Once added, the new volume will be added as 'Unused Space' in the volume group. The figure below illustrates the logical and physical view of the volume group after it was extended.
Logical and physical view of an extended volume group

Figure 11.30. Logical and physical view of an extended volume group


11.5.7. Editing a Logical Volume

The LVM utility allows you to select a logical volume in the volume group and modify its name, size and specify filesystem options. In this example, the logical volume named 'Backups" was extended onto the remaining space for the volume group.
Clicking on the Edit Properties button will display the 'Edit Logical Volume' popup window from which you can edit the properties of the logical volume. On this window, you can also mount the volume after making the changes and mount it when the system is rebooted. Please note that you should indicate the mount point. If the mount point you specify does not exist, a popup window will be displayed prompting you to create it. The 'Edit Logical Volume' window is illustrated below.
Edit logical volume

Figure 11.31. Edit logical volume


If you wish to mount the volume, select the 'Mount' checkbox indicating the preferred mount point. To mount the volume when the system is rebooted, select the 'Mount when rebooted' checkbox. In this example, the new volume will be mounted in /mnt/backups. This is illustrated in the figure below.
Edit logical volume - specifying mount options

Figure 11.32. Edit logical volume - specifying mount options


The figure below illustrates the logical and physical view of the volume group after the logical volume was extended to the unused space. Please note in this example that the logical volume named 'Backups' spans across two hard disks. A volume can be striped across two or more physical devices using LVM.
Edit logical volume

Figure 11.33. Edit logical volume


11.6. Additional Resources

Use these sources to learn more about LVM.

11.6.1. Installed Documentation

  • rpm -qd lvm2 — This command shows all the documentation available from the lvm package, including man pages.
  • lvm help — This command shows all LVM commands available.

11.6.2. Useful Websites

Part II. Package Management

All software on a Red Hat Enterprise Linux system is divided into RPM packages which can be installed, upgraded, or removed. This part describes how to manage the RPM packages on a Red Hat Enterprise Linux system using graphical and command line tools.

Table of Contents

12. Package Management with RPM
12.1. RPM Design Goals
12.2. Using RPM
12.2.1. Finding RPM Packages
12.2.2. Installing
12.2.3. Uninstalling
12.2.4. Upgrading
12.2.5. Freshening
12.2.6. Querying
12.2.7. Verifying
12.3. Checking a Package's Signature
12.3.1. Importing Keys
12.3.2. Verifying Signature of Packages
12.4. Practical and Common Examples of RPM Usage
12.5. Additional Resources
12.5.1. Installed Documentation
12.5.2. Useful Websites
12.5.3. Related Books
13. Package Management Tool
13.1. Listing and Analyzing Packages
13.2. Installing and Removing Packages
14. YUM (Yellowdog Updater Modified)
14.1. Setting Up a Yum Repository
14.2. yum Commands
14.3. yum Options
14.4. Configuring yum
14.4.1. [main] Options
14.4.2. [repository] Options
14.5. Upgrading the System Off-line with ISO and Yum
14.6. Useful yum Variables
15. Registering a System and Managing Subscriptions
15.1. Using Red Hat Subscription Manager Tools
15.1.1. Launching the Red Hat Subscription Manager GUI
15.1.2. Running the subscription-manager Command-Line Tool
15.2. Registering and Unregistering a System
15.2.1. Registering from the GUI
15.2.2. Registering from the Command Line
15.2.3. Unregistering
15.3. Attaching and Removing Subscriptions
15.3.1. Attaching and Removing Subscriptions through the GUI
15.3.2. Attaching and Removing Subscriptions through the Command Line
15.4. Redeeming Vendor Subscriptions
15.4.1. Redeeming Subscriptions through the GUI
15.4.2. Redeeming Subscriptions through the Command Line
15.5. Attaching Subscriptions from a Subscription Asset Manager Activation Key
15.6. Setting Preferences for Systems
15.6.1. Setting Preferences in the UI
15.6.2. Setting Service Levels Through the Command Line
15.6.3. Setting a Preferred Operating System Release Version in the Command Line
15.6.4. Removing a Preference
15.7. Managing Subscription Expiration and Notifications

Chapter 12. Package Management with RPM

The RPM Package Manager (RPM) is an open packaging system, which runs on Red Hat Enterprise Linux as well as other Linux and UNIX systems. Red Hat, Inc. encourages other vendors to use RPM for their own products. RPM is distributed under the terms of the GPL.
The utility works only with packages built for processing by the rpm package. For the end user, RPM makes system updates easy. Installing, uninstalling, and upgrading RPM packages can be accomplished with short commands. RPM maintains a database of installed packages and their files, so you can invoke powerful queries and verifications on your system. If you prefer a graphical interface, you can use the Package Management Tool to perform many RPM commands. Refer to Chapter 13, Package Management Tool for details.

Important

When installing a package, please ensure it is compatible with your operating system and architecture. This can usually be determined by checking the package name.
During upgrades, RPM handles configuration files carefully, so that you never lose your customizations — something that you cannot accomplish with regular .tar.gz files.
For the developer, RPM allows you to take software source code and package it into source and binary packages for end users. This process is quite simple and is driven from a single file and optional patches that you create. This clear delineation between pristine sources and your patches along with build instructions eases the maintenance of the package as new versions of the software are released.

Note

Because RPM makes changes to your system, you must be logged in as root to install, remove, or upgrade an RPM package.

12.1. RPM Design Goals

To understand how to use RPM, it can be helpful to understand the design goals of RPM:
Upgradability
With RPM, you can upgrade individual components of your system without completely reinstalling. When you get a new release of an operating system based on RPM (such as Red Hat Enterprise Linux), you do not need to reinstall on your machine (as you do with operating systems based on other packaging systems). RPM allows intelligent, fully-automated, in-place upgrades of your system. Configuration files in packages are preserved across upgrades, so you do not lose your customizations. There are no special upgrade files needed to upgrade a package because the same RPM file is used to install and upgrade the package on your system.
Powerful Querying
RPM is designed to provide powerful querying options. You can do searches through your entire database for packages or just for certain files. You can also easily find out what package a file belongs to and from where the package came. The files an RPM package contains are in a compressed archive, with a custom binary header containing useful information about the package and its contents, allowing you to query individual packages quickly and easily.
System Verification
Another powerful RPM feature is the ability to verify packages. If you are worried that you deleted an important file for some package, you can verify the package. You are then notified of any anomalies, if any — at which point, you can reinstall the package if necessary. Any configuration files that you modified are preserved during reinstallation.
Pristine Sources
A crucial design goal was to allow the use of pristine software sources, as distributed by the original authors of the software. With RPM, you have the pristine sources along with any patches that were used, plus complete build instructions. This is an important advantage for several reasons. For instance, if a new version of a program is released, you do not necessarily have to start from scratch to get it to compile. You can look at the patch to see what you might need to do. All the compiled-in defaults, and all of the changes that were made to get the software to build properly, are easily visible using this technique.
The goal of keeping sources pristine may seem important only for developers, but it results in higher quality software for end users, too.

12.2. Using RPM

RPM has five basic modes of operation (not counting package building): installing, uninstalling, upgrading, querying, and verifying. This section contains an overview of each mode. For complete details and options, try rpm --help or man rpm. You can also refer to Section 12.5, “Additional Resources” for more information on RPM.

12.2.1. Finding RPM Packages

Before using any RPM packages, you must know where to find them. An Internet search returns many RPM repositories, but if you are looking for RPM packages built by Red Hat, they can be found at the following locations:

12.2.2. Installing

RPM packages typically have file names like foo-1.0-1.i386.rpm. The file name includes the package name (foo), version (1.0), release (1), and architecture (i386). To install a package, log in as root and type the following command at a shell prompt:
rpm -ivh foo-1.0-1.i386.rpm
Alternatively, the following command can also be used:
rpm -Uvh foo-1.0-1.i386.rpm
If the installation is successful, the following output is displayed:
Preparing...                ########################################### [100%]
   1:foo                    ########################################### [100%]
As you can see, RPM prints out the name of the package and then prints a succession of hash marks as a progress meter while the package is installed.
The signature of a package is checked automatically when installing or upgrading a package. The signature confirms that the package was signed by an authorized party. For example, if the verification of the signature fails, an error message such as the following is displayed:
error: V3 DSA signature: BAD, key ID 0352860f
If it is a new, header-only, signature, an error message such as the following is displayed:
error: Header V3 DSA signature: BAD, key ID 0352860f
If you do not have the appropriate key installed to verify the signature, the message contains the word NOKEY such as:
warning: V3 DSA signature: NOKEY, key ID 0352860f
Refer to Section 12.3, “Checking a Package's Signature” for more information on checking a package's signature.

Warning

If you are installing a kernel package, you should use rpm -ivh instead. Refer to Chapter 44, Manually Upgrading the Kernel for details.

12.2.2.1. Package Already Installed

If a package of the same name and version is already installed, the following output is displayed:
Preparing...                ########################################### [100%]
package foo-1.0-1 is already installed
However, if you want to install the package anyway, you can use the --replacepkgs option, which tells RPM to ignore the error:
rpm -ivh --replacepkgs foo-1.0-1.i386.rpm
This option is helpful if files installed from the RPM were deleted or if you want the original configuration files from the RPM to be installed.

12.2.2.2. Conflicting Files

If you attempt to install a package that contains a file which has already been installed by another package, the following is displayed:
Preparing...                ########################################### [100%]
file /usr/bin/foo from install of foo-1.0-1 conflicts with file from package bar-2.0.20
To make RPM ignore this error, use the --replacefiles option:
rpm -ivh --replacefiles foo-1.0-1.i386.rpm

12.2.2.3. Unresolved Dependency

RPM packages may sometimes depend on other packages, which means that they require other packages to be installed to run properly. If you try to install a package which has an unresolved dependency, output similar to the following is displayed:
error: Failed dependencies:
        bar.so.2 is needed by foo-1.0-1
Suggested resolutions:
	bar-2.0.20-3.i386.rpm
If you are installing a package from the Red Hat Enterprise Linux CD-ROM set, it usually suggest the package(s) needed to resolve the dependency. Find the suggested package(s) on the Red Hat Enterprise Linux CD-ROMs or from Red Hat Network , and add it to the command:
rpm -ivh foo-1.0-1.i386.rpm bar-2.0.20-3.i386.rpm
If installation of both packages is successful, output similar to the following is displayed:
Preparing...                ########################################### [100%]
   1:foo                    ########################################### [ 50%]
   2:bar                    ########################################### [100%]
If it does not suggest a package to resolve the dependency, you can try the -q --whatprovides option combination to determine which package contains the required file.
rpm -q --whatprovides bar.so.2
To force the installation anyway (which is not recommended since the package may not run correctly), use the --nodeps option.

12.2.3. Uninstalling

Uninstalling a package is just as simple as installing one. Type the following command at a shell prompt:
rpm -e foo

Note

Notice that we used the package name foo, not the name of the original package file foo-1.0-1.i386.rpm. To uninstall a package, replace foo with the actual package name of the original package.
You can encounter a dependency error when uninstalling a package if another installed package depends on the one you are trying to remove. For example:
error: Failed dependencies:
	foo is needed by (installed) bar-2.0.20-3.i386.rpm
To make RPM ignore this error and uninstall the package anyway (which may break the package dependent on it) use the --nodeps option.

12.2.4. Upgrading

Upgrading a package is similar to installing one. Type the following command at a shell prompt:
rpm -Uvh foo-2.0-1.i386.rpm
As part of upgrading a package, RPM automatically uninstalls any old versions of the foo package. Note that -U will also install a package even when there are no previous versions of the package installed.

Tip

It is not advisable to use the -U option for installing kernel packages, because RPM replaces the previous kernel package. This does not affect a running system, but if the new kernel is unable to boot during your next restart, there would be no other kernel to boot instead.
Using the -i option adds the kernel to your GRUB boot menu (/etc/grub.conf). Similarly, removing an old, unneeded kernel removes the kernel from GRUB.
Because RPM performs intelligent upgrading of packages with configuration files, you may see a message like the following:
saving /etc/foo.conf as /etc/foo.conf.rpmsave
This message means that changes you made to the configuration file may not be forward compatible with the new configuration file in the package, so RPM saved your original file and installed a new one. You should investigate the differences between the two configuration files and resolve them as soon as possible, to ensure that your system continues to function properly.
If you attempt to upgrade to a package with an older version number (that is, if a more updated version of the package is already installed), the output is similar to the following:
package foo-2.0-1 (which is newer than foo-1.0-1) is already installed
To force RPM to upgrade anyway, use the --oldpackage option:
rpm -Uvh --oldpackage foo-1.0-1.i386.rpm

12.2.5. Freshening

Freshening is similar to upgrading, except that only existent packages are upgraded. Type the following command at a shell prompt:
rpm -Fvh foo-1.2-1.i386.rpm
RPM's freshen option checks the versions of the packages specified on the command line against the versions of packages that have already been installed on your system. When a newer version of an already-installed package is processed by RPM's freshen option, it is upgraded to the newer version. However, RPM's freshen option does not install a package if no previously-installed package of the same name exists. This differs from RPM's upgrade option, as an upgrade does install packages whether or not an older version of the package was already installed.
Freshening works for single packages or package groups. If you have just downloaded a large number of different packages, and you only want to upgrade those packages that are already installed on your system, freshening does the job. Thus, you do not have to delete any unwanted packages from the group that you downloaded before using RPM.
In this case, issue the following command:
rpm -Fvh *.rpm
RPM automatically upgrades only those packages that are already installed.

12.2.6. Querying

The RPM database stores information about all RPM packages installed in your system. It is stored in the directory /var/lib/rpm/, and is used to query what packages are installed, what versions each package is, and any changes to any files in the package since installation, among others.
To query this database, use the -q option. The rpm -q package name command displays the package name, version, and release number of the installed package package name . For example, using rpm -q foo to query installed package foo might generate the following output:
foo-2.0-1
You can also use the following Package Selection Options with -q to further refine or qualify your query:
  • -a — queries all currently installed packages.
  • -f <filename> — queries the RPM database for which package owns f<filename> . When specifying a file, specify the absolute path of the file (for example, rpm -qf /bin/ls ).
  • -p <packagefile> — queries the uninstalled package <packagefile> .
There are a number of ways to specify what information to display about queried packages. The following options are used to select the type of information for which you are searching. These are called Package Query Options.
  • -i displays package information including name, description, release, size, build date, install date, vendor, and other miscellaneous information.
  • -l displays the list of files that the package contains.
  • -s displays the state of all the files in the package.
  • -d displays a list of files marked as documentation (man pages, info pages, READMEs, etc.).
  • -c displays a list of files marked as configuration files. These are the files you edit after installation to adapt and customize the package to your system (for example, sendmail.cf, passwd, inittab, etc.).
For options that display lists of files, add -v to the command to display the lists in a familiar ls -l format.

12.2.7. Verifying

Verifying a package compares information about files installed from a package with the same information from the original package. Among other things, verifying compares the size, MD5 sum, permissions, type, owner, and group of each file.
The command rpm -V verifies a package. You can use any of the Verify Options listed for querying to specify the packages you wish to verify. A simple use of verifying is rpm -V foo, which verifies that all the files in the foo package are as they were when they were originally installed. For example:
  • To verify a package containing a particular file:
    rpm -Vf /usr/bin/foo
    In this example, /usr/bin/foo is the absolute path to the file used to query a package.
  • To verify ALL installed packages throughout the system:
    rpm -Va
  • To verify an installed package against an RPM package file:
    rpm -Vp foo-1.0-1.i386.rpm
    This command can be useful if you suspect that your RPM databases are corrupt.
If everything verified properly, there is no output. If there are any discrepancies, they are displayed. The format of the output is a string of eight characters (a c denotes a configuration file) and then the file name. Each of the eight characters denotes the result of a comparison of one attribute of the file to the value of that attribute recorded in the RPM database. A single period (.) means the test passed. The following characters denote specific discrepancies:
  • 5 — MD5 checksum
  • S — file size
  • L — symbolic link
  • T — file modification time
  • D — device
  • U — user
  • G — group
  • M — mode (includes permissions and file type)
  • ? — unreadable file
If you see any output, use your best judgment to determine if you should remove the package, reinstall it, or fix the problem in another way.

12.3. Checking a Package's Signature

If you wish to verify that a package has not been corrupted or tampered with, examine only the md5sum by typing the following command at a shell prompt (where <rpm-file> is the file name of the RPM package):
rpm -K --nosignature <rpm-file>
The message <rpm-file>: md5 OK is displayed. This brief message means that the file was not corrupted by the download. To see a more verbose message, replace -K with -Kvv in the command.
On the other hand, how trustworthy is the developer who created the package? If the package is signed with the developer's GnuPG key, you know that the developer really is who they say they are.
An RPM package can be signed using Gnu Privacy Guard (or GnuPG), to help you make certain your downloaded package is trustworthy.
GnuPG is a tool for secure communication; it is a complete and free replacement for the encryption technology of PGP, an electronic privacy program. With GnuPG, you can authenticate the validity of documents and encrypt/decrypt data to and from other recipients. GnuPG is capable of decrypting and verifying PGP 5.x files as well.
During installation, GnuPG is installed by default. That way you can immediately start using GnuPG to verify any packages that you receive from Red Hat. Before doing so, you must first import Red Hat's public key.

12.3.1. Importing Keys

To verify Red Hat packages, you must import the Red Hat GPG key. To do so, execute the following command at a shell prompt:
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
To display a list of all keys installed for RPM verification, execute the command:
rpm -qa gpg-pubkey*
For the Red Hat key, the output includes:
gpg-pubkey-37017186-45761324
To display details about a specific key, use rpm -qi followed by the output from the previous command:
rpm -qi gpg-pubkey-37017186-45761324

12.3.2. Verifying Signature of Packages

To check the GnuPG signature of an RPM file after importing the builder's GnuPG key, use the following command (replace <rpm-file> with the filename of the RPM package):
rpm -K <rpm-file>
If all goes well, the following message is displayed: md5 gpg OK. This means that the signature of the package has been verified, and that it is not corrupt.

12.4. Practical and Common Examples of RPM Usage

RPM is a useful tool for both managing your system and diagnosing and fixing problems. The best way to make sense of all of its options is to look at some examples.
  • Perhaps you have deleted some files by accident, but you are not sure what you deleted. To verify your entire system and see what might be missing, you could try the following command:
    rpm -Va
    If some files are missing or appear to have been corrupted, you should probably either re-install the package or uninstall and then re-install the package.
  • At some point, you might see a file that you do not recognize. To find out which package owns it, enter:
    rpm -qf /usr/bin/ggv
    The output would look like the following:
    ggv-2.6.0-2
  • We can combine the above two examples in the following scenario. Say you are having problems with /usr/bin/paste. You would like to verify the package that owns that program, but you do not know which package owns paste. Enter the following command,
    rpm -Vf /usr/bin/paste
    and the appropriate package is verified.
  • Do you want to find out more information about a particular program? You can try the following command to locate the documentation which came with the package that owns that program:
    rpm -qdf /usr/bin/free
    The output would be similar to the following:
    /usr/share/doc/procps-3.2.3/BUGS
    /usr/share/doc/procps-3.2.3/FAQ
    /usr/share/doc/procps-3.2.3/NEWS
    /usr/share/doc/procps-3.2.3/TODO
    /usr/share/man/man1/free.1.gz
    /usr/share/man/man1/pgrep.1.gz
    /usr/share/man/man1/pkill.1.gz
    /usr/share/man/man1/pmap.1.gz
    /usr/share/man/man1/ps.1.gz
    /usr/share/man/man1/skill.1.gz
    /usr/share/man/man1/slabtop.1.gz
    /usr/share/man/man1/snice.1.gz
    /usr/share/man/man1/tload.1.gz
    /usr/share/man/man1/top.1.gz
    /usr/share/man/man1/uptime.1.gz
    /usr/share/man/man1/w.1.gz
    /usr/share/man/man1/watch.1.gz
    /usr/share/man/man5/sysctl.conf.5.gz
    /usr/share/man/man8/sysctl.8.gz
    /usr/share/man/man8/vmstat.8.gz
  • You may find a new RPM, but you do not know what it does. To find information about it, use the following command:
    rpm -qip crontabs-1.10-7.noarch.rpm
    The output would be similar to the following:
    Name        : crontabs                     Relocations: (not relocatable)
    Version     : 1.10                              Vendor: Red Hat, Inc.
    Release     : 7                             Build Date: Mon 20 Sep 2004 05:58:10 PM EDT
    Install Date: (not installed)               Build Host: tweety.build.redhat.com
    Group       : System Environment/Base       Source RPM: crontabs-1.10-7.src.rpm
    Size        : 1004                             License: Public Domain
    Signature   : DSA/SHA1, Wed 05 Jan 2005 06:05:25 PM EST, Key ID 219180cddb42a60e
    Packager    : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
    Summary     : Root crontab files used to schedule the execution of programs.
    Description : The crontabs package contains root crontab files. Crontab is the
    program used to install, uninstall, or list the tables used to drive the
    cron daemon. The cron daemon checks the crontab files to see when
    particular commands are scheduled to be executed. If commands are
    scheduled, then it executes them.
  • Perhaps you now want to see what files the crontabs RPM installs. You would enter the following:
    rpm -qlp crontabs-1.10-5.noarch.rpm
    The output is similar to the following:
    /etc/cron.daily
    /etc/cron.hourly
    /etc/cron.monthly
    /etc/cron.weekly
    /etc/crontab
    /usr/bin/run-parts
These are just a few examples. As you use RPM, you may find more uses for it.

12.5. Additional Resources

RPM is an extremely complex utility with many options and methods for querying, installing, upgrading, and removing packages. Refer to the following resources to learn more about RPM.

12.5.1. Installed Documentation

  • rpm --help — This command displays a quick reference of RPM parameters.
  • man rpm — The RPM man page gives more detail about RPM parameters than the rpm --help command.

12.5.2. Useful Websites

12.5.3. Related Books

Chapter 13. Package Management Tool

If you prefer to use a graphical interface to view and manage packages in your system, you can use the Package Management Tool, better known as pirut. This tool allows you to perform basic package management of your system through an easy-to-use interface to remove installed packages or download (and install) packages compatible to your system. It also allows you to view what packages are installed in your system and which ones are available for download from Red Hat Network. In addition, the Package Management Tool also automatically resolves any critical dependencies when you install or remove packages in the same way that the rpm command does.

Note

While the Package Management Tool can automatically resolve dependencies during package installation and removal, it cannot perform a forced install / remove the same way that rpm -e --nodeps or rpm -U --nodeps can.
The X Window System is required to run the Package Management Tool. To start the application, go to Applications (the main menu on the panel) > Add/Remove Software. Alternatively, you can type the commands system-config-packages or pirut at shell prompt.
Package Management Tool

Figure 13.1. Package Management Tool


13.1. Listing and Analyzing Packages

You can use the Package Management Tool to search and list all packages installed in your system, as well as any packages available for you to download. The Browse, Search, and List tabs present different options in viewing, analyzing, installing or removing packages.
The Browse tab allows you to view packages by group. In Figure 13.1, “Package Management Tool”, the left window shows the different package group types you can choose from (for example, Desktop Environments, Applications, Development and more). When a package group type is selected, the right window displays the different package groups of that type.
To view what packages are included in a package group, click Optional packages. Installed packages are checked.
Optional Packages

Figure 13.2. Optional Packages


The List tab displays a list of packages installed or available for download. Packages already installed in your system are marked with a green check ( ).
By default, the All packages option above the main window is selected; this specifies that all packages be displayed. Use the Installed packages option to display only packages that are already installed in your system, and the Available packages option to view what packages you can download and install.
The Search tab allows you to use keywords to search for particular packages. This tab also allows you to view a short description of a package. To do so, simply select a package and click the Package Details button below the main window.

13.2. Installing and Removing Packages

To install a package available for download, click the checkbox beside the package name. When you do so, an installation icon ( ) appears beside its checkbox. This indicates that the package is queued for download and installation. You can select multiple packages to download and install; once you have made your selection, click the Apply button.
Package installation

Figure 13.3. Package installation


If there are any package dependencies for your selected downloads, the Package Management Tool will notify you accordingly. Click Details to view what additional packages are needed. To proceed with downloading and installing the package (along with all other dependent packages) click Continue.
Package dependencies: installation

Figure 13.4. Package dependencies: installation


Removing a package can be done in a similar manner. To remove a package installed in your system, click the checkbox beside the package name. The green check appearing beside the package name will be replaced by a package removal icon ( ). This indicates that the package is queued for removal; you can also select multiple packages to be removed at the same time. Once you have selected the packages you want to remove, click the Apply button.
Package removal

Figure 13.5. Package removal


Note that if any other installed packages are dependent on the package you are removing, they will be removed as well. The Package Management Tool will notify you if there are any such dependencies. Click Details to view what packages are dependent on the one you are removing. To proceed with removing your selected package/s (along with all other dependent packages) click Continue.
Package dependencies: removal

Figure 13.6. Package dependencies: removal


You can install and remove multiple packages by selecting packages to be installed / removed and then clicking Apply. The Package selections window displays the number of packages to be installed and removed.
Installing and removing packages simultaneously

Figure 13.7. Installing and removing packages simultaneously


Chapter 14. YUM (Yellowdog Updater Modified)

Yellowdog Update, Modified (YUM) is a package manager that was developed by Duke University to improve the installation of RPMs. yum searches numerous repositories for packages and their dependencies so they may be installed together in an effort to alleviate dependency issues. Red Hat Enterprise Linux 5.10 uses yum to fetch packages and install RPMs.
up2date is now deprecated in favor of yum (Yellowdog Updater Modified). The entire stack of tools which installs and updates software in Red Hat Enterprise Linux 5.10 is now based on yum. This includes everything, from the initial installation via Anaconda to host software management tools like pirut.
yum also allows system administrators to configure a local (i.e. available over a local network) repository to supplement packages provided by Red Hat. This is useful for user groups that use applications and packages that are not officially supported by Red Hat.
Aside from being able to supplement available packages for local users, using a local yum repository also saves bandwidth for the entire network. Further, clients that use local yum repositories do not need to be registered individually to install or update the latest packages from Red Hat Network.

14.1. Setting Up a Yum Repository

To set up a repository for Red Hat Enterprise Linux packages, follow these steps:
  1. Install the createrepo package:
    ~]# yum install createrepo
  2. Copy all the packages you want to provide in the repository into one directory (/mnt/local_repo for example).
  3. Run createrepo on that directory (for example, createrepo /mnt/local_repo). This will create the necessary metadata for your Yum repository.

14.2.  yum Commands

yum commands are typically run as yum <command> <package name/s> . By default, yum will automatically attempt to check all configured repositories to resolve all package dependencies during an installation/upgrade.
The following is a list of the most commonly-used yum commands. For a complete list of available yum commands, refer to man yum.
yum install <package name/s>
Used to install the latest version of a package or group of packages. If no package matches the specified package name(s), they are assumed to be a shell glob, and any matches are then installed.
yum update <package name/s>
Used to update the specified packages to the latest available version. If no package name/s are specified, then yum will attempt to update all installed packages.
If the --obsoletes option is used (i.e. yum --obsoletes <package name/s> , yum will process obsolete packages. As such, packages that are obsoleted across updates will be removed and replaced accordingly.
yum check-update
This command allows you to determine whether any updates are available for your installed packages. yum returns a list of all package updates from all repositories if any are available.
yum remove <package name/s>
Used to remove specified packages, along with any other packages dependent on the packages being removed.
yum provides <file name>
Used to determine which packages provide a specific file or feature.
yum search <keyword>
This command is used to find any packages containing the specified keyword in the description, summary, packager and package name fields of RPMs in all repositories.
yum localinstall <absolute path to package name/s>
Used when using yum to install a package located locally in the machine.

14.3.  yum Options

yum options are typically stated before specific yum commands; i.e. yum <options> <command> <package name/s> . Most of these options can be set as default using the configuration file.
The following is a list of the most commonly-used yum options. For a complete list of available yum options, refer to man yum.
-y
Answer "yes" to every question in the transaction.
-t
Sets yum to be "tolerant" of errors with regard to packages specified in the transaction. For example, if you run yum update package1 package2 and package2 is already installed, yum will continue to install package1.
--exclude=<package name>
Excludes a specific package by name or glob in a specific transaction.

14.4. Configuring yum

By default, yum is configured through /etc/yum.conf. The following is an example of a typical /etc/yum.conf file:
[main]
cachedir=/var/cache/yum
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
distroverpkg=redhat-release
tolerant=1
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
metadata_expire=1800
[myrepo]
name=RHEL 5 $releasever - $basearch
baseurl=http://local/path/to/yum/repository/
enabled=1
A typical /etc/yum.conf file is made up of two types of sections: a [main] section, and a repository section. There can only be one [main] section, but you can specify multiple repositories in a single /etc/yum.conf.

14.4.1.  [main] Options

The [main] section is mandatory, and there must only be one. For a complete list of options you can use in the [main] section, refer to man yum.conf.
The following is a list of the most commonly-used options in the [main] section.
cachedir
This option specifies the directory where yum should store its cache and database files. By default, the cache directory of yum is /var/cache/yum.
keepcache=<1 or 0>
Setting keepcache=1 instructs yum to keep the cache of headers and packages after a successful installation. keepcache=1 is the default.
reposdir=<absolute path to directory of .repo files>
This option allows you to specify a directory where .repo files are located. .repo files contain repository information (similar to the [repository] section of /etc/yum.conf).
yum collects all repository information from .repo files and the [repository] section of the /etc/yum.conf file to create a master list of repositories to use for each transaction. Refer to Section 14.4.2, “ [repository] Options” for more information about options you can use for both the [repository] section and .repo files.
If reposdir is not set, yum uses the default directory /etc/yum.repos.d.
gpgcheck=<1 or 0>
This disables/enables GPG signature checking on packages on all repositories, including local package installation. The default is gpgcheck=0, which disables GPG checking.
If this option is set in the [main] section of the /etc/yum.conf file, it sets the GPG checking rule for all repositories. However, you can also set this on individual repositories instead; i.e., you can enable GPG checking on one repository while disabling it on another.
assumeyes=<1 or 0>
This determines whether or not yum should prompt for confirmation of critical actions. The default if assumeyes=0, which means yum will prompt you for confirmation.
If assumeyes=1 is set, yum behaves in the same way that the command line option -y does.
tolerant=<1 or 0>
When enabled (tolerant=1), yum will be tolerant of errors on the command line with regard to packages. This is similar to the yum command line option -t.
The default value for this is tolerant=0 (not tolerant).
exclude=<package name/s>
This option allows you to exclude packages by keyword during installation/updates. If you are specifying multiple packages, this is a space-delimited list. Shell globs using wildcards (for example, * and ?) are allowed.
retries=<number of retries>
This sets the number of times yum should attempt to retrieve a file before returning an error. Setting this to 0 makes yum retry forever. The default value is 6.

14.4.2.  [repository] Options

The [repository] section of the /etc/yum.conf file contains information about a repository yum can use to find packages during package installation, updating and dependency resolution. A repository entry takes the following form:
[repository ID]
name=repository name
baseurl=url, file or ftp://path to repository
You can also specify repository information in a separate .repo files (for example, rhel5.repo). The format of repository information placed in .repo files is identical with the [repository] of /etc/yum.conf.
.repo files are typically placed in /etc/yum.repos.d, unless you specify a different repository path in the [main] section of /etc/yum.conf with reposdir=. .repo files and the /etc/yum.conf file can contain multiple repository entries.
Each repository entry consists of the following mandatory parts:
[repository ID]
The repository ID is a unique, one-word string that serves as a repository identifier.
name=repository name
This is a human-readable string describing the repository.
baseurl=http, file or ftp://path
This is a URL to the directory where the repodatadirectory of a repository is located. If the repository is local to the machine, use baseurl=file://path to local repository . If the repository is located online using HTTP, use baseurl=http://link . If the repository is online and uses FTP, use baseurl=ftp://link .
If a specific online repository requires basic HTTP authentication, you can specify your username and password in the baseurl line by prepending it as username:password@link. For example, if a repository on http://www.example.com/repo/ requires a username of "user" and a password os "password", then the baseurl link can be specified as baseurl=http://user:password@www.example.com/repo/.
The following is a list of options most commonly used in repository entries. For a complete list of repository entries, refer to man yum.conf.
gpgcheck=<1 or 0>
This disables/enables GPG signature checking a specific repository. The default is gpgcheck=0, which disables GPG checking.
gpgkey=URL
This option allows you to point to a URL of the ASCII-armoured GPG key file for a repository. This option is normally used if yum needs a public key to verify a package and the required key was not imported into the RPM database.
If this option is set, yum will automatically import the key from the specified URL. You will be prompted before the key is installed unless you set assumeyes=1 (in the [main] section of /etc/yum.conf) or -y (in a yum transaction).
exclude=<package name/s>
This option is similar to the exclude option in the [main] section of /etc/yum.conf. However, it only applies to the repository in which it is specified.
includepkgs=<package name/s>
This option is the opposite of exclude. When this option is set on a repository, yum will only be able to see the specified packages in that repository. By default, all packages in a repository are visible to yum.

14.5. Upgrading the System Off-line with ISO and Yum

For systems that are disconnected from the Internet or Red Hat Network, using the yum update command with the Red Hat Enterprise Linux installation ISO image is an easy and quick way to upgrade systems to the latest minor version. The following steps illustrate the upgrading process:
  1. Create a target directory to mount your ISO image. This directory is not automatically created when mounting, so create it before proceeding to the next step, as root, type:
    mkdir mount_dir
    Replace mount_dir with a path to the mount directory. Typicaly, users create it as a subdirectory in the /media/ directory.
  2. Mount the Red Hat Enterprise Linux 5 installation ISO image to the previously created target directory. As root, type:
    mount -o loop iso_name mount_dir
    Replace iso_name with a path to your ISO image and mount_dir with a path to the target directory. Here, the -o loop option is required to mount the file as a block device.
  3. Check the numeric value found on the first line of the .discinfo file from the mount directory:
    head -n1 mount_dir/.discinfo
    The output of this command is an identification number of the ISO image, you need to know it to perform the following step.
  4. Create a new file in the /etc/yum.repos.d/ directory, named for instance new.repo, and add a content in the following form. Note that configuration files in this directory must have the .repo extension to function properly.
    [repository] 
    mediaid=media_id 
    name=repository_name
    baseurl=repository_url
    gpgkey=gpg_key 
    enabled=1 
    gpgcheck=1
    
    Replace media_id with the numeric value found in mount_dir/.discinfo. Set the repository name instead of repository_name, replace repository_url with a path to a repository directory in the mount point and gpg_key with a path to the GPG key.
    For example, the repository settings for Red Hat Enterprise Linux 5 Server ISO can look as follows:
    [rhel5-Server] 
    mediaid=1354216429.587870 
    name=RHEL5-Server
    baseurl=file:///media/rhel5/Server 
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release 
    enabled=1 
    gpgcheck=1
    
  5. Update all yum repositories including /etc/yum.repos.d/new.repo created in previous steps. As root, type:
    yum update
    This upgrades your system to the version provided by the mounted ISO image.
  6. After successful upgrade, you can unmount the ISO image, with the root privileges:
    umount mount_dir
    where mount_dir is a path to your mount directory. Also, you can remove the mount directory created in the first step. As root, type:
    rmdir mount_dir
  7. If you will not use the previously created configuration file for another installation or update, you can remove it. As root, type:
    rm /etc/yum.repos.d/new.repo

Example 14.1. Upgrading from Red Hat Enterprise Linux 5.8 to 5.9

Imagine you need to upgrade your system without access to the Internet connection. To do so, you want to use an ISO image with the newer version of the system, called for instance RHEL5.9-Server-20121129.0-x86_64-DVD1.iso. You have crated a target directory /media/rhel5/. As root, change into the directory with your ISO image and type:
~]# mount -o loop RHEL5.9-Server-20121129.0-x86_64-DVD1.iso /media/rhel5/
To find the identification number of the mounted image, run:
~]# head -n1 /media/rhel5/.discinfo 
1354216429.587870
You need this number to configure your mount point as a yum repository. Create the/etc/yum.repos.d/rhel5.repo file and insert the following text into it:
[rhel5-Server] 
mediaid=1354216429.587870 
name=RHEL5-Server
baseurl=file:///media/rhel5/Server 
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release 
enabled=1 
gpgcheck=1
Update the yum repository, which effectively upgrades your system to a version provided by RHEL5.9-Server-20121129.0-x86_64-DVD1.iso. As root, execute:
~]# yum update
When your system is successfully upgraded, unmount the image, remove the target directory and the configuration file:
~]# umount /media/rhel5/
~]# rmdir /media/rhel5/
~]# rm /etc/yum.repos.d/rhel5.repo

14.6. Useful yum Variables

The following is a list of variables you can use for both yum commands and yum configuration files (i.e. /etc/yum.conf and .repo files).
$releasever
This is replaced with the package's version, as listed in distroverpkg. This defaults to the version of the redhat-release package.
$arch
This is replaced with your system's architecture, as listed by os.uname() in Python.
$basearch
This is replaced with your base architecture. For example, if $arch=i686 then $basearch=i386.
$YUM0-9
This is replaced with the value of the shell environment variable of the same name. If the shell environment variable does not exist, then the configuration file variable will not be replaced.

Chapter 15. Registering a System and Managing Subscriptions

Effective asset management requires a mechanism to handle the software inventory — both the type of products and the number of systems that the software is installed on. The subscription service provides that mechanism and gives transparency into both global allocations of subscriptions for an entire organization and the specific subscriptions assigned to a single system.
Red Hat Subscription Manager works with yum to unite content delivery with subscription management. The Subscription Manager handles only the subscription-system associations. yum or other package management tools handle the actual content delivery. Chapter 14, YUM (Yellowdog Updater Modified) describes how to use yum.

15.1. Using Red Hat Subscription Manager Tools

Both registration and subscriptions are managed on the local system through GUI and CLI tools called Red Hat Subscription Manager.

Note

The Red Hat Subscription Manager tools are always run as root because of the nature of the changes to the system. However, Red Hat Subscription Manager connects to the subscription service as a user account for the subscription service.

15.1.1. Launching the Red Hat Subscription Manager GUI

Red Hat Subscription Manager is listed as one of the administrative tools in the System > Administration menu in the top management bar.
Red Hat Subscription Manager Menu Option

Figure 15.1. Red Hat Subscription Manager Menu Option


Alternatively, the Red Hat Subscription Manager GUI can be opened from the command line with a single command:
[root@server1 ~]# subscription-manager-gui

15.1.2. Running the subscription-manager Command-Line Tool

Any of the operations that can be performed through the Red Hat Subscription Manager UI can also be performed by running the subscription-manager tool. This tool has the following format:
[root@server1 ~]# subscription-manager command [options]
Each command has its own set of options that are used with it. The subscription-manager help and manpage have more information.

Table 15.1. Common subscription-manager Commands

Command Description
register Registers or identifies a new system to the subscription service.
unregister Unregisters a machine, which strips its subscriptions and removes the machine from the subscription service.
subscribe Attaches a specific subscription to the machine.
redeem Auto-attaches a machine to a pre-specified subscription that was purchased from a vendor, based on its hardware and BIOS information.
unsubscribe Removes a specific subscription or all subscriptions from the machine.
list Lists all of the subscriptions that are compatible with a machine, either subscriptions that are actually attached to the machine or unused subscriptions that are available to the machine.

15.2. Registering and Unregistering a System

Systems can be registered with a subscription service during the firstboot process or as part of the kickstart setup (both described in the Installation Guide). Systems can also be registered after they have been configured or removed from the subscription service inventory (unregistered) if they will no longer be managed within that subscription service.

15.2.1. Registering from the GUI

  1. Launch Subscription Manager. For example:
    [root@server ~]# subscription-manager-gui
  2. If the system is not already registered, then there will be a Register button at the top of the window in the top right corner of the My Installed Products tab.
  3. To identify which subscription server to use for registration, enter the hostname of the service. The default service is Customer Portal Subscription Management, with the hostname subscription.rhn.redhat.com. To use a different subscription service, such as Subscription Asset Manager, enter the hostname of the local server.
    There are seveal different subscription services which use and recognize certificate-based subscriptions, and a system can be registered with any of them in firstboot:
    • Customer Portal Subscription Management, hosted services from Red Hat (the default)
    • Subscription Asset Manager, an on-premise subscription server which proxies content delivery back to the Customer Portal's services
    • CloudForms System Engine, an on-premise service which handles both subscription services and content delivery
  4. Enter the user credentials for the given subscription service to log in.
    The user credentials to use depend on the subscription service. When registering with the Customer Portal, use the Red Hat Network credentials for the administrator or company account.
    However, for Subscription Asset Manager or CloudForms System engine, the user account to use is created within the on-premise service and probably is not the same as the Customer Portal user account.
  5. Optionally, select the Manually assign subscriptions after registration checkbox.
    By default, the registration process automatically attaches the best-matched subscription to the system. This can be turned off so that the subscriptions can be selected manually, as in Section 15.3, “Attaching and Removing Subscriptions”.
  6. When registration begins, Subscription Manager scans for organizations and environments (sub-domains within the organization) to which to register the system.
    IT environments that use Customer Portal Subscription Management have only a single organization, so no further configuration is necessary. IT infrastructures that use a local subscription service like Subscription Asset Manager might have multiple organizations configured, and those organizations may have multiple environments configured within them.
    If multiple organizations are detected, Subscription Manager prompts to select the one to join.
  7. With the default setting, subscriptions are automatically selected and attached to the system. Review and confirm the subscriptions to attach to the system.
    1. If prompted, select the service level to use for the discovered subscriptions.
    2. Subscription Manager lists the selected subscription. This subscription selection must be confirmed by clicking the Subscribe button for the wizard to complete.

15.2.2. Registering from the Command Line

The simplest way to register a machine is to pass the register command with the user account information required to authenticate to Customer Portal Subscription Management. When the system is successfully authenticated, it echoes back the newly-assigned system inventory ID and the user account name which registered it.
The register options are listed in Table 15.2, “register Options”.

Example 15.1. Registering a System to the Customer Portal

[root@server1 ~]# subscription-manager register --username admin-example --password secret

The system has been registered with id: 7d133d55-876f-4f47-83eb-0ee931cb0a97

Example 15.2. Automatically Subscribing While Registering

The register command has an option, --autosubscribe, which allows the system to be registered to the subscription service and immediately attaches the subscription which best matches the system's architecture, in a single step.
[root@server1 ~]# subscription-manager register --username admin-example --password secret --autosubscribe
This is the same behavior as when registering with the default settings in the Subscription Manager UI.

Example 15.3. Registering a System with Subscription Asset Manager

With Subscription Asset Managr or CloudForms System Engine, an account can have multiple, independent subdivisions called organizationst is required that you specify which organization (essentially an independent group or unit within the main account) to join the system to. This is done by using the --org option in addition to the username and password. The given user must also have the access permissions to add systems to that organization.
To register with a subscription service other than Customer Portal Subscription Management, several additional options must be used to identify the environment and organizational divisions that the system is being registered to:
  • The username and password for the user account withint the subscription service itself
  • --serverurl to give the hostname of the subscription service
  • --baseurl to give the hostname of the content delivery service (for CloudForms System Engine only)
  • --org to give the name of the organization under which to register the system
  • --environment to give the name of an environment (group) within the organization to which to add the system; this is optional, since a default environment is set for any organization
    A system can only be added to an environment during registration.
[root@server1 ~]# subscription-manager register --username=admin-example --password=secret --org="IT Department" --environment="dev" --serverurl=sam-server.example.com

The system has been registered with id: 7d133d55-876f-4f47-83eb-0ee931cb0a97

Note

If the system is in a multi-org environment and no organization is given, the register command returns a Remote Server error.

Table 15.2. register Options

Options Description Required
--username=name Gives the content server user account name. Required
--password=password Gives the password for the user account. Required
--serverurl=hostname Gives the hostname of the subscription service to use. The default is for Customer Portal Subcription Management, subscription.rhn.redhat.com. If this option is not used, the system is registered with Customer Portal Subscription Management. Required for Subscription Asset Manager or CloudForms System Engine
--baseurl=URL Gives the hostname of the content delivery server to use to receive updates. Both Customer Portal Subscription Management and Subscription Asset Manager use Red Hat's hosted content delivery services, with the URL https://cdn.redhat.com. Since CloudForms System Engine hosts its own content, the URL must be used for systems registered with System Engine. Required for CloudForms System Engine
--org=name Gives the organization to which to join the system. Required, except for hosted environments
--environment=name Registers the system to an environment within an organization. Optional
--name=machine_name Sets the name of the system to register. This defaults to be the same as the hostname. Optional
--autosubscribe Automatically ataches the best-matched compatible subscription. This is good for automated setup operations, since the system can be configured in a single step. Optional
--activationkey=key Attaches existing subscriptions as part of the registration process. The subscriptions are pre-assigned by a vendor or by a systems administrator using Subscription Asset Manager. Optional
--servicelevel=None|Standard|Premium Sets the service level to use for subscriptions on that machine. This is only used with the --autosubscribe option. Optional
--release=NUMBER Sets the operating system minor release to use for subscriptions for the system. Products and updates are limited to that specific minor release version. This is used only used with the --autosubscribe option. Optional
--force Registers the system even if it is already registered. Normally, any register operations will fail if the machine is already registered. Optional

15.2.3. Unregistering

The only thing required to unregister a machine is to run the unregister command. This removes the system's entry from the subscription service, removes any subscriptions, and, locally, deletes its identity and subscription certificates.
From the command line, this requires only the unregister command.

Example 15.4. Unregistering a System

[root@server1 ~]# subscription-manager unregister

To unregister from the Subscription Manager GUI:
  1. Open the Subscription Manager UI.
    [root@server ~]# subscription-manager-gui
  2. Open the System menu, and select the Unregister item.
  3. Confirm that the system should be unregistered.

15.3. Attaching and Removing Subscriptions

Assigning a subscription to a system gives the system the ability to install and update any Red Hat product in that subscription. A subscription is a list of all of the products, in all variations, that were purchased at one time, and it defines both the products and the number of times that subscription can be used. When one of those licenses is associated with a system, that subscription is attached to the system.

15.3.1. Attaching and Removing Subscriptions through the GUI

15.3.1.1. Attaching a Subscription

  1. Launch Subscription Manager. For example:
    [root@server ~]# subscription-manager-gui
  2. Open the All Available Subscriptions tab.
  3. Optionally, set the date range and click the Filters button to set the filters to use to search for available subscriptions.
    Subscriptions can be filtered by their active date and by their name. The checkboxes provide more fine-grained filtering:
    • match my system shows only subscriptions which match the system architecture.
    • match my installed products shows subscriptions which work with currently installed products on the system.
    • have no overlap with existing subscriptions excludes subscriptions with duplicate products. If a subscription is already attached to the system for a specific product or if multiple subscriptions supply the same product, then the subscription service filters those subscriptions and shows only the best fit.
    • contain the text searches for strings, such as the product name, within the subscription or pool.
    After setting the date and filters, click the Update button to apply them.
  4. Select one of the available subscriptions.
  5. Click the Subscribe button.

15.3.1.2. Removing Subscriptions

  1. Launch Subscription Manager. For example:
    [root@server ~]# subscription-manager-gui
  2. Open the My Subscriptions tab.
    All of the active subscriptions to which the system is currently attached are listed. (The products available through the subscription may or may not be installed.)
  3. Select the subscription to remove.
  4. Click the Unsubscribe button in the bottom right of the window.

15.3.2. Attaching and Removing Subscriptions through the Command Line

15.3.2.1. Attaching Subscriptions

Attaching subscriptions to a system requires specifying the individual product or subscription to attach, using the --pool option.
[root@server1 ~]# subscription-manager subscribe --pool=XYZ01234567
The options for the subscribe command are listed in Table 15.3, “subscribe Options”.
The ID of the subscription pool for the purchased product must be specified. The pool ID is listed with the product subscription information, which is available from running the list command:
[root@server1 ~]# subscription-manager list --available

+-------------------------------------------+
    Available Subscriptions
+-------------------------------------------+
ProductName:            RHEL for Physical Servers
ProductId:              MKT-rhel-server
PoolId:                 ff8080812bc382e3012bc3845ca000cb
Quantity:               10
Expires:                2011-09-20
Alternatively,the best-fitting subscriptions, as identified by the subscription service, can be attached to the system by using the --auto option (which is analogous to the --autosubscribe option with the register command).
[root@server1 ~]# subscription-manager subscribe --auto

Table 15.3. subscribe Options

Options Description Required
--pool=pool-id Gives the ID for the subscription to attach to the system. Required, unless --auto is used
--auto Automatically attaches the system to the best-match subscription or subscriptions. Optional
--quantity=number Attaches multiple counts of a subscription to the system. This is used to cover subscriptions that define a count limit, like using two 2-socket server subscriptions to cover a 4-socket machine. Optional
--servicelevel=None|Standard|Premium Sets the service level to use for subscriptions on that machine. This is only used with the --auto option. Optional

15.3.2.2. Removing Subscriptions from the Command Line

A system can be attached to multiple subscriptions and products. Similarly, a single subscription or all subscriptions can be removed from the system.
Running the unsubscribe command with the --all option removes every product subscription and subscription pool that is currently attached to the system.
[root@server1 ~]# subscription-manager unsubscribe --all
It is also possible to remove a single product subscription. Each product has an identifying X.509 certificate installed with it. The product subscription to remove is identified in the unsubscribe command by referencing the ID number of that X.509 certificate.
  1. Get the serial number for the product certificate, if you are removing a single product subscription. The serial number can be obtained from the subscription#.pem file (for example, 392729555585697907.pem) or by using the list command. For example:
    [root@server1 ~]# subscription-manager list --consumed
    
    +-------------------------------------------+
        Consumed Product Subscriptions
    +-------------------------------------------+
    
    
    ProductName:         High availability (cluster suite)
    ContractNumber:      0
    SerialNumber:        11287514358600162
    Active:              True
    Begins:              2010-09-18
    Expires:             2011-11-18
  2. Run the subscription-manager tool with the --serial option to specify the certificate.
    [root@server1 ~]# subscription-manager unsubscribe --serial=11287514358600162

15.4. Redeeming Vendor Subscriptions

Systems can be set up with pre-existing subscriptions already available to that system. For some systems which were purchased through third-party vendors, a subscription to Red Hat products is included with the purchase of the machine.
Red Hat Subscription Manager pulls information about the system hardware and the BIOS into the system facts to recognize the hardware vendor. If the vendor and BIOS information matches a certain configuration, then the subscription can be redeemed, which will allow subscriptions to be automatically attached to the system.

15.4.1. Redeeming Subscriptions through the GUI

Note

If the machine does not have any subscriptions to be redeemed, then the Redeem menu item is not there.
  1. Launch Subscription Manager. For example:
    [root@server ~]# subscription-manager-gui
  2. If necessary, register the system, as described in Section 15.2.1, “Registering from the GUI”.
  3. Open the System menu in the top left of the window, and click the Redeem item.
  4. In the dialog window, enter the email address to send the notification to when the redemption is complete. Because the redemption process can take several minutes to contact the vendor and receive information about the pre-configured subscriptions, the notification message is sent through email rather than through the Subscription Manager dialog window.
  5. Click the Redeem button.
It can take up to ten minutes for the confirmation email to arrive.

15.4.2. Redeeming Subscriptions through the Command Line

Note

The machine must be registered first so that the subscription service can properly identify the system and its subscriptions.
The machine subscriptions are redeemed by running the redeem command, with an email address to send the redemption email to when the process is complete.
# subscription-manager redeem --email=jsmith@example.com

15.5. Attaching Subscriptions from a Subscription Asset Manager Activation Key

A local Subscription Asset Manager can pre-configure subscriptions to use for a system, and that pre-configured set of subscriptions is identified by an activation key. That key can then be used to attach those subscriptions on a local system.
The Subscription Asset Manager activation key can be used as part of the registration process for the new system:
# subscription-manager register --username=jsmith --password=secret --org="IT Dept" --activationkey=abcd1234
If there are multiple organizations, it is still necessary to specify the organization for the system. That information is not defined in the activation key.

15.6. Setting Preferences for Systems

Auto-attaching and healing (updating) subscriptions selects what subscriptions to attach to a system based on a variety of criteria, including current installed products, hardware, and architecture. It is possible to set two additional preferences for Subscription Manager to use:
  • Service levels for subscriptions
  • The operating system minor version (X.Y) to use
This is especially useful for healing, which runs daily to ensure that all installed products and current subscriptions remain active.

15.6.1. Setting Preferences in the UI

Both a service level preference and an operating system release version preference are set in the System Preferences dialog box in Subscription Manager.
  1. Open the Subscription Manager.
  2. Open the System menu.
  3. Select the System Preferences menu item.
  4. Select the desired service level agreement preference from the drop-down menu. Only service levels available to the Red Hat account, based on all of its active subscriptions, are listed.
  5. Select the operating system release preference in the Release version drop-down menu. The only versions listed are Red Hat Enterprise Linux versions for which the account has an active subscription.
  6. The preferences are saved and applied to future subscription operations when they are set. To close the dialog, click Close.

15.6.2. Setting Service Levels Through the Command Line

A general service level preference can be set using the service-level --set command.

Example 15.5. Setting a Service Level Preference

First, list the available service levels for the system, using the --list option with the service-level command.
[root@server ~]# subscription-manager service-level --list
+-------------------------------------------+
          Available Service Levels
+-------------------------------------------+
Standard
None
Premium
Self-Support
Then, set the desired level for the system.
[root@server ~]# subscription-manager service-level --set=self-support
Service level set to: self-support
The current setting for the local system is shown with the --show option:
[root#server ~]# subscription-manager service-level --show
Current service level: self-support

A service level preference can be defined when a subscription operation is being run (such as registering a system or attaching subscriptions after registration). This can be used to override a system preference. Both the register and subscribe commands have the --servicelevel option to set a preference for that action.

Example 15.6. Autoattaching Subscriptions with a Premium Service Level

[root#server ~]# subscription-manager subscribe --auto --servicelevel Premium
Service level set to: Premium
Installed Product Current Status:
ProductName:            Red Hat Enterprise Linux 5 Server
Status:                 Subscribed

Note

The --servicelevel option requires the --autosubscribe option (for register) or --auto option (for subscribe). It cannot be used when attaching a specified pool or when importing a subscription.

15.6.3. Setting a Preferred Operating System Release Version in the Command Line

Many IT environments have to be certified to meet a certain level of security or other criteria. In that case, major upgrades must be carefully planned and controlled — so administrators cannot simply run yum update and move from version to version.
Setting a release version preference limits the system access to content repositories associated with that operating system version instead of automatically using the newest or latest version repositories.
For example, if the preferred operating system version is 5.9, then 5.9 content repositories will be preferred for all installed products and attached subscriptions for the system, even as other repositories become available.

Example 15.7. Setting an Operating System Release During Registration

A preference for a release version can be set when the system is registered by using --release option with the register. This applies the release preference to any subscriptions selected and auto-attached to the system at registration time.
Setting a preference requires the --autosubscribe option, because it is one of the criteria used to select subscriptions to auto-attach.
[root#server ~]# subscription-manager register --autosubscribe --release=5.9 --username=admin@example.com...

Note

Unlike setting a service level preference, a release preference can only be used during registration or set as a preference. It cannot be specified with the subscribe command.

Example 15.8. Setting an Operating System Release Preference

The release command can display the available operating system releases, based on the available, purchased (not only attached) subscriptions for the organization.
[root#server ~]# subscription-manager release --list
+-------------------------------------------+
          Available Releases
+-------------------------------------------+
5.8
5.9
5Server
The --set then sets the preference to one of the available release versions:
[root#server ~]# subscription-manager release --set=5.9
Release version set to: 5.9

15.6.4. Removing a Preference

To remove a preference through the command line, use the --unset with the appropriate command. For example, to unset a release version preference:
[root#server ~]# subscription-manager release --unset
Release version set to:
To remove or unset a preference in the UI:
  1. Open the Subscription Manager.
  2. Open the System menu.
  3. Select the System Preferences menu item.
  4. Set the service level or release version value to the blank line in the corresponding drop-down menu.
  5. Click Close.

15.7. Managing Subscription Expiration and Notifications

Subscriptions are active for a certain period of time, called the validity period. When a subscription is purchased, the start and end dates for the contract are set.
On a system, there can be multiple subscriptions attached. Each product requires its own subscription. Additionally, some products may require multiple quantities for it to be fully subscribed. For example, a 16 socket machine may require four 4-socket operating system subscriptions to cover the socket count.
The My Installed Software tab shows the subscription status for the entire system. It also shows a date; that is the first date that a product subscription goes from valid to invalid (meaning it expires).
Valid Until...

Figure 15.2. Valid Until...


The Red Hat Subscription Manager provides a series of log and UI messages that indicate any changes to the valid certificates of any installed products for a system. In the Subscription Manager GUI, the status of the system subscriptions is color-coded, where green means all products are fully subscribed, yellow means that some products may not be subscribed but updates are still in effect, and red means that updates are disabled.
Color-Coded Status Views

Figure 15.3. Color-Coded Status Views


The command-line tools also indicate that status of the machine. The green, yellow, and red codes translate to text status messages of subscribed, partially subscribed, and expired/not subscribed, respectively.
[root@server ~]# subscription-manager list
+-------------------------------------------+
    Installed Product Status
+-------------------------------------------+

ProductName:            Red Hat Enterprise Linux Server
Status: Not Subscribed
Expires:                                         
SerialNumber:                                    
ContractNumber:                                  
AccountNumber:
Whenever there is a warning about subscription changes, a small icon appears in the top menu bar, similar to a fuel gauge.
Subscription Notification Icon

Figure 15.4. Subscription Notification Icon


As any installed product nears the expiration date of the subscription, the Subscription Manager daemon will issue a warning. A similar message is given when the system has products without a valid certificate, meaning either a subscription is not atached that covers that product or the product is installed past the expiration of the subscription. Clicking the Manage My Subscriptions... button in the subscription notification window opens the Red Hat Subscription Manager GUI to view and update subscriptions.
Subscription Warning Message

Figure 15.5. Subscription Warning Message


When the Subscription Manager UI opens, whether it was opened through a notification or just opened normally, there is an icon in the upper left corner that shows whether products lack a valid certificate. The easiest way to attach subscriptions which match invalidated products is to click the Autosubscribe button.
Autosubscribe Button

Figure 15.6. Autosubscribe Button


The Subscribe System dialog shows a targeted list of available subscriptions that apply to the specific products that do not have valid certificates (assuming subscriptions are available).
Subscribe System

Figure 15.7. Subscribe System


Part III. Network-Related Configuration

After explaining how to configure the network, this part discusses topics related to networking such as how to allow remote logins, share files and directories over the network, and set up a Web server.

Table of Contents

16. Network Interfaces
16.1. Network Configuration Files
16.2. Interface Configuration Files
16.2.1. Ethernet Interfaces
16.2.2. IPsec Interfaces
16.2.3. Channel Bonding Interfaces
16.2.4. Alias and Clone Files
16.2.5. Dialup Interfaces
16.2.6. Other Interfaces
16.3. Interface Control Scripts
16.4. Static Routes and the Default Gateway
16.5. Network Function Files
16.6. Additional Resources
16.6.1. Installed Documentation
17. Network Configuration
17.1. Overview
17.2. Establishing an Ethernet Connection
17.3. Establishing an ISDN Connection
17.4. Establishing a Modem Connection
17.5. Establishing an xDSL Connection
17.6. Establishing a Token Ring Connection
17.7. Establishing a Wireless Connection
17.8. Managing DNS Settings
17.9. Managing Hosts
17.10. Working with Profiles
17.11. Device Aliases
17.12. Saving and Restoring the Network Configuration
18. Controlling Access to Services
18.1. Runlevels
18.2. TCP Wrappers
18.2.1. xinetd
18.3. Services Configuration Tool
18.4. ntsysv
18.5. chkconfig
18.6. Additional Resources
18.6.1. Installed Documentation
18.6.2. Useful Websites
19. Berkeley Internet Name Domain (BIND)
19.1. Introduction to DNS
19.1.1. Nameserver Zones
19.1.2. Nameserver Types
19.1.3. BIND as a Nameserver
19.2. /etc/named.conf
19.2.1. Common Statement Types
19.2.2. Other Statement Types
19.2.3. Comment Tags
19.3. Zone Files
19.3.1. Zone File Directives
19.3.2. Zone File Resource Records
19.3.3. Example Zone File
19.3.4. Reverse Name Resolution Zone Files
19.4. Using rndc
19.4.1. Configuring /etc/named.conf
19.4.2. Configuring /etc/rndc.conf
19.4.3. Command Line Options
19.5. Advanced Features of BIND
19.5.1. DNS Protocol Enhancements
19.5.2. Multiple Views
19.5.3. Security
19.5.4. IP version 6
19.6. Common Mistakes to Avoid
19.7. Additional Resources
19.7.1. Installed Documentation
19.7.2. Useful Websites
19.7.3. Related Books
20. OpenSSH
20.1. Features of SSH
20.1.1. Why Use SSH?
20.2. SSH Protocol Versions
20.3. Event Sequence of an SSH Connection
20.3.1. Transport Layer
20.3.2. Authentication
20.3.3. Channels
20.4. Configuring an OpenSSH Server
20.4.1. Requiring SSH for Remote Connections
20.5. OpenSSH Configuration Files
20.6. Configuring an OpenSSH Client
20.6.1. Using the ssh Command
20.6.2. Using the scp Command
20.6.3. Using the sftp Command
20.7. More Than a Secure Shell
20.7.1. X11 Forwarding
20.7.2. Port Forwarding
20.7.3. Generating Key Pairs
20.8. Additional Resources
20.8.1. Installed Documentation
20.8.2. Useful Websites
21. Network File System (NFS)
21.1. How It Works
21.1.1. Required Services
21.2. NFS Client Configuration
21.2.1. Mounting NFS File Systems using /etc/fstab
21.3. autofs
21.3.1. What's new in autofs version 5?
21.3.2. autofs Configuration
21.3.3. autofs Common Tasks
21.4. Common NFS Mount Options
21.5. Starting and Stopping NFS
21.6. NFS Server Configuration
21.6.1. Exporting or Sharing NFS File Systems
21.6.2. Command Line Configuration
21.6.3. Running NFS Behind a Firewall
21.6.4. Hostname Formats
21.7. The /etc/exports Configuration File
21.7.1. The exportfs Command
21.8. Securing NFS
21.8.1. Host Access
21.8.2. File Permissions
21.9. NFS and portmap
21.9.1. Troubleshooting NFS and portmap
21.10. Using NFS over TCP
21.11. Additional Resources
21.11.1. Installed Documentation
21.11.2. Useful Websites
21.11.3. Related Books
22. Samba
22.1. Introduction to Samba
22.1.1. Samba Features
22.2. Samba Daemons and Related Services
22.2.1. Samba Daemons
22.3. Connecting to a Samba Share
22.3.1. Command Line
22.3.2. Mounting the Share
22.4. Configuring a Samba Server
22.4.1. Graphical Configuration
22.4.2. Command Line Configuration
22.4.3. Encrypted Passwords
22.5. Starting and Stopping Samba
22.6. Samba Server Types and the smb.conf File
22.6.1. Stand-alone Server
22.6.2. Domain Member Server
22.6.3. Domain Controller
22.7. Samba Security Modes
22.7.1. User-Level Security
22.7.2. Share-Level Security
22.8. Samba Account Information Databases
22.9. Samba Network Browsing
22.9.1. Domain Browsing
22.9.2. WINS (Windows Internetworking Name Server)
22.10. Samba with CUPS Printing Support
22.10.1. Simple smb.conf Settings
22.11. Samba Distribution Programs
22.12. Additional Resources
22.12.1. Installed Documentation
22.12.2. Related Books
22.12.3. Useful Websites
23. Dynamic Host Configuration Protocol (DHCP)
23.1. Why Use DHCP?
23.2. Configuring a DHCP Server
23.2.1. Configuration File
23.2.2. Lease Database
23.2.3. Starting and Stopping the Server
23.2.4. DHCP Relay Agent
23.3. Configuring a DHCP Client
23.4. Configuring a Multihomed DHCP Server
23.4.1. Host Configuration
23.5. Additional Resources
23.5.1. Installed Documentation
24. Migrating from MySQL 5.0 to MySQL 5.5
24.1. Upgrading from MySQL 5.0 to MySQL 5.5
25. Apache HTTP Server
25.1. Apache HTTP Server 2.2
25.1.1. Features of Apache HTTP Server 2.2
25.2. Migrating Apache HTTP Server Configuration Files
25.2.1. Migrating Apache HTTP Server 2.0 Configuration Files
25.2.2. Migrating Apache HTTP Server 1.3 Configuration Files to 2.0
25.3. Starting and Stopping httpd
25.4. Apache HTTP Server Configuration
25.4.1. Basic Settings
25.4.2. Default Settings
25.5. Configuration Directives in httpd.conf
25.5.1. General Configuration Tips
25.5.2. Configuration Directives for SSL
25.5.3. MPM Specific Server-Pool Directives
25.6. Adding Modules
25.7. Virtual Hosts
25.7.1. Setting Up Virtual Hosts
25.8. Apache HTTP Secure Server Configuration
25.8.1. An Overview of Security-Related Packages
25.8.2. An Overview of Certificates and Security
25.8.3. Using Pre-Existing Keys and Certificates
25.8.4. Types of Certificates
25.8.5. Generating a Key
25.8.6. How to configure the server to use the new key
25.9. Additional Resources
25.9.1. Useful Websites
26. FTP
26.1. The File Transfer Protocol
26.1.1. Multiple Ports, Multiple Modes
26.2. FTP Servers
26.2.1. vsftpd
26.3. Files Installed with vsftpd
26.4. Starting and Stopping vsftpd
26.4.1. Starting Multiple Copies of vsftpd
26.5. vsftpd Configuration Options
26.5.1. Daemon Options
26.5.2. Log In Options and Access Controls
26.5.3. Anonymous User Options
26.5.4. Local User Options
26.5.5. Directory Options
26.5.6. File Transfer Options
26.5.7. Logging Options
26.5.8. Network Options
26.6. Additional Resources
26.6.1. Installed Documentation
26.6.2. Useful Websites
27. Email
27.1. Email Protocols
27.1.1. Mail Transport Protocols
27.1.2. Mail Access Protocols
27.2. Email Program Classifications
27.2.1. Mail Transport Agent
27.2.2. Mail Delivery Agent
27.2.3. Mail User Agent
27.3. Mail Transport Agents
27.3.1. Sendmail
27.3.2. Postfix
27.3.3. Fetchmail
27.4. Mail Transport Agent (MTA) Configuration
27.5. Mail Delivery Agents
27.5.1. Procmail Configuration
27.5.2. Procmail Recipes
27.6. Mail User Agents
27.6.1. Securing Communication
27.7. Additional Resources
27.7.1. Installed Documentation
27.7.2. Useful Websites
27.7.3. Related Books
28. Lightweight Directory Access Protocol (LDAP)
28.1. Why Use LDAP?
28.1.1. OpenLDAP Features
28.2. LDAP Terminology
28.3. OpenLDAP Daemons and Utilities
28.3.1. NSS, PAM, and LDAP
28.3.2. PHP4, LDAP, and the Apache HTTP Server
28.3.3. LDAP Client Applications
28.4. OpenLDAP Configuration Files
28.5. The /etc/openldap/schema/ Directory
28.6. OpenLDAP Setup Overview
28.6.1. Editing /etc/openldap/slapd.conf
28.7. Configuring a System to Authenticate Using OpenLDAP
28.7.1. PAM and LDAP
28.7.2. Migrating Old Authentication Information to LDAP Format
28.8. Migrating Directories from Earlier Releases
28.9. Additional Resources
28.9.1. Installed Documentation
28.9.2. Useful Websites
28.9.3. Related Books
29. Authentication Configuration
29.1. User Information
29.2. Authentication
29.3. Options
29.4. Command Line Version
30. Using and Caching Credentials with SSSD
30.1. About the sssd.conf File
30.2. Starting and Stopping SSSD
30.3. Configuring SSSD to Work with System Services
30.3.1. Configuring NSS Services
30.3.2. Configuring the PAM Service
30.4. Creating Domains
30.4.1. General Rules and Options for Configuring a Domain
30.4.2. Configuring an LDAP Domain
30.4.3. Configuring Kerberos Authentication with a Domain
30.4.4. Configuring a Proxy Domain
30.5. Configuring Access Control for SSSD Domains
30.5.1. Using the Simple Access Provider
30.5.2. Using the LDAP Access Filter
30.6. Configuring Domain Failover
30.6.1. Configuring Failover
30.6.2. Using SRV Records with Failover
30.7. Deleting Domain Cache Files
30.8. Using NSCD with SSSD
30.9. Troubleshooting SSSD
30.9.1. Checking SSSD Log Files
30.9.2. Problems with SSSD Configuration

Chapter 16. Network Interfaces

Under Red Hat Enterprise Linux, all network communications occur between configured software interfaces and physical networking devices connected to the system.
The configuration files for network interfaces are located in the /etc/sysconfig/network-scripts/ directory. The scripts used to activate and deactivate these network interfaces are also located here. Although the number and type of interface files can differ from system to system, there are three categories of files that exist in this directory:
  1. Interface configuration files
  2. Interface control scripts
  3. Network function files
The files in each of these categories work together to enable various network devices.
This chapter explores the relationship between these files and how they are used.

16.1. Network Configuration Files

Before delving into the interface configuration files, let us first itemize the primary configuration files used in network configuration. Understanding the role these files play in setting up the network stack can be helpful when customizing a Red Hat Enterprise Linux system.
The primary network configuration files are as follows:
/etc/hosts
The main purpose of this file is to resolve hostnames that cannot be resolved any other way. It can also be used to resolve hostnames on small networks with no DNS server. Regardless of the type of network the computer is on, this file should contain a line specifying the IP address of the loopback device (127.0.0.1) as localhost.localdomain. For more information, refer to the hosts man page.
/etc/resolv.conf
This file specifies the IP addresses of DNS servers and the search domain. Unless configured to do otherwise, the network initialization scripts populate this file. For more information about this file, refer to the resolv.conf man page.
/etc/sysconfig/network
This file specifies routing and host information for all network interfaces. For more information about this file and the directives it accepts, refer to Section 32.1.21, “/etc/sysconfig/network.
/etc/sysconfig/network-scripts/ifcfg-<interface-name>
For each network interface, there is a corresponding interface configuration script. Each of these files provide information specific to a particular network interface. Refer to Section 16.2, “Interface Configuration Files” for more information on this type of file and the directives it accepts.

Warning

The /etc/sysconfig/networking/ directory is used by the Network Administration Tool (system-config-network) and its contents should not be edited manually. Using only one method for network configuration is strongly encouraged, due to the risk of configuration deletion.
For more information about configuring network interfaces using the Network Administration Tool, refer to Chapter 17, Network Configuration

16.2. Interface Configuration Files

Interface configuration files control the software interfaces for individual network devices. As the system boots, it uses these files to determine what interfaces to bring up and how to configure them. These files are usually named ifcfg-<name> , where <name> refers to the name of the device that the configuration file controls.

16.2.1. Ethernet Interfaces

One of the most common interface files is ifcfg-eth0, which controls the first Ethernet network interface card or NIC in the system. In a system with multiple NICs, there are multiple ifcfg-eth<X> files (where <X> is a unique number corresponding to a specific interface). Because each device has its own configuration file, an administrator can control how each interface functions individually.
The following is a sample ifcfg-eth0 file for a system using a fixed IP address:
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
NETMASK=255.255.255.0
IPADDR=10.0.1.27
USERCTL=no
The values required in an interface configuration file can change based on other values. For example, the ifcfg-eth0 file for an interface using DHCP looks different because IP information is provided by the DHCP server:
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes
The Network Administration Tool (system-config-network) is an easy way to make changes to the various network interface configuration files (refer to Chapter 17, Network Configuration for detailed instructions on using this tool).
However, it is also possible to manually edit the configuration files for a given network interface.
Below is a listing of the configurable parameters in an Ethernet interface configuration file:
BONDING_OPTS=<parameters>
sets the configuration parameters for the bonding device, and is used in /etc/sysconfig/network-scripts/ifcfg-bond<N> (see Section 16.2.3, “Channel Bonding Interfaces”). These parameters are identical to those used for bonding devices in /sys/class/net/<bonding device>/bonding, and the module parameters for the bonding driver as described in bonding Module Directives.
This configuration method is used so that multiple bonding devices can have different configurations. If you use BONDING_OPTS in ifcfg-<name> , do not use /etc/modprobe.conf to specify options for the bonding device.
BOOTPROTO=<protocol>
where <protocol> is one of the following:
  • none — No boot-time protocol should be used.
  • bootp — The BOOTP protocol should be used.
  • dhcp — The DHCP protocol should be used.
BROADCAST=<address>
where <address> is the broadcast address. This directive is deprecated, as the value is calculated automatically with ipcalc.
DEVICE=<name>
where <name> is the name of the physical device (except for dynamically-allocated PPP devices where it is the logical name).
DHCP_HOSTNAME=<name>
where <name> is a short hostname to be sent to the DHCP server. Use this option only if the DHCP server requires the client to specify a hostname before receiving an IP address.
DNS{1,2}=<address>
where <address> is a name server address to be placed in /etc/resolv.conf if the PEERDNS directive is set to yes.
ETHTOOL_OPTS=<options>
where <options> are any device-specific options supported by ethtool. For example, if you wanted to force 100Mb, full duplex:
ETHTOOL_OPTS="autoneg off speed 100 duplex full"
Instead of a custom initscript, use ETHTOOL_OPTS to set the interface speed and duplex settings. Custom initscripts run outside of the network init script lead to unpredictable results during a post-boot network service restart.

Note

Changing speed or duplex settings almost always requires disabling autonegotiation with the autoneg off option. This needs to be stated first, as the option entries are order-dependent.
GATEWAY=<address>
where <address> is the IP address of the network router or gateway device (if any).
HOTPLUG=<answer>
where <answer> is one of the following:
  • yes — This device should be activated when it is hot-plugged (this is the default option).
  • no — This device should not be activated when it is hot-plugged.
The HOTPLUG=no option can be used to prevent a channel bonding interface from being activated when a bonding kernel module is loaded.
Refer to Section 16.2.3, “Channel Bonding Interfaces” for more about channel bonding interfaces.
HWADDR=<MAC-address>
where <MAC-address> is the hardware address of the Ethernet device in the form AA:BB:CC:DD:EE:FF. This directive must be used in machines containing more than one NIC to ensure that the interfaces are assigned the correct device names regardless of the configured load order for each NIC's module. This directive should not be used in conjunction with MACADDR.
IPADDR=<address>
where <address> is the IP address.
LINKDELAY=<time>
where <time> is the number of seconds to wait for link negotiation before configuring the device.
MACADDR=<MAC-address>
where <MAC-address> is the hardware address of the Ethernet device in the form AA:BB:CC:DD:EE:FF. This directive is used to assign a MAC address to an interface, overriding the one assigned to the physical NIC. This directive should not be used in conjunction with HWADDR.
MASTER=<bond-interface>
where <bond-interface> is the channel bonding interface to which the Ethernet interface is linked.
This directive is used in conjunction with the SLAVE directive.
Refer to Section 16.2.3, “Channel Bonding Interfaces” for more information about channel bonding interfaces.
NETMASK=<mask>
where <mask> is the netmask value.
NETWORK=<address>
where <address> is the network address. This directive is deprecated, as the value is calculated automatically with ipcalc.
ONBOOT=<answer>
where <answer> is one of the following:
  • yes — This device should be activated at boot-time.
  • no — This device should not be activated at boot-time.
PEERDNS=<answer>
where <answer> is one of the following:
  • yes — Modify /etc/resolv.conf if the DNS directive is set. If using DHCP, then yes is the default.
  • no — Do not modify /etc/resolv.conf.
SLAVE=<answer>
where <answer> is one of the following:
  • yes — This device is controlled by the channel bonding interface specified in the MASTER directive.
  • no — This device is not controlled by the channel bonding interface specified in the MASTER directive.
This directive is used in conjunction with the MASTER directive.
Refer to Section 16.2.3, “Channel Bonding Interfaces” for more about channel bonding interfaces.
SRCADDR=<address>
where <address> is the specified source IP address for outgoing packets.
USERCTL=<answer>
where <answer> is one of the following:
  • yes — Non-root users are allowed to control this device.
  • no — Non-root users are not allowed to control this device.

16.2.2. IPsec Interfaces

The following example shows the ifcfg file for a network-to-network IPsec connection for LAN A. The unique name to identify the connection in this example is ipsec1, so the resulting file is named /etc/sysconfig/network-scripts/ifcfg-ipsec1.
TYPE=IPsec
ONBOOT=yes
IKE_METHOD=PSK
SRCNET=192.168.1.0/24
DSTNET=192.168.2.0/24
DST=X.X.X.X
In the example above, X.X.X.X is the publicly routable IP address of the destination IPsec router.
Below is a listing of the configurable parameters for an IPsec interface:
DST=<address>
where <address> is the IP address of the IPsec destination host or router. This is used for both host-to-host and network-to-network IPsec configurations.
DSTNET=<network>
where <network> is the network address of the IPsec destination network. This is only used for network-to-network IPsec configurations.
SRC=<address>
where <address> is the IP address of the IPsec source host or router. This setting is optional and is only used for host-to-host IPsec configurations.
SRCNET=<network>
where <network> is the network address of the IPsec source network. This is only used for network-to-network IPsec configurations.
TYPE=<interface-type>
where <interface-type> is IPSEC. Both applications are part of the ipsec-tools package.
If manual key encryption with IPsec is being used, refer to /usr/share/doc/initscripts-<version-number>/sysconfig.txt (replace <version-number> with the version of the initscripts package installed) for configuration parameters.
The racoon IKEv1 key management daemon negotiates and configures a set of parameters for IPSec. It can use preshared keys, RSA signatures, or GSS-API. If racoon is used to automatically manage key encryption, the following options are required:
IKE_METHOD=<encryption-method>
where <encryption-method> is either PSK, X509, or GSSAPI. If PSK is specified, the IKE_PSK parameter must also be set. If X509 is specified, the IKE_CERTFILE parameter must also be set.
IKE_PSK=<shared-key>
where <shared-key> is the shared, secret value for the PSK (preshared keys) method.
IKE_CERTFILE=<cert-file>
where <cert-file> is a valid X.509 certificate file for the host.
IKE_PEER_CERTFILE=<cert-file>
where <cert-file> is a valid X.509 certificate file for the remote host.
IKE_DNSSEC=<answer>
where <answer> is yes. The racoon daemon retrieves the remote host's X.509 certificate via DNS. If a IKE_PEER_CERTFILE is specified, do not include this parameter.
For more information about the encryption algorithms available for IPsec, refer to the setkey man page. For more information about racoon, refer to the racoon and racoon.conf man pages.

16.2.3. Channel Bonding Interfaces

Red Hat Enterprise Linux allows administrators to bind multiple network interfaces together into a single channel using the bonding kernel module and a special network interface called a channel bonding interface. Channel bonding enables two or more network interfaces to act as one, simultaneously increasing the bandwidth and providing redundancy.
To create a channel bonding interface, create a file in the /etc/sysconfig/network-scripts/ directory called ifcfg-bond<N> , replacing <N> with the number for the interface, such as 0.
The contents of the file can be identical to whatever type of interface is getting bonded, such as an Ethernet interface. The only difference is that the DEVICE= directive must be bond<N> , replacing <N> with the number for the interface.
The following is a sample channel bonding configuration file, ifcfg-bond0:
DEVICE=bond0
IPADDR=192.168.1.1
NETMASK=255.255.255.0
ONBOOT=yes
BOOTPROTO=none
USERCTL=no
BONDING_OPTS="<bonding parameters separated by spaces>"
After the channel bonding interface is created, the network interfaces to be bound together must be configured by adding the MASTER= and SLAVE= directives to their configuration files. The configuration files for each of the channel-bonded interfaces can be nearly identical.
For example, if two Ethernet interfaces are being channel bonded, both eth0 and eth1 may look like the following example:
DEVICE=eth<N>
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no
In this example, replace <N> with the numerical value for the interface.
For a channel bonding interface to be valid, the kernel module must be loaded. To ensure that the module is loaded when the channel bonding interface is brought up, add the following line to /etc/modprobe.conf:
alias bond<N> bonding
Replace <N> with the number of the interface, such as 0.

Important

Do not place parameters for the bonding kernel module in the /etc/modprobe.conf file. Instead, specify them as a space-separated list in the BONDING_OPTS="<bonding parameters>" directive in the ifcfg-bond<N> interface file.
The only exception is the debug parameter, which cannot be used on a per-device basis, and which should therefore be specified in /etc/modprobe.conf as follows:
options bonding debug=1
For further instructions and advice on configuring the bonding module, as well as to view the list of bonding parameters, refer to Section 45.5.2, “The Channel Bonding Module”.

16.2.4. Alias and Clone Files

Two lesser-used types of interface configuration files are alias and clone files.
Alias interface configuration files, which are used to bind multiple addresses to a single interface, use the ifcfg-<if-name>:<alias-value> naming scheme.
For example, an ifcfg-eth0:0 file could be configured to specify DEVICE=eth0:0 and a static IP address of 10.0.0.2, serving as an alias of an Ethernet interface already configured to receive its IP information via DHCP in ifcfg-eth0. Under this configuration, eth0 is bound to a dynamic IP address, but the same physical network card can receive requests via the fixed, 10.0.0.2 IP address.

Warning

Alias interfaces do not support DHCP.
A clone interface configuration file should use the following naming convention: ifcfg-<if-name>-<clone-name> . While an alias file allows multiple addresses for an existing interface, a clone file is used to specify additional options for an interface. For example, a standard DHCP Ethernet interface called eth0, may look similar to this:
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=dhcp
Since the default value for the USERCTL directive is no if it is not specified, users cannot bring this interface up and down. To give users the ability to control the interface, create a clone by copying ifcfg-eth0 to ifcfg-eth0-user and add the following line to ifcfg-eth0-user:
USERCTL=yes
This way a user can bring up the eth0 interface using the /sbin/ifup eth0-user command because the configuration options from ifcfg-eth0 and ifcfg-eth0-user are combined. While this is a very basic example, this method can be used with a variety of options and interfaces.
The easiest way to create alias and clone interface configuration files is to use the graphical Network Administration Tool. For more information on using this tool, refer to Chapter 17, Network Configuration.

16.2.5. Dialup Interfaces

If you are connecting to the Internet via a dialup connection, a configuration file is necessary for the interface.
PPP interface files are named using the following format:
ifcfg-ppp<X>
where <X> is a unique number corresponding to a specific interface.
The PPP interface configuration file is created automatically when wvdial, the Network Administration Tool or Kppp is used to create a dialup account. It is also possible to create and edit this file manually.
The following is a typical ifcfg-ppp0 file:
DEVICE=ppp0
NAME=test
WVDIALSECT=test
MODEMPORT=/dev/modem
LINESPEED=115200
PAPNAME=test
USERCTL=true
ONBOOT=no
PERSIST=no
DEFROUTE=yes
PEERDNS=yes
DEMAND=no
IDLETIMEOUT=600
Serial Line Internet Protocol (SLIP) is another dialup interface, although it is used less frequently. SLIP files have interface configuration file names such as ifcfg-sl0.
Other options that may be used in these files include:
DEFROUTE=<answer>
where <answer> is one of the following:
  • yes — Set this interface as the default route.
  • no — Do not set this interface as the default route.
DEMAND=<answer>
where <answer> is one of the following:
  • yes — This interface allows pppd to initiate a connection when someone attempts to use it.
  • no — A connection must be manually established for this interface.
IDLETIMEOUT=<value>
where <value> is the number of seconds of idle activity before the interface disconnects itself.
INITSTRING=<string>
where <string> is the initialization string passed to the modem device. This option is primarily used in conjunction with SLIP interfaces.
LINESPEED=<value>
where <value> is the baud rate of the device. Possible standard values include 57600, 38400, 19200, and 9600.
MODEMPORT=<device>
where <device> is the name of the serial device that is used to establish the connection for the interface.
MTU=<value>
where <value> is the Maximum Transfer Unit (MTU) setting for the interface. The MTU refers to the largest number of bytes of data a frame can carry, not counting its header information. In some dialup situations, setting this to a value of 576 results in fewer packets dropped and a slight improvement to the throughput for a connection.
NAME=<name>
where <name> is the reference to the title given to a collection of dialup connection configurations.
PAPNAME=<name>
where <name> is the username given during the Password Authentication Protocol (PAP) exchange that occurs to allow connections to a remote system.
PERSIST=<answer>
where <answer> is one of the following:
  • yes — This interface should be kept active at all times, even if deactivated after a modem hang up.
  • no — This interface should not be kept active at all times.
REMIP=<address>
where <address> is the IP address of the remote system. This is usually left unspecified.
WVDIALSECT=<name>
where <name> associates this interface with a dialer configuration in /etc/wvdial.conf. This file contains the phone number to be dialed and other important information for the interface.

16.2.6. Other Interfaces

Other common interface configuration files include the following:
ifcfg-lo
A local loopback interface is often used in testing, as well as being used in a variety of applications that require an IP address pointing back to the same system. Any data sent to the loopback device is immediately returned to the host's network layer.

Warning

The loopback interface script, /etc/sysconfig/network-scripts/ifcfg-lo, should never be edited manually. Doing so can prevent the system from operating correctly.
ifcfg-irlan0
An infrared interface allows information between devices, such as a laptop and a printer, to flow over an infrared link. This works in a similar way to an Ethernet device except that it commonly occurs over a peer-to-peer connection.
ifcfg-plip0
A Parallel Line Interface Protocol (PLIP) connection works much the same way as an Ethernet device, except that it utilizes a parallel port.
ifcfg-tr0
Token Ring topologies are not as common on Local Area Networks (LANs) as they once were, having been eclipsed by Ethernet.

16.3. Interface Control Scripts

The interface control scripts activate and deactivate system interfaces. There are two primary interface control scripts that call on control scripts located in the /etc/sysconfig/network-scripts/ directory: /sbin/ifdown and /sbin/ifup.
The ifup and ifdown interface scripts are symbolic links to scripts in the /sbin/ directory. When either of these scripts are called, they require the value of the interface to be specified, such as:
ifup eth0

Warning

The ifup and ifdown interface scripts are the only scripts that the user should use to bring up and take down network interfaces.
The following scripts are described for reference purposes only.
Two files used to perform a variety of network initialization tasks during the process of bringing up a network interface are /etc/rc.d/init.d/functions and /etc/sysconfig/network-scripts/network-functions. Refer to Section 16.5, “Network Function Files” for more information.
After verifying that an interface has been specified and that the user executing the request is allowed to control the interface, the correct script brings the interface up or down. The following are common interface control scripts found within the /etc/sysconfig/network-scripts/ directory:
ifup-aliases
Configures IP aliases from interface configuration files when more than one IP address is associated with an interface.
ifup-ippp and ifdown-ippp
Brings ISDN interfaces up and down.
ifup-ipsec and ifdown-ipsec
Brings IPsec interfaces up and down.
ifup-ipv6 and ifdown-ipv6
Brings IPv6 interfaces up and down.
ifup-ipx
Brings up an IPX interface.
ifup-plip
Brings up a PLIP interface.
ifup-plusb
Brings up a USB interface for network connections.
ifup-post and ifdown-post
Contains commands to be executed after an interface is brought up or down.
ifup-ppp and ifdown-ppp
Brings a PPP interface up or down.
ifup-routes
Adds static routes for a device as its interface is brought up.
ifdown-sit and ifup-sit
Contains function calls related to bringing up and down an IPv6 tunnel within an IPv4 connection.
ifup-sl and ifdown-sl
Brings a SLIP interface up or down.
ifup-wireless
Brings up a wireless interface.

Warning

Removing or modifying any scripts in the /etc/sysconfig/network-scripts/ directory can cause interface connections to act irregularly or fail. Only advanced users should modify scripts related to a network interface.
The easiest way to manipulate all network scripts simultaneously is to use the /sbin/service command on the network service (/etc/rc.d/init.d/network), as illustrated the following command:
service network <action>
Here, <action> can be either start, stop, or restart.
To view a list of configured devices and currently active network interfaces, use the following command:
service network status

16.4. Static Routes and the Default Gateway

Static routes are for traffic that must not, or should not, go through the default gateway. Routing is usually handled by routing devices and therefore it is often not necessary to configure static routes on Red Hat Enterprise Linux servers or clients. Exceptions include traffic that must pass through an encrypted VPN tunnel or traffic that should take a less costly route. The default gateway is for any and all traffic which is not destined for the local network and for which no preferred route is specified in the routing table. The default gateway is traditionally a dedicated network router.

Static Routes

Use the ip route command to display the IP routing table. If static routes are required, they can be added to the routing table by means of the ip route add command and removed using the ip route del command. To add a static route to a host address, that is to say to a single IP address, issue the following command as root:
ip route add X.X.X.X
where X.X.X.X is the IP address of the host in dotted decimal notation. To add a static route to a network, that is to say to an IP address representing a range of IP addresses, issue the following command as root:
ip route add X.X.X.X/Y
where X.X.X.X is the IP address of the network in dotted decimal notation and Y is the network prefix. The network prefix is the number of enabled bits in the subnet mask. This format of network address slash prefix length is referred to as CIDR notation.
Static route configuration is stored per-interface in a /etc/sysconfig/network-scripts/route-interface file. For example, static routes for the eth0 interface would be stored in the /etc/sysconfig/network-scripts/route-eth0 file. The route-interface file has two formats: IP command arguments and network/netmask directives. These are described below.

The Default Gateway

The default gateway is specified by means of the GATEWAY directive and can be specified either globally or in interface-specific configuration files. Specifying the default gateway globally has certain advantages especially if more than one network interface is present and it can make fault finding simpler if applied consistently. There is also the GATEWAYDEV directive, which is a global option. If multiple devices specify GATEWAY, and one interface uses the GATEWAYDEV directive, that directive will take precedence. This option is not recommend as it can have unexpected consequences if an interface goes down and it can complicate fault finding.
Global default gateway configuration is stored in the /etc/sysconfig/network file. This file specifies gateway and host information for all network interfaces. For more information about this file and the directives it accepts, refer to Section 32.1.21, “/etc/sysconfig/network.
IP Command Arguments Format
If required in a per-interface configuration file, define a default gateway on the first line. This is only required if the default gateway is not set via DHCP and is not set globally as mentioned above:
default via X.X.X.X dev interface
X.X.X.X is the IP address of the default gateway. The interface is the interface that is connected to, or can reach, the default gateway.
Define a static route. Each line is parsed as an individual route:
X.X.X.X/X via X.X.X.X dev interface
X.X.X.X/X is the network number and netmask for the static route. X.X.X.X and interface are the IP address and interface for the default gateway respectively. The X.X.X.X address does not have to be the default gateway IP address. In most cases, X.X.X.X will be an IP address in a different subnet, and interface will be the interface that is connected to, or can reach, that subnet. Add as many static routes as required.
The following is a sample route-eth0 file using the IP command arguments format. The default gateway is 192.168.0.1, interface eth0. The two static routes are for the 10.10.10.0/24 and 172.16.1.0/24 networks:
default via 192.168.0.1 dev eth0
10.10.10.0/24 via 192.168.0.1 dev eth0
172.16.1.0/24 via 192.168.0.1 dev eth0
Static routes should only be configured for other subnets. The above example is not necessary, since packets going to the 10.10.10.0/24 and 172.16.1.0/24 networks will use the default gateway anyway. Below is an example of setting static routes to a different subnet, on a machine in a 192.168.0.0/24 subnet. The example machine has an eth0 interface in the 192.168.0.0/24 subnet, and an eth1 interface (10.10.10.1) in the 10.10.10.0/24 subnet:
10.10.10.0/24 via 10.10.10.1 dev eth1

Duplicate Default Gateways

If the default gateway is already assigned from DHCP, the IP command arguments format can cause one of two errors during start-up, or when bringing up an interface from the down state using the ifup command: "RTNETLINK answers: File exists" or 'Error: either "to" is a duplicate, or "X.X.X.X" is a garbage.', where X.X.X.X is the gateway, or a different IP address. These errors can also occur if you have another route to another network using the default gateway. Both of these errors are safe to ignore.
Network/Netmask Directives Format
You can also use the network/netmask directives format for route-interface files. The following is a template for the network/netmask format, with instructions following afterwards:
ADDRESS0=X.X.X.X
NETMASK0=X.X.X.X
GATEWAY0=X.X.X.X
  • ADDRESS0=X.X.X.X is the network number for the static route.
  • NETMASK0=X.X.X.X is the netmask for the network number defined with ADDRESS0=X.X.X.X .
  • GATEWAY0=X.X.X.X is the default gateway, or an IP address that can be used to reach ADDRESS0=X.X.X.X
The following is a sample route-eth0 file using the network/netmask directives format. The default gateway is 192.168.0.1, interface eth0. The two static routes are for the 10.10.10.0/24 and 172.16.1.0/24 networks. However, as mentioned before, this example is not necessary as the 10.10.10.0/24 and 172.16.1.0/24 networks would use the default gateway anyway:
ADDRESS0=10.10.10.0
NETMASK0=255.255.255.0
GATEWAY0=192.168.0.1
ADDRESS1=172.16.1.0
NETMASK1=255.255.255.0
GATEWAY1=192.168.0.1
Subsequent static routes must be numbered sequentially, and must not skip any values. For example, ADDRESS0, ADDRESS1, ADDRESS2, and so on.
Below is an example of setting static routes to a different subnet, on a machine in the 192.168.0.0/24 subnet. The example machine has an eth0 interface in the 192.168.0.0/24 subnet, and an eth1 interface (10.10.10.1) in the 10.10.10.0/24 subnet:
ADDRESS0=10.10.10.0
NETMASK0=255.255.255.0
GATEWAY0=10.10.10.1
DHCP should assign these settings automatically, therefore it should not be necessary to configure static routes on Red Hat Enterprise Linux servers or clients.

16.5. Network Function Files

Red Hat Enterprise Linux makes use of several files that contain important common functions used to bring interfaces up and down. Rather than forcing each interface control file to contain these functions, they are grouped together in a few files that are called upon when necessary.
The /etc/sysconfig/network-scripts/network-functions file contains the most commonly used IPv4 functions, which are useful to many interface control scripts. These functions include contacting running programs that have requested information about changes in the status of an interface, setting hostnames, finding a gateway device, verifying whether or not a particular device is down, and adding a default route.
As the functions required for IPv6 interfaces are different from IPv4 interfaces, a /etc/sysconfig/network-scripts/network-functions-ipv6 file exists specifically to hold this information. The functions in this file configure and delete static IPv6 routes, create and remove tunnels, add and remove IPv6 addresses to an interface, and test for the existence of an IPv6 address on an interface.

16.6. Additional Resources

The following are resources which explain more about network interfaces.

16.6.1. Installed Documentation

/usr/share/doc/initscripts-<version>/sysconfig.txt
A guide to available options for network configuration files, including IPv6 options not covered in this chapter.
/usr/share/doc/iproute-<version>/ip-cref.ps
This file contains a wealth of information about the ip command, which can be used to manipulate routing tables, among other things. Use the ggv or kghostview application to view this file.

Chapter 17. Network Configuration

To communicate with each other, computers must have a network connection. This is accomplished by having the operating system recognize an interface card (such as Ethernet, ISDN modem, or token ring) and configuring the interface to connect to the network.
The Network Administration Tool can be used to configure the following types of network interfaces:
  • Ethernet
  • ISDN
  • modem
  • xDSL
  • token ring
  • CIPE
  • wireless devices
It can also be used to configure IPsec connections, manage DNS settings, and manage the /etc/hosts file used to store additional hostnames and IP address combinations.
To use the Network Administration Tool, you must have root privileges. To start the application, go to the Applications (the main menu on the panel) > System Settings > Network, or type the command system-config-network at a shell prompt (for example, in an XTerm or a GNOME terminal). If you type the command, the graphical version is displayed if X is running; otherwise, the text-based version is displayed.
To use the command line version, execute the command system-config-network-cmd --help as root to view all of the options.
Network Administration Tool

Figure 17.1.  Network Administration Tool


Tip

Use the Red Hat Hardware Compatibility List (http://hardware.redhat.com/hcl/) to determine if Red Hat Enterprise Linux supports your hardware device.

17.1. Overview

To configure a network connection with the Network Administration Tool, perform the following steps:
  1. Add a network device associated with the physical hardware device.
  2. Add the physical hardware device to the hardware list, if it does not already exist.
  3. Configure the hostname and DNS settings.
  4. Configure any hosts that cannot be looked up through DNS.
This chapter discusses each of these steps for each type of network connection.

17.2. Establishing an Ethernet Connection

To establish an Ethernet connection, you need a network interface card (NIC), a network cable (usually a CAT5 cable), and a network to connect to. Different networks are configured to use different network speeds; make sure your NIC is compatible with the network to which you want to connect.
To add an Ethernet connection, follow these steps:
  1. Click the Devices tab.
  2. Click the New button on the toolbar.
  3. Select Ethernet connection from the Device Type list, and click Forward.
  4. If you have already added the network interface card to the hardware list, select it from the Ethernet card list. Otherwise, select Other Ethernet Card to add the hardware device.

    Note

    The installation program detects supported Ethernet devices and prompts you to configure them. If you configured any Ethernet devices during the installation, they are displayed in the hardware list on the Hardware tab.
  5. If you selected Other Ethernet Card, the Select Ethernet Adapter window appears. Select the manufacturer and model of the Ethernet card. Select the device name. If this is the system's first Ethernet card, select eth0 as the device name; if this is the second Ethernet card, select eth1 (and so on). The Network Administration Tool also allows you to configure the resources for the NIC. Click Forward to continue.
  6. In the Configure Network Settings window shown in Figure 17.2, “Ethernet Settings”, choose between DHCP and a static IP address. If the device receives a different IP address each time the network is started, do not specify a hostname.
  7. Do not specify a value for the Set MTU to or Set MRU to fields. MTU stands for Maximum Transmission Unit and MRU for Maximum Receive Unit; the network configuration tool will choose appropriate values for both of these parameters. Click Forward to continue.
  8. Click Apply on the Create Ethernet Device page.
Ethernet Settings

Figure 17.2. Ethernet Settings


After configuring the Ethernet device, it appears in the device list as shown in Figure 17.3, “Ethernet Device”.
Ethernet Device

Figure 17.3. Ethernet Device


Be sure to select File > Save to save the changes.
After adding the Ethernet device, you can edit its configuration by selecting the device from the device list and clicking Edit. For example, when the device is added, it is configured to start at boot time by default. To change this setting, select to edit the device, modify the Activate device when computer starts value, and save the changes.
When the device is added, it is not activated immediately, as seen by its Inactive status. To activate the device, select it from the device list, and click the Activate button. If the system is configured to activate the device when the computer starts (the default), this step does not have to be performed again.
If you associate more than one device with an Ethernet card, the subsequent devices are device aliases. A device alias allows you to setup multiple virtual devices for one physical device, thus giving the one physical device more than one IP address. For example, you can configure an eth1 device and an eth1:1 device. For details, refer to Section 17.11, “Device Aliases”.

17.3. Establishing an ISDN Connection

An ISDN connection is an Internet connection established with a ISDN modem card through a special phone line installed by the phone company. ISDN connections are popular in Europe.
To add an ISDN connection, follow these steps:
  1. Click the Devices tab.
  2. Click the New button on the toolbar.
  3. Select ISDN connection from the Device Type list, and click Forward.
  4. Select the ISDN adapter from the pulldown menu. Then configure the resources and D channel protocol for the adapter. Click Forward to continue.
    ISDN Settings

    Figure 17.4. ISDN Settings


  5. If your Internet Service Provider (ISP) is in the pre-configured list, select it. Otherwise, enter the required information about your ISP account. If you do not know the values, contact your ISP. Click Forward.
  6. In the IP Settings window, select the Encapsulation Mode and whether to obtain an IP address automatically or to set a static IP instead. Click Forward when finished.
  7. On the Create Dialup Connection page, click Apply.
After configuring the ISDN device, it appears in the device list as a device with type ISDN as shown in Figure 17.5, “ISDN Device”.
Be sure to select File > Save to save the changes.
After adding the ISDN device, you can edit its configuration by selecting the device from the device list and clicking Edit. For example, when the device is added, it is configured not to start at boot time by default. Edit its configuration to modify this setting. Compression, PPP options, login name, password, and more can be changed.
When the device is added, it is not activated immediately, as seen by its Inactive status. To activate the device, select it from the device list, and click the Activate button. If the system is configured to activate the device when the computer starts (the default), this step does not have to be performed again.
ISDN Device

Figure 17.5. ISDN Device


17.4. Establishing a Modem Connection

A modem can be used to configure an Internet connection over an active phone line. An Internet Service Provider (ISP) account (also called a dial-up account) is required.
To add a modem connection, follow these steps:
  1. Click the Devices tab.
  2. Click the New button on the toolbar.
  3. Select Modem connection from the Device Type list, and click Forward.
  4. If there is a modem already configured in the hardware list (on the Hardware tab), the Network Administration Tool assumes you want to use it to establish a modem connection. If there are no modems already configured, it tries to detect any modems in the system. This probe might take a while. If a modem is not found, a message is displayed to warn you that the settings shown are not values found from the probe.
  5. After probing, the window in Figure 17.6, “Modem Settings” appears.
    Modem Settings

    Figure 17.6. Modem Settings


  6. Configure the modem device, baud rate, flow control, and modem volume. If you do not know these values, accept the defaults if the modem was probed successfully. If you do not have touch tone dialing, uncheck the corresponding checkbox. Click Forward.
  7. If your ISP is in the pre-configured list, select it. Otherwise, enter the required information about your ISP account. If you do not know these values, contact your ISP. Click Forward.
  8. On the IP Settings page, select whether to obtain an IP address automatically or whether to set one statically. Click Forward when finished.
  9. On the Create Dialup Connection page, click Apply.
After configuring the modem device, it appears in the device list with the type Modem as shown in Figure 17.7, “Modem Device”.
Modem Device

Figure 17.7. Modem Device


Be sure to select File > Save to save the changes.
After adding the modem device, you can edit its configuration by selecting the device from the device list and clicking Edit. For example, when the device is added, it is configured not to start at boot time by default. Edit its configuration to modify this setting. Compression, PPP options, login name, password, and more can also be changed.
When the device is added, it is not activated immediately, as seen by its Inactive status. To activate the device, select it from the device list, and click the Activate button. If the system is configured to activate the device when the computer starts (the default), this step does not have to be performed again.

17.5. Establishing an xDSL Connection

DSL stands for Digital Subscriber Lines. There are different types of DSL such as ADSL, IDSL, and SDSL. The Network Administration Tool uses the term xDSL to mean all types of DSL connections.
Some DSL providers require that the system is configured to obtain an IP address through DHCP with an Ethernet card. Some DSL providers require you to configure a PPPoE (Point-to-Point Protocol over Ethernet) connection with an Ethernet card. Ask your DSL provider which method to use.
If you are required to use DHCP, refer to Section 17.2, “Establishing an Ethernet Connection” to configure your Ethernet card.
If you are required to use PPPoE, follow these steps:
  1. Click the Devices tab.
  2. Click the New button.
  3. Select xDSL connection from the Device Type list, and click Forward as shown in Figure 17.8, “Select Device Type”.
    Select Device Type

    Figure 17.8. Select Device Type


  4. If your Ethernet card is in the hardware list, select the Ethernet Device from the pulldown menu from the page shown in Figure 17.9, “xDSL Settings”. Otherwise, the Select Ethernet Adapter window appears.

    Note

    The installation program detects supported Ethernet devices and prompts you to configure them. If you configured any Ethernet devices during the installation, they are displayed in the hardware list on the Hardware tab.
    xDSL Settings

    Figure 17.9. xDSL Settings


  5. Enter the Provider Name, Login Name, and Password. If you are not setting up a T-Online account, select Normal from the Account Type pulldown menu.
    If you are setting up a T-Online account, select T-Online from the Account Type pulldown menu and enter any values in the Login name and Password field. You can further configure your T-Online account settings once the DSL connection has been fully configured (refer to Setting Up a T-Online Account).
  6. Click the Forward to go to the Create DSL Connection menu. Check your settings and click Apply to finish.
  7. After configuring the DSL connection, it appears in the device list as shown in Figure 17.10, “xDSL Device”.
    xDSL Device

    Figure 17.10. xDSL Device


  8. After adding the xDSL connection, you can edit its configuration by selecting the device from the device list and clicking Edit.
    xDSL Configuration

    Figure 17.11. xDSL Configuration


    For example, when the device is added, it is configured not to start at boot time by default. Edit its configuration to modify this setting. Click OK when finished.
  9. Once you are satisfied with your xDSL connection settings, select File > Save to save the changes.
Setting Up a T-Online Account
If you are setting up a T-Online Account, follow these additional steps:
  1. Select the device from the device list and click Edit.
  2. Select the Provider tab from the xDSL Configuration menu as shown in Figure 17.12, “xDSL Configuration - Provider Tab”.
    xDSL Configuration - Provider Tab

    Figure 17.12. xDSL Configuration - Provider Tab


  3. Click the T-Online Account Setup button. This will open the Account Setup window for your T-Online account as shown in Figure 17.13, “Account Setup”.
    Account Setup

    Figure 17.13. Account Setup


  4. Enter your Adapter identifier, Associated T-Online number, Concurrent user number/suffix, and Personal password.. Click OK when finished to close the Account Setup window.
  5. On the xDSL Configuration window, click OK. Be sure to select File > Save from the Network Administration Tool to save the changes.
When the device is added, it is not activated immediately, as seen by its Inactive status. To activate the device, select it from the device list, and click the Activate button. If the system is configured to activate the device when the computer starts (the default), this step does not have to be performed again.

17.6. Establishing a Token Ring Connection

A token ring network is a network in which all the computers are connected in a circular pattern. A token, or a special network packet, travels around the token ring and allows computers to send information to each other.

Tip

For more information on using token rings under Linux, refer to the Linux Token Ring Project website available at http://www.linuxtr.net/.
To add a token ring connection, follow these steps:
  1. Click the Devices tab.
  2. Click the New button on the toolbar.
  3. Select Token Ring connection from the Device Type list and click Forward.
  4. If you have already added the token ring card to the hardware list, select it from the Tokenring card list. Otherwise, select Other Tokenring Card to add the hardware device.
  5. If you selected Other Tokenring Card, the Select Token Ring Adapter window as shown in Figure 17.14, “Token Ring Settings” appears. Select the manufacturer and model of the adapter. Select the device name. If this is the system's first token ring card, select tr0; if this is the second token ring card, select tr1 (and so on). The Network Administration Tool also allows the user to configure the resources for the adapter. Click Forward to continue.
    Token Ring Settings

    Figure 17.14. Token Ring Settings


  6. On the Configure Network Settings page, choose between DHCP and static IP address. You may specify a hostname for the device. If the device receives a dynamic IP address each time the network is started, do not specify a hostname. Click Forward to continue.
  7. Click Apply on the Create Tokenring Device page.
After configuring the token ring device, it appears in the device list as shown in Figure 17.15, “Token Ring Device”.
Token Ring Device

Figure 17.15. Token Ring Device


Be sure to select File > Save to save the changes.
After adding the device, you can edit its configuration by selecting the device from the device list and clicking Edit. For example, you can configure whether the device is started at boot time.
When the device is added, it is not activated immediately, as seen by its Inactive status. To activate the device, select it from the device list, and click the Activate button. If the system is configured to activate the device when the computer starts (the default), this step does not have to be performed again.

17.7. Establishing a Wireless Connection

Wireless Ethernet devices are becoming increasingly popular. The configuration is similar to the Ethernet configuration except that it allows you to configure settings such as the SSID and key for the wireless device.
To add a wireless Ethernet connection, follow these steps:
  1. Click the Devices tab.
  2. Click the New button on the toolbar.
  3. Select Wireless connection from the Device Type list and click Forward.
  4. If you have already added the wireless network interface card to the hardware list, select it from the Wireless card list. Otherwise, select Other Wireless Card to add the hardware device.

    Note

    The installation program usually detects supported wireless Ethernet devices and prompts you to configure them. If you configured them during the installation, they are displayed in the hardware list on the Hardware tab.
  5. If you selected Other Wireless Card, the Select Ethernet Adapter window appears. Select the manufacturer and model of the Ethernet card and the device. If this is the first Ethernet card for the system, select eth0; if this is the second Ethernet card for the system, select eth1 (and so on). The Network Administration Tool also allows the user to configure the resources for the wireless network interface card. Click Forward to continue.
  6. On the Configure Wireless Connection page as shown in Figure 17.16, “Wireless Settings”, configure the settings for the wireless device.

    Note: Open System and Shared Key Authentication

    For the Authentication dropdown, note that wireless access points using WEP encryption have a choice between using open system and shared key authentication. Shared key authentication requires an exchange between the client and the access point during the association process that proves that the client has the correct WEP key. Open system authentication allows all wireless clients to connect. Counterintuitively, shared key authentication is less secure than open system, and thus is less widely deployed. It is therefore recommended to select Open System (open) as the authentication method when you do not know which method the access point requires. If connecting to the access point using open system fails, then try switching to shared key authentication.
    Wireless Settings

    Figure 17.16. Wireless Settings


  7. On the Configure Network Settings page, choose between DHCP and static IP address. You may specify a hostname for the device. If the device receives a dynamic IP address each time the network is started, do not specify a hostname. Click Forward to continue.
  8. Click Apply on the Create Wireless Device page.
After configuring the wireless device, it appears in the device list as shown in Figure 17.17, “Wireless Device”.
Wireless Device

Figure 17.17. Wireless Device


Be sure to select File > Save to save the changes.
After adding the wireless device, you can edit its configuration by selecting the device from the device list and clicking Edit. For example, you can configure the device to activate at boot time.
When the device is added, it is not activated immediately, as seen by its Inactive status. To activate the device, select it from the device list, and click the Activate button. If the system is configured to activate the device when the computer starts (the default), this step does not have to be performed again.

17.8. Managing DNS Settings

The DNS tab allows you to configure the system's hostname, domain, name servers, and search domain. Name servers are used to look up other hosts on the network.
If the DNS server names are retrieved from DHCP or PPPoE (or retrieved from the ISP), do not add primary, secondary, or tertiary DNS servers.
If the hostname is retrieved dynamically from DHCP or PPPoE (or retrieved from the ISP), do not change it.
DNS Configuration

Figure 17.18. DNS Configuration


Note

The name servers section does not configure the system to be a name server. Instead, it configures which name servers to use when resolving IP addresses to hostnames and vice-versa.

Warning

If the hostname is changed and system-config-network is started on the local host, you may not be able to start another X11 application. As such, you may have to re-login to a new desktop session.

17.9. Managing Hosts

The Hosts tab allows you to add, edit, or remove hosts from the /etc/hosts file. This file contains IP addresses and their corresponding hostnames.
When your system tries to resolve a hostname to an IP address or tries to determine the hostname for an IP address, it refers to the /etc/hosts file before using the name servers (if you are using the default Red Hat Enterprise Linux configuration). If the IP address is listed in the /etc/hosts file, the name servers are not used. If your network contains computers whose IP addresses are not listed in DNS, it is recommended that you add them to the /etc/hosts file.
To add an entry to the /etc/hosts file, go to the Hosts tab, click the New button on the toolbar, provide the requested information, and click OK. Select File > Save or press Ctrl+S to save the changes to the /etc/hosts file. The network or network services do not need to be restarted since the current version of the file is referred to each time an address is resolved.

Warning

Do not remove the localhost entry. Even if the system does not have a network connection or have a network connection running constantly, some programs need to connect to the system via the localhost loopback interface.
Hosts Configuration

Figure 17.19. Hosts Configuration


Tip

To change lookup order, edit the /etc/host.conf file. The line order hosts, bind specifies that /etc/hosts takes precedence over the name servers. Changing the line to order bind, hosts configures the system to resolve hostnames and IP addresses using the name servers first. If the IP address cannot be resolved through the name servers, the system then looks for the IP address in the /etc/hosts file.

17.10. Working with Profiles

Multiple logical network devices can be created for each physical hardware device. For example, if you have one Ethernet card in your system (eth0), you can create logical network devices with different nicknames and different configuration options, all to be specifically associated with eth0.
Logical network devices are different from device aliases. Logical network devices associated with the same physical device must exist in different profiles and cannot be activated simultaneously. Device aliases are also associated with the same physical hardware device, but device aliases associated with the same physical hardware can be activated at the same time. Refer to Section 17.11, “Device Aliases” for details about creating device aliases.
Profiles can be used to create multiple configuration sets for different networks. A configuration set can include logical devices as well as hosts and DNS settings. After configuring the profiles, you can use the Network Administration Tool to switch back and forth between them.
By default, there is one profile called Common. To create a new profile, select Profile > New from the pull-down menu, and enter a unique name for the profile.
You are now modifying the new profile as indicated by the status bar at the bottom of the main window.
Click on an existing device already in the list and click the Copy button to copy the existing device to a logical network device. If you use the New button, a network alias is created, which is incorrect. To change the properties of the logical device, select it from the list and click Edit. For example, the Nickname can be changed to a more descriptive name, such as eth0_office, so that it can be recognized more easily. Once you have finished editing your new profile, make sure to save it by clicking Save from the File menu. If you forget to save after creating a profile, that profile will be lost.
In the list of devices, there is a column of checkboxes labeled Profile. For each profile, you can check or uncheck devices. Only the checked devices are included for the currently selected profile. For example, if you create a logical device named eth0_office in a profile called Office and want to activate the logical device if the profile is selected, uncheck the eth0 device and check the eth0_office device.
For example, Figure 17.20, “Office Profile” shows a profile called Office with the logical device eth0_office. It is configured to activate the first Ethernet card using DHCP.
Office Profile

Figure 17.20. Office Profile


Notice that the Home profile as shown in Figure 17.21, “Home Profile” activates the eth0_home logical device, which is associated with eth0.
Home Profile

Figure 17.21. Home Profile


You can also configure eth0 to activate in the Office profile only and to activate a PPP (modem) device in the Home profile only. Another example is to have the Common profile activate eth0 and an Away profile activate a PPP device for use while traveling.
To activate a profile at boot time, modify the boot loader configuration file to include the netprofile=<profilename> option. For example, if the system uses GRUB as the boot loader and /boot/grub/grub.conf contains:
title Red Hat Enterprise Linux (2.6.9-5.EL)
         root (hd0,0)
	 kernel /vmlinuz-2.6.9-5.EL ro root=/dev/VolGroup00/LogVol00 rhgb quiet
	 initrd /initrd-2.6.9-5.EL.img
Modify it to the following (where <profilename> is the name of the profile to be activated at boot time):
title Red Hat Enterprise Linux (2.6.9-5.EL)
         root (hd0,0)
	 kernel /vmlinuz-2.6.9-5.EL ro root=/dev/VolGroup00/LogVol00 \ 
	 	netprofile=<profilename>  \ 	  rhgb quiet
	 initrd /initrd-2.6.9-5.EL.img
To switch profiles after the system has booted, go to Applications (the main menu on the panel) > System Tools > Network Device Control (or type the command system-control-network) to select a profile and activate it. The activate profile section only appears in the Network Device Control interface if more than the default Common interface exists.
Alternatively, execute the following command to enable a profile (replace <profilename> with the name of the profile):
system-config-network-cmd --profile <profilename> --activate

17.11. Device Aliases

Device aliases are virtual devices associated with the same physical hardware, but they can be activated at the same time to have different IP addresses. They are commonly represented as the device name followed by a colon and a number (for example, eth0:1). They are useful if you want to have multiple IP addresses for a system that only has one network card.
After configuring the Ethernet device —such as eth0 —to use a static IP address (DHCP does not work with aliases), go to the Devices tab and click New. Select the Ethernet card to configure with an alias, set the static IP address for the alias, and click Apply to create it. Since a device already exists for the Ethernet card, the one just created is the alias, such as eth0:1.

Warning

If you are configuring an Ethernet device to have an alias, neither the device nor the alias can be configured to use DHCP. You must configure the IP addresses manually.
Figure 17.22, “Network Device Alias Example” shows an example of one alias for the eth0 device. Notice the eth0:1 device — the first alias for eth0. The second alias for eth0 would have the device name eth0:2, and so on. To modify the settings for the device alias, such as whether to activate it at boot time and the alias number, select it from the list and click the Edit button.
Network Device Alias Example

Figure 17.22. Network Device Alias Example


Select the alias and click the Activate button to activate the alias. If you have configured multiple profiles, select which profiles in which to include it.
To verify that the alias has been activated, use the command /sbin/ifconfig. The output should show the device and the device alias with different IP addresses:
eth0      Link encap:Ethernet
	HWaddr 00:A0:CC:60:B7:G4
	inet addr:192.168.100.5  Bcast:192.168.100.255  Mask:255.255.255.0
	UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
	RX packets:161930 errors:1 dropped:0 overruns:0 frame:0
	TX packets:244570 errors:0 dropped:0 overruns:0 carrier:0
	collisions:475 txqueuelen:100
	RX bytes:55075551 (52.5 Mb)  TX bytes:178108895 (169.8 Mb)
	Interrupt:10 Base address:0x9000  eth0:1    Link encap:Ethernet  HWaddr 00:A0:CC:60:B7:G4
	inet addr:192.168.100.42  Bcast:192.168.100.255  Mask:255.255.255.0
	UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
	Interrupt:10 Base address:0x9000  lo
	Link encap:Local Loopback
	inet addr:127.0.0.1  Mask:255.0.0.0
	UP LOOPBACK RUNNING  MTU:16436  Metric:1
	RX packets:5998 errors:0 dropped:0 overruns:0 frame:0
	TX packets:5998 errors:0 dropped:0 overruns:0 carrier:0
	collisions:0 txqueuelen:0
	RX bytes:1627579 (1.5 Mb)  TX bytes:1627579 (1.5 Mb)

17.12. Saving and Restoring the Network Configuration

The command line version of Network Administration Tool can be used to save the system's network configuration to a file. This file can then be used to restore the network settings to a Red Hat Enterprise Linux system.
This feature can be used as part of an automated backup script, to save the configuration before upgrading or reinstalling, or to copy the configuration to a different Red Hat Enterprise Linux system.
To save, or export, the network configuration of a system to the file /tmp/network-config, execute the following command as root:
system-config-network-cmd -e > /tmp/network-config
To restore, or import, the network configuration from the file created from the previous command, execute the following command as root:
system-config-network-cmd -i -c -f /tmp/network-config
The -i option means to import the data, the -c option means to clear the existing configuration prior to importing, and the -f option specifies that the file to import is as follows.

Chapter 18. Controlling Access to Services

Maintaining security on your system is extremely important, and one approach for this task is to manage access to system services carefully. Your system may need to provide open access to particular services (for example, httpd if you are running a Web server). However, if you do not need to provide a service, you should turn it off to minimize your exposure to possible bug exploits.
There are several different methods for managing access to system services. Choose which method of management to use based on the service, your system's configuration, and your level of Linux expertise.
The easiest way to deny access to a service is to turn it off. Both the services managed by xinetd and the services in the /etc/rc.d/init.d hierarchy (also known as SysV services) can be configured to start or stop using three different applications:
Services Configuration Tool
This is a graphical application that displays a description of each service, displays whether each service is started at boot time (for runlevels 3, 4, and 5), and allows services to be started, stopped, and restarted.
ntsysv
This is a text-based application that allows you to configure which services are started at boot time for each runlevel. Non-xinetd services can not be started, stopped, or restarted using this program.
chkconfig
This is a command line utility that allows you to turn services on and off for the different runlevels. Non-xinetd services can not be started, stopped, or restarted using this utility.
You may find that these tools are easier to use than the alternatives — editing the numerous symbolic links located in the directories below /etc/rc.d by hand or editing the xinetd configuration files in /etc/xinetd.d.
Another way to manage access to system services is by using iptables to configure an IP firewall. If you are a new Linux user, note that iptables may not be the best solution for you. Setting up iptables can be complicated, and is best tackled by experienced Linux system administrators.
On the other hand, the benefit of using iptables is flexibility. For example, if you need a customized solution which provides certain hosts access to certain services, iptables can provide it for you. Refer to Section 48.8.1, “Netfilter and IPTables” and Section 48.8.3, “Using IPTables” for more information about iptables.
Alternatively, if you are looking for a utility to set general access rules for your home machine, and/or if you are new to Linux, try the Security Level Configuration Tool (system-config-securitylevel), which allows you to select the security level for your system, similar to the Firewall Configuration screen in the installation program.
Refer to Section 48.8, “Firewalls” for more information.

Important

When you allow access for new services, always remember that both the firewall and SELinux need to be configured as well. One of the most common mistakes committed when configuring a new service is neglecting to implement the necessary firewall configuration and SELinux policies to allow access for it. Refer to Section 48.8.2, “Basic Firewall Configuration” for more information.

18.1. Runlevels

Before you can configure access to services, you must understand Linux runlevels. A runlevel is a state, or mode, that is defined by the services listed in the directory /etc/rc.d/rc<x>.d, where <x> is the number of the runlevel.
The following runlevels exist:
  • 0 — Halt
  • 1 — Single-user mode
  • 2 — Not used (user-definable)
  • 3 — Full multi-user mode
  • 4 — Not used (user-definable)
  • 5 — Full multi-user mode (with an X-based login screen)
  • 6 — Reboot
If you use a text login screen, you are operating in runlevel 3. If you use a graphical login screen, you are operating in runlevel 5.
The default runlevel can be changed by modifying the /etc/inittab file, which contains a line near the top of the file similar to the following:
id:5:initdefault:
Change the number in this line to the desired runlevel. The change does not take effect until you reboot the system.

18.2. TCP Wrappers

Many UNIX system administrators are accustomed to using TCP wrappers to manage access to certain network services. Any network services managed by xinetd (as well as any program with built-in support for libwrap) can use TCP wrappers to manage access. xinetd can use the /etc/hosts.allow and /etc/hosts.deny files to configure access to system services. As the names imply, hosts.allow contains a list of rules that allow clients to access the network services controlled by xinetd, and hosts.deny contains rules to deny access. The hosts.allow file takes precedence over the hosts.deny file. Permissions to grant or deny access can be based on individual IP address (or hostnames) or on a pattern of clients. Refer to hosts_access in section 5 of the man pages (man 5 hosts_access) for details.

18.2.1. xinetd

To control access to Internet services, use xinetd, which is a secure replacement for inetd. The xinetd daemon conserves system resources, provides access control and logging, and can be used to start special-purpose servers. xinetd can also be used to grant or deny access to particular hosts, provide service access at specific times, limit the rate of incoming connections, limit the load created by connections, and more.
xinetd runs constantly and listens on all ports for the services it manages. When a connection request arrives for one of its managed services, xinetd starts up the appropriate server for that service.
The configuration file for xinetd is /etc/xinetd.conf, but the file only contains a few defaults and an instruction to include the /etc/xinetd.d directory. To enable or disable an xinetd service, edit its configuration file in the /etc/xinetd.d directory. If the disable attribute is set to yes, the service is disabled. If the disable attribute is set to no, the service is enabled. You can edit any of the xinetd configuration files or change its enabled status using the Services Configuration Tool, ntsysv, or chkconfig. For a list of network services controlled by xinetd, review the contents of the /etc/xinetd.d directory with the command ls /etc/xinetd.d.

18.3. Services Configuration Tool

The Services Configuration Tool is a graphical application developed by Red Hat to configure which SysV services in the /etc/rc.d/init.d directory are started at boot time (for runlevels 3, 4, and 5) and which xinetd services are enabled. It also allows you to start, stop, and restart SysV services as well as reload xinetd.
To start the Services Configuration Tool from the desktop, go to the Applications (the main menu on the panel) > System Settings > Server Settings > Services or type the command system-config-services at a shell prompt (for example, in an XTerm or a GNOME terminal).
Services Configuration Tool

Figure 18.1. Services Configuration Tool


The Services Configuration Tool displays the current runlevel as well as the runlevel you are currently editing. To edit a different runlevel, select Edit Runlevel from the pulldown menu and select runlevel 3, 4, or 5. Refer to Section 18.1, “Runlevels” for a description of runlevels.
The Services Configuration Tool lists the services from the /etc/rc.d/init.d directory as well as the services controlled by xinetd. Click on the name of the service from the list on the left-hand side of the application to display a brief description of that service as well as the status of the service. If the service is not an xinetd service, the status window shows whether the service is currently running. If the service is controlled by xinetd, the status window displays the phrase xinetd service.
To start, stop, or restart a service immediately, select the service from the list and click the appropriate button on the toolbar (or choose the action from the Actions pulldown menu). If the service is an xinetd service, the action buttons are disabled because they cannot be started or stopped individually.
If you enable/disable an xinetd service by checking or unchecking the checkbox next to the service name, you must select File > Save Changes from the pulldown menu (or the Save button above the tabs) to reload xinetd and immediately enable/disable the xinetd service that you changed. xinetd is also configured to remember the setting. You can enable/disable multiple xinetd services at a time and save the changes when you are finished.
For example, assume you check rsync to enable it in runlevel 3 and then save the changes. The rsync service is immediately enabled. The next time xinetd is started, rsync is still enabled.

Note

When you save changes to xinetd services, xinetd is reloaded, and the changes take place immediately. When you save changes to other services, the runlevel is reconfigured, but the changes do not take effect immediately.
To enable a non-xinetd service to start at boot time for the currently selected runlevel, check the box beside the name of the service in the list. After configuring the runlevel, apply the changes by selecting File > Save Changes from the pulldown menu. The runlevel configuration is changed, but the runlevel is not restarted; thus, the changes do not take place immediately.
For example, assume you are configuring runlevel 3. If you change the value for the httpd service from checked to unchecked and then select Save Changes, the runlevel 3 configuration changes so that httpd is not started at boot time. However, runlevel 3 is not reinitialized, so httpd is still running. Select one of following options at this point:
  1. Stop the httpd service — Stop the service by selecting it from the list and clicking the Stop button. A message appears stating that the service was stopped successfully.
  2. Reinitialize the runlevel — Reinitialize the runlevel by going to a shell prompt and typing the command telinit x (where x is the runlevel number; in this example, 3.). This option is recommended if you change the Start at Boot value of multiple services and want to activate the changes immediately.
  3. Do nothing else — You do not have to stop the httpd service. You can wait until the system is rebooted for the service to stop. The next time the system is booted, the runlevel is initialized without the httpd service running.
To add a service to a runlevel, select the runlevel from the Edit Runlevel pulldown menu, and then select Actions > Add Service. To delete a service from a runlevel, select the runlevel from the Edit Runlevel pulldown menu, select the service to be deleted from the list on the left, and select Actions > Delete Service.

18.4. ntsysv

The ntsysv utility provides a simple interface for activating or deactivating services. You can use ntsysv to turn an xinetd-managed service on or off. You can also use ntsysv to configure runlevels. By default, only the current runlevel is configured. To configure a different runlevel, specify one or more runlevels with the --level option. For example, the command ntsysv --level 345 configures runlevels 3, 4, and 5.
The ntsysv interface works like the text mode installation program. Use the up and down arrows to navigate up and down the list. The space bar selects/unselects services and is also used to "press" the Ok and Cancel buttons. To move between the list of services and the Ok and Cancel buttons, use the Tab key. An asterisk (*) signifies that a service is set to on. Pressing the F1 key displays a short description of the selected service.
The ntsysv utility

Figure 18.2. The ntsysv utility


Warning

Services managed by xinetd are immediately affected by ntsysv. For all other services, changes do not take effect immediately. You must stop or start the individual service with the command service <daemon> stop (where <daemon> is the name of the service you want to stop; for example, httpd). Replace stop with start or restart to start or restart the service.

18.5. chkconfig

The chkconfig command can also be used to activate and deactivate services. The chkconfig --list command displays a list of system services and whether they are started (on) or stopped (off) in runlevels 0-6. At the end of the list is a section for the services managed by xinetd.
If the chkconfig --list command is used to query a service managed by xinetd, it displays whether the xinetd service is enabled (on) or disabled (off). For example, the command chkconfig --list rsync returns the following output:
rsync          on
As shown, rsync is enabled as an xinetd service. If xinetd is running, rsync is enabled.
If you use chkconfig --list to query a service in /etc/rc.d, that service's settings for each runlevel are displayed. For example, the command chkconfig --list httpd returns the following output:
httpd         0:off   1:off   2:on    3:on    4:on    5:on    6:off
chkconfig can also be used to configure a service to be started (or not) in a specific runlevel. For example, to turn nscd off in runlevels 3, 4, and 5, use the following command:
chkconfig --level 345 nscd off

Warning

Services managed by xinetd are immediately affected by chkconfig. For example, if xinetd is running while rsync is disabled, and the command chkconfig rsync on is executed, then rsync is immediately enabled without having to restart xinetd manually. Changes for other services do not take effect immediately after using chkconfig. You must stop or start the individual service with the command service <daemon> stop (where <daemon> is the name of the service you want to stop; for example, httpd). Replace stop with start or restart to start or restart the service.

18.6. Additional Resources

For more information, refer to the following resources.

18.6.1. Installed Documentation

  • The man pages for ntsysv, chkconfig, xinetd, and xinetd.conf.
  • man 5 hosts_access — The man page for the format of host access control files (in section 5 of the man pages).

18.6.2. Useful Websites

  • http://www.xinetd.org — The xinetd webpage. It contains sample configuration files and a more detailed list of features.

Chapter 19. Berkeley Internet Name Domain (BIND)

On most modern networks, including the Internet, users locate other computers by name. This frees users from the daunting task of remembering the numerical network address of network resources. The most effective way to configure a network to allow such name-based connections is to set up a Domain Name Service (DNS) or a nameserver, which resolves hostnames on the network to numerical addresses and vice versa.
This chapter reviews the nameserver included in Red Hat Enterprise Linux and the Berkeley Internet Name Domain (BIND) DNS server, with an emphasis on the structure of its configuration files and how it may be administered both locally and remotely.

Note

BIND is also known as the service named in Red Hat Enterprise Linux. You can manage it via the Services Configuration Tool (system-config-service).

19.1. Introduction to DNS

DNS associates hostnames with their respective IP addresses, so that when users want to connect to other machines on the network, they can refer to them by name, without having to remember IP addresses.
Use of DNS and FQDNs also has advantages for system administrators, allowing the flexibility to change the IP address for a host without affecting name-based queries to the machine. Conversely, administrators can shuffle which machines handle a name-based query.
DNS is normally implemented using centralized servers that are authoritative for some domains and refer to other DNS servers for other domains.
When a client host requests information from a nameserver, it usually connects to port 53. The nameserver then attempts to resolve the FQDN based on its resolver library, which may contain authoritative information about the host requested or cached data from an earlier query. If the nameserver does not already have the answer in its resolver library, it queries other nameservers, called root nameservers, to determine which nameservers are authoritative for the FQDN in question. Then, with that information, it queries the authoritative nameservers to determine the IP address of the requested host. If a reverse lookup is performed, the same procedure is used, except that the query is made with an unknown IP address rather than a name.

19.1.1. Nameserver Zones

On the Internet, the FQDN of a host can be broken down into different sections. These sections are organized into a hierarchy (much like a tree), with a main trunk, primary branches, secondary branches, and so forth. Consider the following FQDN:
bob.sales.example.com
When looking at how an FQDN is resolved to find the IP address that relates to a particular system, read the name from right to left, with each level of the hierarchy divided by periods (.). In this example, com defines the top level domain for this FQDN. The name example is a sub-domain under com, while sales is a sub-domain under example. The name furthest to the left, bob, identifies a specific machine hostname.
Except for the hostname, each section is called a zone, which defines a specific namespace. A namespace controls the naming of the sub-domains to its left. While this example only contains two sub-domains, an FQDN must contain at least one sub-domain but may include many more, depending upon how the namespace is organized.
Zones are defined on authoritative nameservers through the use of zone files (which describe the namespace of that zone), the mail servers to be used for a particular domain or sub-domain, and more. Zone files are stored on primary nameservers (also called master nameservers), which are truly authoritative and where changes are made to the files, and secondary nameservers (also called slave nameservers), which receive their zone files from the primary nameservers. Any nameserver can be a primary and secondary nameserver for different zones at the same time, and they may also be considered authoritative for multiple zones. It all depends on how the nameserver is configured.

19.1.2. Nameserver Types

There are four primary nameserver configuration types:
master
Stores original and authoritative zone records for a namespace, and answers queries about the namespace from other nameservers.
slave
Answers queries from other nameservers concerning namespaces for which it is considered an authority. However, slave nameservers get their namespace information from master nameservers.
caching-only
Offers name-to-IP resolution services, but is not authoritative for any zones. Answers for all resolutions are cached in memory for a fixed period of time, which is specified by the retrieved zone record.
forwarding
Forwards requests to a specific list of nameservers for name resolution. If none of the specified nameservers can perform the resolution, the resolution fails.
A nameserver may be one or more of these types. For example, a nameserver can be a master for some zones, a slave for others, and only offer forwarding resolutions for others.

19.1.3. BIND as a Nameserver

BIND performs name resolution services through the /usr/sbin/named daemon. BIND also includes an administration utility called /usr/sbin/rndc. More information about rndc can be found in Section 19.4, “Using rndc.
BIND stores its configuration files in the following locations:
/etc/named.conf
The configuration file for the named daemon
/var/named/ directory
The named working directory which stores zone, statistic, and cache files

Note

If you have installed the bind-chroot package, the BIND service will run in the /var/named/chroot environment. All configuration files will be moved there. As such, named.conf will be located in /var/named/chroot/etc/named.conf, and so on.

Tip

If you have installed the caching-nameserver package, the default configuration file is /etc/named.caching-nameserver.conf. To override this default configuration, you can create your own custom configuration file in /etc/named.conf. BIND will use the /etc/named.conf custom file instead of the default configuration file after you restart.
The next few sections review the BIND configuration files in more detail.

19.2.  /etc/named.conf

The named.conf file is a collection of statements using nested options surrounded by opening and closing ellipse characters, { }. Administrators must be careful when editing named.conf to avoid syntax errors as many seemingly minor errors prevent the named service from starting.
A typical named.conf file is organized similar to the following example:
<statement-1> ["<statement-1-name>"] [<statement-1-class>] {
	<option-1>;
	<option-2>;
	<option-N>;
};
<statement-2> ["<statement-2-name>"] [<statement-2-class>] {
	<option-1>;
	<option-2>;
	<option-N>;
};
<statement-N> ["<statement-N-name>"] [<statement-N-class>] {
	<option-1>;
	<option-2>;
	<option-N>;
};

19.2.1. Common Statement Types

The following types of statements are commonly used in /etc/named.conf:

19.2.1.1.  acl Statement

The acl statement (or access control statement) defines groups of hosts which can then be permitted or denied access to the nameserver.
An acl statement takes the following form:
acl <acl-name> {
	<match-element>;
	[<match-element>; ...]
};
In this statement, replace <acl-name> with the name of the access control list and replace <match-element> with a semi-colon separated list of IP addresses. Most of the time, an individual IP address or IP network notation (such as 10.0.1.0/24) is used to identify the IP addresses within the acl statement.
The following access control lists are already defined as keywords to simplify configuration:
  • any — Matches every IP address
  • localhost — Matches any IP address in use by the local system
  • localnets — Matches any IP address on any network to which the local system is connected
  • none — Matches no IP addresses
When used in conjunction with other statements (such as the options statement), acl statements can be very useful in preventing the misuse of a BIND nameserver.
The following example defines two access control lists and uses an options statement to define how they are treated by the nameserver:
acl black-hats {
	10.0.2.0/24;
	192.168.0.0/24;
};
acl red-hats {
	10.0.1.0/24;
};
options {
	blackhole { black-hats; };
	allow-query { red-hats; };
	allow-recursion { red-hats; };
};
This example contains two access control lists, black-hats and red-hats. Hosts in the black-hats list are denied access to the nameserver, while hosts in the red-hats list are given normal access.

19.2.1.2.  include Statement

The include statement allows files to be included in a named.conf file. In this way, sensitive configuration data (such as keys) can be placed in a separate file with restrictive permissions.
An include statement takes the following form:
include "<file-name>"
In this statement, <file-name> is replaced with an absolute path to a file.

19.2.1.3.  options Statement

The options statement defines global server configuration options and sets defaults for other statements. It can be used to specify the location of the named working directory, the types of queries allowed, and much more.
The options statement takes the following form:
options {
	<option>;
	[<option>; ...]
};
In this statement, the <option> directives are replaced with a valid option.
The following are commonly used options:
allow-query
Specifies which hosts are allowed to query this nameserver. By default, all hosts are allowed to query. An access control list, or collection of IP addresses or networks, may be used here to allow only particular hosts to query the nameserver.
allow-recursion
Similar to allow-query, this option applies to recursive queries. By default, all hosts are allowed to perform recursive queries on the nameserver.
blackhole
Specifies which hosts are not allowed to query the server.
directory
Specifies the named working directory if different from the default value, /var/named/.
forwarders
Specifies a list of valid IP addresses for nameservers where requests should be forwarded for resolution.
forward
Specifies the forwarding behavior of a forwarders directive.
The following options are accepted:
  • first — Specifies that the nameservers listed in the forwarders directive be queried before named attempts to resolve the name itself.
  • only — Specifies that named does not attempt name resolution itself in the event that queries to nameservers specified in the forwarders directive fail.
listen-on
Specifies the network interface on which named listens for queries. By default, all interfaces are used.
Using this directive on a DNS server which also acts a gateway, BIND can be configured to only answer queries that originate from one of the networks.
The following is an example of a listen-on directive:
options {
	listen-on { 10.0.1.1; };
};
In this example, only requests that arrive from the network interface serving the private network (10.0.1.1) are accepted.
notify
Controls whether named notifies the slave servers when a zone is updated. It accepts the following options:
  • yes — Notifies slave servers.
  • no — Does not notify slave servers.
  • explicit — Only notifies slave servers specified in an also-notify list within a zone statement.
pid-file
Specifies the location of the process ID file created by named.
root-delegation-only
Turns on the enforcement of delegation properties in top-level domains (TLDs) and root zones with an optional exclude list. Delegation is the process of dividing a single zone into multiple subzones. In order to create a delegated zone, items known as NS records are used. NameServer records (delegation records) announce the authoritative nameservers for a particular zone.
The following root-delegation-only example specifies an exclude list of TLDs from whom undelegated responses are expected and trusted:
options {
	root-delegation-only exclude { "ad"; "ar"; "biz"; "cr"; "cu"; "de"; "dm"; "id";
		"lu"; "lv"; "md"; "ms"; "museum"; "name"; "no"; "pa";
		"pf"; "se"; "sr"; "to"; "tw"; "us"; "uy"; };
};
statistics-file
Specifies an alternate location for statistics files. By default, named statistics are saved to the /var/named/named.stats file.
There are several other options also available, many of which rely upon one another to work properly. Refer to the BIND 9 Administrator Reference Manual referenced in Section 19.7.1, “Installed Documentation” and the bind.conf man page for more details.

19.2.1.4.  zone Statement

A zone statement defines the characteristics of a zone, such as the location of its configuration file and zone-specific options. This statement can be used to override the global options statements.
A zone statement takes the following form:
zone <zone-name> <zone-class> {
	<zone-options>;
	[<zone-options>; ...]
};
In this statement, <zone-name> is the name of the zone, <zone-class> is the optional class of the zone, and <zone-options> is a list of options characterizing the zone.
The <zone-name> attribute for the zone statement is particularly important. It is the default value assigned for the $ORIGIN directive used within the corresponding zone file located in the /var/named/ directory. The named daemon appends the name of the zone to any non-fully qualified domain name listed in the zone file.

Note

If you have installed the caching-nameserver package, the default configuration file will be in /etc/named.rfc1912.zones.
For example, if a zone statement defines the namespace for example.com, use example.com as the <zone-name> so it is placed at the end of hostnames within the example.com zone file.
For more information about zone files, refer to Section 19.3, “Zone Files”.
The most common zone statement options include the following:
allow-query
Specifies the clients that are allowed to request information about this zone. The default is to allow all query requests.
allow-transfer
Specifies the slave servers that are allowed to request a transfer of the zone's information. The default is to allow all transfer requests.
allow-update
Specifies the hosts that are allowed to dynamically update information in their zone. The default is to deny all dynamic update requests.
Be careful when allowing hosts to update information about their zone. Do not enable this option unless the host specified is completely trusted. In general, it is better to have an administrator manually update the records for a zone and reload the named service.
file
Specifies the name of the file in the named working directory that contains the zone's configuration data.
masters
Specifies the IP addresses from which to request authoritative zone information and is used only if the zone is defined as type slave.
notify
Specifies whether or not named notifies the slave servers when a zone is updated. This directive accepts the following options:
  • yes — Notifies slave servers.
  • no — Does not notify slave servers.
  • explicit — Only notifies slave servers specified in an also-notify list within a zone statement.
type
Defines the type of zone.
Below is a list of valid options:
  • delegation-only — Enforces the delegation status of infrastructure zones such as COM, NET, or ORG. Any answer that is received without an explicit or implicit delegation is treated as NXDOMAIN. This option is only applicable in TLDs or root zone files used in recursive or caching implementations.
  • forward — Forwards all requests for information about this zone to other nameservers.
  • hint — A special type of zone used to point to the root nameservers which resolve queries when a zone is not otherwise known. No configuration beyond the default is necessary with a hint zone.
  • master — Designates the nameserver as authoritative for this zone. A zone should be set as the master if the zone's configuration files reside on the system.
  • slave — Designates the nameserver as a slave server for this zone. Also specifies the IP address of the master nameserver for the zone.
zone-statistics
Configures named to keep statistics concerning this zone, writing them to either the default location (/var/named/named.stats) or the file listed in the statistics-file option in the server statement. Refer to Section 19.2.2, “Other Statement Types” for more information about the server statement.

19.2.1.5. Sample zone Statements

Most changes to the /etc/named.conf file of a master or slave nameserver involves adding, modifying, or deleting zone statements. While these zone statements can contain many options, most nameservers require only a small subset to function efficiently. The following zone statements are very basic examples illustrating a master-slave nameserver relationship.
The following is an example of a zone statement for the primary nameserver hosting example.com (192.168.0.1):
zone "example.com" IN {
	type master;
	file "example.com.zone";
	allow-update { none; };
};
In the statement, the zone is identified as example.com, the type is set to master, and the named service is instructed to read the /var/named/example.com.zone file. It also tells named not to allow any other hosts to update.
A slave server's zone statement for example.com is slightly different from the previous example. For a slave server, the type is set to slave and in place of the allow-update line is a directive telling named the IP address of the master server.
The following is an example slave server zone statement for example.com zone:
zone "example.com" {
	type slave;
	file "example.com.zone";
	masters { 192.168.0.1; };
};
This zone statement configures named on the slave server to query the master server at the 192.168.0.1 IP address for information about the example.com zone. The information that the slave server receives from the master server is saved to the /var/named/example.com.zone file.

19.2.2. Other Statement Types

The following is a list of lesser used statement types available within named.conf:
controls
Configures various security requirements necessary to use the rndc command to administer the named service.
Refer to Section 19.4.1, “Configuring /etc/named.conf to learn more about how the controls statement is structured and what options are available.
key "<key-name>"
Defines a particular key by name. Keys are used to authenticate various actions, such as secure updates or the use of the rndc command. Two options are used with key:
  • algorithm <algorithm-name> — The type of algorithm used, such as dsa or hmac-md5.
  • secret "<key-value>" — The encrypted key.
Refer to Section 19.4.2, “Configuring /etc/rndc.conf for instructions on how to write a key statement.
logging
Allows for the use of multiple types of logs, called channels. By using the channel option within the logging statement, a customized type of log can be constructed — with its own file name (file), size limit (size), versioning (version), and level of importance (severity). Once a customized channel is defined, a category option is used to categorize the channel and begin logging when named is restarted.
By default, named logs standard messages to the syslog daemon, which places them in /var/log/messages. This occurs because several standard channels are built into BIND with various severity levels, such as default_syslog (which handles informational logging messages) and default_debug (which specifically handles debugging messages). A default category, called default, uses the built-in channels to do normal logging without any special configuration.
Customizing the logging process can be a very detailed process and is beyond the scope of this chapter. For information on creating custom BIND logs, refer to the BIND 9 Administrator Reference Manual referenced in Section 19.7.1, “Installed Documentation”.
server
Specifies options that affect how named should respond to remote nameservers, especially with regard to notifications and zone transfers.
The transfer-format option controls whether one resource record is sent with each message (one-answer) or multiple resource records are sent with each message (many-answers). While many-answers is more efficient, only newer BIND nameservers understand it.
trusted-keys
Contains assorted public keys used for secure DNS (DNSSEC). Refer to Section 19.5.3, “Security” for more information concerning BIND security.
view "<view-name>"
Creates special views depending upon which network the host querying the nameserver is on. This allows some hosts to receive one answer regarding a zone while other hosts receive totally different information. Alternatively, certain zones may only be made available to particular trusted hosts while non-trusted hosts can only make queries for other zones.
Multiple views may be used, but their names must be unique. The match-clients option specifies the IP addresses that apply to a particular view. Any options statement may also be used within a view, overriding the global options already configured for named. Most view statements contain multiple zone statements that apply to the match-clients list. The order in which view statements are listed is important, as the first view statement that matches a particular client's IP address is used.
Refer to Section 19.5.2, “Multiple Views” for more information about the view statement.

19.2.3. Comment Tags

The following is a list of valid comment tags used within named.conf:
  • // — When placed at the beginning of a line, that line is ignored by named.
  • # — When placed at the beginning of a line, that line is ignored by named.
  • /* and */ — When text is enclosed in these tags, the block of text is ignored by named.

19.3. Zone Files

Zone files contain information about a namespace and are stored in the named working directory (/var/named/) by default. Each zone file is named according to the file option data in the zone statement, usually in a way that relates to the domain in question and identifies the file as containing zone data, such as example.com.zone.

Note

If you have installed the bind-chroot package, the BIND service will run in the /var/named/chroot environment. All configuration files will be moved there. As such, you can find the zone files in /var/named/chroot/var/named.
Each zone file may contain directives and resource records. Directives tell the nameserver to perform tasks or apply special settings to the zone. Resource records define the parameters of the zone and assign identities to individual hosts. Directives are optional, but resource records are required to provide name service to a zone.
All directives and resource records should be entered on individual lines.
Comments can be placed after semicolon characters (;) in zone files.

19.3.1. Zone File Directives

Directives begin with the dollar sign character ($) followed by the name of the directive. They usually appear at the top of the zone file.
The following are commonly used directives:
$INCLUDE
Configures named to include another zone file in this zone file at the place where the directive appears. This allows additional zone settings to be stored apart from the main zone file.
$ORIGIN
Appends the domain name to unqualified records, such as those with the hostname and nothing more.
For example, a zone file may contain the following line:
$ORIGIN example.com.
Any names used in resource records that do not end in a trailing period (.) are appended with example.com.

Note

The use of the $ORIGIN directive is unnecessary if the zone is specified in /etc/named.conf because the zone name is used as the value for the $ORIGIN directive by default.
$TTL
Sets the default Time to Live (TTL) value for the zone. This is the length of time, in seconds, that a zone resource record is valid. Each resource record can contain its own TTL value, which overrides this directive.
Increasing this value allows remote nameservers to cache the zone information for a longer period of time, reducing the number of queries for the zone and lengthening the amount of time required to proliferate resource record changes.

19.3.2. Zone File Resource Records

The primary component of a zone file is its resource records.
There are many types of zone file resource records. The following are used most frequently:
A
This refers to the Address record, which specifies an IP address to assign to a name, as in this example:
<host> IN A <IP-address> 
If the <host> value is omitted, then an A record points to a default IP address for the top of the namespace. This system is the target for all non-FQDN requests.
Consider the following A record examples for the example.com zone file:
server1		IN	A	10.0.1.3
		IN	A	10.0.1.5
Requests for example.com are pointed to 10.0.1.3 or 10.0.1.5.
CNAME
This refers to the Canonical Name record, which maps one name to another. This type of record can also be referred to as an alias record.
The next example tells named that any requests sent to the <alias-name> should point to the host, <real-name>. CNAME records are most commonly used to point to services that use a common naming scheme, such as www for Web servers.
<alias-name> IN CNAME <real-name> 
In the following example, an A record binds a hostname to an IP address, while a CNAME record points the commonly used www hostname to it.
server1		IN	A	10.0.1.5
www		IN	CNAME	server1
MX
This refers to the Mail eXchange record, which tells where mail sent to a particular namespace controlled by this zone should go.
 IN MX <preference-value> <email-server-name> 
Here, the <preference-value> allows numerical ranking of the email servers for a namespace, giving preference to some email systems over others. The MX resource record with the lowest <preference-value> is preferred over the others. However, multiple email servers can possess the same value to distribute email traffic evenly among them.
The <email-server-name> may be a hostname or FQDN.
IN     MX     10     mail.example.com.
IN     MX     20     mail2.example.com.
In this example, the first mail.example.com email server is preferred to the mail2.example.com email server when receiving email destined for the example.com domain.
NS
This refers to the NameServer record, which announces the authoritative nameservers for a particular zone.
The following illustrates the layout of an NS record:
 IN NS <nameserver-name> 
Here, <nameserver-name> should be an FQDN.
Next, two nameservers are listed as authoritative for the domain. It is not important whether these nameservers are slaves or if one is a master; they are both still considered authoritative.
IN     NS     dns1.example.com.
IN     NS     dns2.example.com.
PTR
This refers to the PoinTeR record, which is designed to point to another part of the namespace.
PTR records are primarily used for reverse name resolution, as they point IP addresses back to a particular name. Refer to Section 19.3.4, “Reverse Name Resolution Zone Files” for more examples of PTR records in use.
SOA
This refers to the Start Of Authority resource record, which proclaims important authoritative information about a namespace to the nameserver.
Located after the directives, an SOA resource record is the first resource record in a zone file.
The following shows the basic structure of an SOA resource record:
@  IN	SOA  <primary-name-server>  <hostmaster-email> (
	<serial-number>
	<time-to-refresh>
	<time-to-retry>
	<time-to-expire>
	<minimum-TTL> )
The @ symbol places the $ORIGIN directive (or the zone's name, if the $ORIGIN directive is not set) as the namespace being defined by this SOA resource record. The hostname of the primary nameserver that is authoritative for this domain is the <primary-name-server> directive, and the email of the person to contact about this namespace is the <hostmaster-email> directive.
The <serial-number> directive is a numerical value incremented every time the zone file is altered to indicate it is time for named to reload the zone. The <time-to-refresh> directive is the numerical value slave servers use to determine how long to wait before asking the master nameserver if any changes have been made to the zone. The <serial-number> directive is a numerical value used by the slave servers to determine if it is using outdated zone data and should therefore refresh it.
The <time-to-retry> directive is a numerical value used by slave servers to determine the length of time to wait before issuing a refresh request in the event that the master nameserver is not answering. If the master has not replied to a refresh request before the amount of time specified in the <time-to-expire> directive elapses, the slave servers stop responding as an authority for requests concerning that namespace.
In BIND 4 and 8, the <minimum-TTL> directive is the amount of time other nameservers cache the zone's information. However, in BIND 9, the <minimum-TTL> directive defines how long negative answers are cached for. Caching of negative answers can be set to a maximum of 3 hours (3H).
When configuring BIND, all times are specified in seconds. However, it is possible to use abbreviations when specifying units of time other than seconds, such as minutes (M), hours (H), days (D), and weeks (W). The table in Table 19.1, “Seconds compared to other time units” shows an amount of time in seconds and the equivalent time in another format.

Table 19.1. Seconds compared to other time units

Seconds Other Time Units
60 1M
1800 30M
3600 1H
10800 3H
21600 6H
43200 12H
86400 1D
259200 3D
604800 1W
31536000 365D

The following example illustrates the form an SOA resource record might take when it is populated with real values.
@	IN	SOA	dns1.example.com.	hostmaster.example.com. (
		2001062501 ; serial
		21600      ; refresh after 6 hours
		3600       ; retry after 1 hour
		604800     ; expire after 1 week
		86400 )    ; minimum TTL of 1 day

19.3.3. Example Zone File

Seen individually, directives and resource records can be difficult to grasp. However, when placed together in a single file, they become easier to understand.
The following example shows a very basic zone file.
$ORIGIN example.com.
$TTL 86400
@		IN	SOA	dns1.example.com.	hostmaster.example.com. (
			2001062501 ; serial
			21600      ; refresh after 6 hours
			3600       ; retry after 1 hour
			604800     ; expire after 1 week
			86400 )    ; minimum TTL of 1 day
;
;
		IN	NS	dns1.example.com.
		IN	NS	dns2.example.com.
dns1		IN	A	10.0.1.1
		IN	AAAA	aaaa:bbbb::1
dns2		IN	A	10.0.1.2
		IN	AAAA	aaaa:bbbb::2
;
;
@		IN	MX	10	mail.example.com.
		IN	MX	20	mail2.example.com.
mail		IN	A	10.0.1.5
		IN	AAAA	aaaa:bbbb::5
mail2		IN	A	10.0.1.6
		IN	AAAA	aaaa:bbbb::6
;
;
; This sample zone file illustrates sharing the same IP addresses
; for multiple services:
;
services	IN	A	10.0.1.10
		IN	AAAA	aaaa:bbbb::10
		IN	A	10.0.1.11
		IN	AAAA	aaaa:bbbb::11
ftp		IN	CNAME	services.example.com.
www		IN	CNAME	services.example.com.
;
;
In this example, standard directives and SOA values are used. The authoritative nameservers are set as dns1.example.com and dns2.example.com, which have A records that tie them to 10.0.1.1 and 10.0.1.2, respectively.
The email servers configured with the MX records point to mail and mail2 via A records. Since the mail and mail2 names do not end in a trailing period (.), the $ORIGIN domain is placed after them, expanding them to mail.example.com and mail2.example.com. Through the related A resource records, their IP addresses can be determined.
Services available at the standard names, such as www.example.com (WWW), are pointed at the appropriate servers using a CNAME record.
This zone file would be called into service with a zone statement in the named.conf similar to the following:
zone "example.com" IN {
	type master;
	file "example.com.zone";
	allow-update { none; };
};

19.3.4. Reverse Name Resolution Zone Files

A reverse name resolution zone file is used to translate an IP address in a particular namespace into an FQDN. It looks very similar to a standard zone file, except that PTR resource records are used to link the IP addresses to a fully qualified domain name.
The following illustrates the layout of a PTR record:
<last-IP-digit> IN PTR <FQDN-of-system> 
The <last-IP-digit> is the last number in an IP address which points to a particular system's FQDN.
In the following example, IP addresses 10.0.1.1 through 10.0.1.6 are pointed to corresponding FQDNs. It can be located in /var/named/example.com.rr.zone.
$ORIGIN 1.0.10.in-addr.arpa.
$TTL 86400
@	IN	SOA	dns1.example.com.	hostmaster.example.com. (
			2001062501 ; serial
			21600      ; refresh after 6 hours
			3600       ; retry after 1 hour
			604800     ; expire after 1 week
			86400 )    ; minimum TTL of 1 day
;
@	IN	NS	dns1.example.com.
;
1	IN	PTR	dns1.example.com.
2	IN	PTR	dns2.example.com.
;
5	IN	PTR	server1.example.com.
6	IN	PTR	server2.example.com.
;
3	IN	PTR	ftp.example.com.
4	IN	PTR	ftp.example.com.
This zone file would be called into service with a zone statement in the named.conf file similar to the following:
zone "1.0.10.in-addr.arpa" IN {
	type master;
	file "example.com.rr.zone";
	allow-update { none; };
};
There is very little difference between this example and a standard zone statement, except for the zone name. Note that a reverse name resolution zone requires the first three blocks of the IP address reversed followed by .in-addr.arpa. This allows the single block of IP numbers used in the reverse name resolution zone file to be associated with the zone.

19.4. Using rndc

BIND includes a utility called rndc which allows command line administration of the named daemon from the localhost or a remote host.
In order to prevent unauthorized access to the named daemon, BIND uses a shared secret key authentication method to grant privileges to hosts. This means an identical key must be present in both /etc/named.conf and the rndc configuration file, /etc/rndc.conf.

Note

If you have installed the bind-chroot package, the BIND service will run in the /var/named/chroot environment. All configuration files will be moved there. As such, the rndc.conf file is located in /var/named/chroot/etc/rndc.conf.
Note that since the rndc utility does not run in a chroot environment, /etc/rndc.conf is a symlink to /var/named/chroot/etc/rndc.conf.

19.4.1. Configuring /etc/named.conf

In order for rndc to connect to a named service, there must be a controls statement in the BIND server's /etc/named.conf file.
The controls statement, shown in the following example, allows rndc to connect from the localhost.
controls {
	inet 127.0.0.1
		allow { localhost; } keys { <key-name>; };
};
This statement tells named to listen on the default TCP port 953 of the loopback address and allow rndc commands coming from the localhost, if the proper key is given. The <key-name> specifies a name in the key statement within the /etc/named.conf file. The next example illustrates a sample key statement.
key "<key-name>" {
	algorithm hmac-md5;
	secret "<key-value>";
};
In this case, the <key-value> uses the HMAC-MD5 algorithm. Use the following command to generate keys using the HMAC-MD5 algorithm:
dnssec-keygen -a hmac-md5 -b <bit-length> -n HOST <key-file-name> 
A key with at least a 256-bit length is a good idea. The actual key that should be placed in the <key-value> area can be found in the <key-file-name> file generated by this command.

Warning

Because /etc/named.conf is world-readable, it is advisable to place the key statement in a separate file, readable only by root, and then use an include statement to reference it. For example:
include "/etc/rndc.key";

19.4.1.1. Firewall Blocking Communication

If a firewall is blocking connections from the named daemon to other nameservers, the recommended best practice is to change the firewall settings whenever possible.

Warning: Avoid Using Fixed UDP Source Ports

DNS resolvers, that are not configured to perform DNSSEC validation or that need to query DNS zones that are not protected by DNSSEC only, use a 16-bit transaction identifier (TXID) and the destination UDP port number to check whether the DNS reply was sent by the server they queried for DNS data.
Previously, BIND always used a fixed UDP source port when sending DNS queries. BIND used either a port configured using the query-source (and query-source-v6) directive, or one randomly chosen at startup. When a static query source port is used, TXID offers insufficient protection against spoofed replies and allows an attacker to efficiently perform cache-poisoning attacks. To address this issue, BIND was updated to allow the use of a randomly-selected source port for each DNS query, making it more difficult for an attacker to spoof replies, when the query packets cannot be detected. A security update [3] was released for all the affected Red Hat Enterprise Linux versions. Additionally, the default configuration provided by the caching-nameserver package was updated to no longer specify a fixed query source port.
When deploying BIND as a DNS resolver, ensure that BIND is not forced, by the aforementioned configuration directives, to use a fixed query source port. Your firewall configuration must also permit the use of random query source ports. Previously, it was common practice to configure BIND to use port 53 as a query source port, and only allow DNS queries from that port on the firewall.

19.4.2. Configuring /etc/rndc.conf

The key is the most important statement in /etc/rndc.conf.
key "<key-name>" {
	algorithm hmac-md5;
	secret "<key-value>";
};
The <key-name> and <key-value> should be exactly the same as their settings in /etc/named.conf.
To match the keys specified in the target server's /etc/named.conf, add the following lines to /etc/rndc.conf.
options {
	default-server  localhost;
	default-key     "<key-name>";
};
This directive sets a global default key. However, the rndc configuration file can also specify different keys for different servers, as in the following example:
server localhost {
	key  "<key-name>";
};

Important

Make sure that only the root user can read or write to the /etc/rndc.conf file.
For more information about the /etc/rndc.conf file, refer to the rndc.conf man page.

19.4.3. Command Line Options

An rndc command takes the following form:
rndc <options> <command> <command-options> 
When executing rndc on a properly configured localhost, the following commands are available:
  • halt — Stops the named service immediately.
  • querylog — Logs all queries made to this nameserver.
  • refresh — Refreshes the nameserver's database.
  • reload — Reloads the zone files but keeps all other previously cached responses. This command also allows changes to zone files without losing all stored name resolutions.
    If changes made only affect a specific zone, reload only that specific zone by adding the name of the zone after the reload command.
  • stats — Dumps the current named statistics to the /var/named/named.stats file.
  • stop — Stops the server gracefully, saving any dynamic update and Incremental Zone Transfers (IXFR) data before exiting.
Occasionally, it may be necessary to override the default settings in the /etc/rndc.conf file. The following options are available:
  • -c <configuration-file> — Specifies the alternate location of a configuration file.
  • -p <port-number> — Specifies a port number to use for the rndc connection other than the default port 953.
  • -s <server> — Specifies a server other than the default-server listed in /etc/rndc.conf.
  • -y <key-name> — Specifies a key other than the default-key option in /etc/rndc.conf.
Additional information about these options can be found in the rndc man page.

19.5. Advanced Features of BIND

Most BIND implementations only use named to provide name resolution services or to act as an authority for a particular domain or sub-domain. However, BIND version 9 has a number of advanced features that allow for a more secure and efficient DNS service.

Caution

Some of these advanced features, such as DNSSEC, TSIG, and IXFR (which are defined in the following section), should only be used in network environments with nameservers that support the features. If the network environment includes non-BIND or older BIND nameservers, verify that each advanced feature is supported before attempting to use it.
All of the features mentioned are discussed in greater detail in the BIND 9 Administrator Reference Manual referenced in Section 19.7.1, “Installed Documentation”.

19.5.1. DNS Protocol Enhancements

BIND supports Incremental Zone Transfers (IXFR), where a slave nameserver only downloads the updated portions of a zone modified on a master nameserver. The standard transfer process requires that the entire zone be transferred to each slave nameserver for even the smallest change. For very popular domains with very lengthy zone files and many slave nameservers, IXFR makes the notification and update process much less resource-intensive.
Note that IXFR is only available when using dynamic updating to make changes to master zone records. If manually editing zone files to make changes, Automatic Zone Transfer (AXFR) is used. More information on dynamic updating is available in the BIND 9 Administrator Reference Manual referenced in Section 19.7.1, “Installed Documentation”.

19.5.2. Multiple Views

Through the use of the view statement in named.conf, BIND can present different information depending on which network a request originates from.
This is primarily used to deny sensitive DNS entries from clients outside of the local network, while allowing queries from clients inside the local network.
The view statement uses the match-clients option to match IP addresses or entire networks and give them special options and zone data.

19.5.3. Security

BIND supports a number of different methods to protect the updating and transfer of zones, on both master and slave nameservers:
DNSSEC
Short for DNS SECurity, this feature allows for zones to be cryptographically signed with a zone key.
In this way, the information about a specific zone can be verified as coming from a nameserver that has signed it with a particular private key, as long as the recipient has that nameserver's public key.
BIND version 9 also supports the SIG(0) public/private key method of message authentication.
TSIG
Short for Transaction SIGnatures, this feature allows a transfer from master to slave only after verifying that a shared secret key exists on both nameservers.
This feature strengthens the standard IP address-based method of transfer authorization. An attacker would not only need to have access to the IP address to transfer the zone, but they would also need to know the secret key.
BIND version 9 also supports TKEY, which is another shared secret key method of authorizing zone transfers.

19.5.4. IP version 6

BIND version 9 supports name service in IP version 6 (IPv6) environments through the use of A6 zone records.
If the network environment includes both IPv4 and IPv6 hosts, use the lwresd lightweight resolver daemon on all network clients. This daemon is a very efficient, caching-only nameserver which understands the new A6 and DNAME records used under IPv6. Refer to the lwresd man page for more information.

19.6. Common Mistakes to Avoid

It is very common for beginners to make mistakes when editing BIND configuration files. Be sure to avoid the following issues:
  • Take care to increment the serial number when editing a zone file.
    If the serial number is not incremented, the master nameserver has the correct, new information, but the slave nameservers are never notified of the change and do not attempt to refresh their data of that zone.
  • Be careful to use ellipses and semi-colons correctly in the /etc/named.conf file.
    An omitted semi-colon or unclosed ellipse section can cause named to refuse to start.
  • Remember to place periods (.) in zone files after all FQDNs and omit them on hostnames.
    A period at the end of a domain name denotes a fully qualified domain name. If the period is omitted, then named appends the name of the zone or the $ORIGIN value to complete it.
  • If a firewall is blocking connections from the named daemon to other nameservers, the recommended best practice is to change the firewall settings whenever possible. For important security information regarding fixed UDP source ports, refer to Section 19.4.1.1, “Firewall Blocking Communication”

19.7. Additional Resources

The following sources of information provide additional resources regarding BIND.

19.7.1. Installed Documentation

BIND features a full range of installed documentation covering many different topics, each placed in its own subject directory. For each item below, replace <version-number> with the version of bind installed on the system:
/usr/share/doc/bind-<version-number>/
This directory lists the most recent features.
/usr/share/doc/bind-<version-number>/arm/
This directory contains the BIND 9 Administrator Reference Manual in HTML and SGML formats, which details BIND resource requirements, how to configure different types of nameservers, how to perform load balancing, and other advanced topics. For most new users of BIND, this is the best place to start.
/usr/share/doc/bind-<version-number>/draft/
This directory contains assorted technical documents that review issues related to DNS service and propose some methods to address them.
/usr/share/doc/bind-<version-number>/misc/
This directory contains documents designed to address specific advanced issues. Users of BIND version 8 should consult the migration document for specific changes they must make when moving to BIND 9. The options file lists all of the options implemented in BIND 9 that are used in /etc/named.conf.
/usr/share/doc/bind-<version-number>/rfc/
This directory provides every RFC document related to BIND.
There are also a number of man pages for the various applications and configuration files involved with BIND. The following lists some of the more important man pages.
Administrative Applications
  • man rndc — Explains the different options available when using the rndc command to control a BIND nameserver.
Server Applications
  • man named — Explores assorted arguments that can be used to control the BIND nameserver daemon.
  • man lwresd — Describes the purpose of and options available for the lightweight resolver daemon.
Configuration Files
  • man named.conf — A comprehensive list of options available within the named configuration file.
  • man rndc.conf — A comprehensive list of options available within the rndc configuration file.

19.7.2. Useful Websites

19.7.3. Related Books

  • DNS and BIND by Paul Albitz and Cricket Liu; O'Reilly & Associates — A popular reference that explains both common and esoteric BIND configuration options, as well as providing strategies for securing a DNS server.
  • The Concise Guide to DNS and BIND by Nicolai Langfeldt; Que — Looks at the connection between multiple network services and BIND, with an emphasis on task-oriented, technical topics.


[3] The security update was RHSA-2008:0533.

Chapter 20. OpenSSH

SSH™ (or Secure SHell) is a protocol which facilitates secure communications between two systems using a client/server architecture and allows users to log into server host systems remotely. Unlike other remote communication protocols, such as FTP or Telnet, SSH encrypts the login session, rendering the connection difficult for intruders to collect unencrypted passwords.
SSH is designed to replace older, less secure terminal applications used to log into remote hosts, such as telnet or rsh. A related program called scp replaces older programs designed to copy files between hosts, such as rcp. Because these older applications do not encrypt passwords transmitted between the client and the server, avoid them whenever possible. Using secure methods to log into remote systems decreases the risks for both the client system and the remote host.

20.1. Features of SSH

The SSH protocol provides the following safeguards:
  • After an initial connection, the client can verify that it is connecting to the same server it had connected to previously.
  • The client transmits its authentication information to the server using strong, 128-bit encryption.
  • All data sent and received during a session is transferred using 128-bit encryption, making intercepted transmissions extremely difficult to decrypt and read.
  • The client can forward X11[4] applications from the server. This technique, called X11 forwarding, provides a secure means to use graphical applications over a network.
Because the SSH protocol encrypts everything it sends and receives, it can be used to secure otherwise insecure protocols. Using a technique called port forwarding, an SSH server can become a conduit to securing otherwise insecure protocols, like POP, and increasing overall system and data security.
The OpenSSH server and client can also be configured to create a tunnel similar to a virtual private network for traffic between server and client machines.
Finally, OpenSSH servers and clients can be configured to authenticate using the GSSAPI implementation of the Kerberos network authentication protocol. For more information on configuring Kerberos authentication services, refer to Section 48.6, “Kerberos”.
Red Hat Enterprise Linux includes the general OpenSSH package (openssh) as well as the OpenSSH server (openssh-server) and client (openssh-clients) packages. Note, the OpenSSH packages require the OpenSSL package (openssl) which installs several important cryptographic libraries, enabling OpenSSH to provide encrypted communications.

20.1.1. Why Use SSH?

Nefarious computer users have a variety of tools at their disposal enabling them to disrupt, intercept, and re-route network traffic in an effort to gain access to a system. In general terms, these threats can be categorized as follows:
  • Interception of communication between two systems — In this scenario, the attacker can be somewhere on the network between the communicating parties, copying any information passed between them. The attacker may intercept and keep the information, or alter the information and send it on to the intended recipient.
    This attack can be mounted through the use of a packet sniffer — a common network utility.
  • Impersonation of a particular host — Using this strategy, an attacker's system is configured to pose as the intended recipient of a transmission. If this strategy works, the user's system remains unaware that it is communicating with the wrong host.
    This attack can be mounted through techniques known as DNS poisoning[5] or IP spoofing[6].
Both techniques intercept potentially sensitive information and, if the interception is made for hostile reasons, the results can be disastrous.
If SSH is used for remote shell login and file copying, these security threats can be greatly diminished. This is because the SSH client and server use digital signatures to verify their identity. Additionally, all communication between the client and server systems is encrypted. Attempts to spoof the identity of either side of a communication does not work, since each packet is encrypted using a key known only by the local and remote systems.

20.2. SSH Protocol Versions

The SSH protocol allows any client and server programs built to the protocol's specifications to communicate securely and to be used interchangeably.
Two varieties of SSH (version 1 and version 2) currently exist. The OpenSSH suite under Red Hat Enterprise Linux uses SSH version 2 which has an enhanced key exchange algorithm not vulnerable to the exploit in version 1. However, the OpenSSH suite does support version 1 connections.

Important

It is recommended that only SSH version 2-compatible servers and clients are used whenever possible.

20.3. Event Sequence of an SSH Connection

The following series of events help protect the integrity of SSH communication between two hosts.
  1. A cryptographic handshake is made so that the client can verify that it is communicating with the correct server.
  2. The transport layer of the connection between the client and remote host is encrypted using a symmetric cipher.
  3. The client authenticates itself to the server.
  4. The remote client interacts with the remote host over the encrypted connection.

20.3.1. Transport Layer

The primary role of the transport layer is to facilitate safe and secure communication between the two hosts at the time of authentication and during subsequent communication. The transport layer accomplishes this by handling the encryption and decryption of data, and by providing integrity protection of data packets as they are sent and received. The transport layer also provides compression, speeding the transfer of information.
Once an SSH client contacts a server, key information is exchanged so that the two systems can correctly construct the transport layer. The following steps occur during this exchange:
  • Keys are exchanged
  • The public key encryption algorithm is determined
  • The symmetric encryption algorithm is determined
  • The message authentication algorithm is determined
  • The hash algorithm is determined
During the key exchange, the server identifies itself to the client with a unique host key. If the client has never communicated with this particular server before, the server's host key is unknown to the client and it does not connect. OpenSSH gets around this problem by accepting the server's host key. This is done after the user is notified and has both accepted and verified the new host key. In subsequent connections, the server's host key is checked against the saved version on the client, providing confidence that the client is indeed communicating with the intended server. If, in the future, the host key no longer matches, the user must remove the client's saved version before a connection can occur.

Caution

It is possible for an attacker to masquerade as an SSH server during the initial contact since the local system does not know the difference between the intended server and a false one set up by an attacker. To help prevent this, verify the integrity of a new SSH server by contacting the server administrator before connecting for the first time or in the event of a host key mismatch.
SSH is designed to work with almost any kind of public key algorithm or encoding format. After an initial key exchange creates a hash value used for exchanges and a shared secret value, the two systems immediately begin calculating new keys and algorithms to protect authentication and future data sent over the connection.
After a certain amount of data has been transmitted using a given key and algorithm (the exact amount depends on the SSH implementation), another key exchange occurs, generating another set of hash values and a new shared secret value. Even if an attacker is able to determine the hash and shared secret value, this information is only useful for a limited period of time.

20.3.2. Authentication

Once the transport layer has constructed a secure tunnel to pass information between the two systems, the server tells the client the different authentication methods supported, such as using a private key-encoded signature or typing a password. The client then tries to authenticate itself to the server using one of these supported methods.
SSH servers and clients can be configured to allow different types of authentication, which gives each side the optimal amount of control. The server can decide which encryption methods it supports based on its security model, and the client can choose the order of authentication methods to attempt from the available options.

20.3.3. Channels

After a successful authentication over the SSH transport layer, multiple channels are opened via a technique called multiplexing[7]. Each of these channels handles communication for different terminal sessions and for forwarded X11 sessions.
Both clients and servers can create a new channel. Each channel is then assigned a different number on each end of the connection. When the client attempts to open a new channel, the clients sends the channel number along with the request. This information is stored by the server and is used to direct communication to that channel. This is done so that different types of sessions do not affect one another and so that when a given session ends, its channel can be closed without disrupting the primary SSH connection.
Channels also support flow-control, which allows them to send and receive data in an orderly fashion. In this way, data is not sent over the channel until the client receives a message that the channel is open.
The client and server negotiate the characteristics of each channel automatically, depending on the type of service the client requests and the way the user is connected to the network. This allows great flexibility in handling different types of remote connections without having to change the basic infrastructure of the protocol.

20.4. Configuring an OpenSSH Server

To run an OpenSSH server, you must first make sure that you have the proper RPM packages installed. The openssh-server package is required and is dependent on the openssh package.
The OpenSSH daemon uses the configuration file /etc/ssh/sshd_config. The default configuration file should be sufficient for most purposes. If you want to configure the daemon in ways not provided by the default sshd_config, read the sshd man page for a list of the keywords that can be defined in the configuration file.
To start the OpenSSH service, use the command /sbin/service sshd start. To stop the OpenSSH server, use the command /sbin/service sshd stop. If you want the daemon to start automatically at boot time, refer to Chapter 18, Controlling Access to Services for information on how to manage services.
If you reinstall, the reinstalled system creates a new set of identification keys. Any clients who had connected to the system with any of the OpenSSH tools before the reinstall will see the following message:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
If you want to keep the host keys generated for the system, backup the /etc/ssh/ssh_host*key* files and restore them after the reinstall. This process retains the system's identity, and when clients try to connect to the system after the reinstall, they will not receive the warning message.

20.4.1. Requiring SSH for Remote Connections

For SSH to be truly effective, using insecure connection protocols, such as Telnet and FTP, should be prohibited. Otherwise, a user's password may be protected using SSH for one session, only to be captured later while logging in using Telnet.
Some services to disable include:
  • telnet
  • rsh
  • rlogin
  • vsftpd
To disable insecure connection methods to the system, use the command line program chkconfig, the ncurses-based program /usr/sbin/ntsysv, or the Services Configuration Tool (system-config-services) graphical application. All of these tools require root level access.
For more information on runlevels and configuring services with chkconfig, /usr/sbin/ntsysv, and the Services Configuration Tool, refer to Chapter 18, Controlling Access to Services.

20.5. OpenSSH Configuration Files

OpenSSH has two different sets of configuration files: one for client programs (ssh, scp, and sftp) and one for the server daemon (sshd).
System-wide SSH configuration information is stored in the /etc/ssh/ directory:
  • moduli — Contains Diffie-Hellman groups used for the Diffie-Hellman key exchange which is critical for constructing a secure transport layer. When keys are exchanged at the beginning of an SSH session, a shared, secret value is created which cannot be determined by either party alone. This value is then used to provide host authentication.
  • ssh_config — The system-wide default SSH client configuration file. It is overridden if one is also present in the user's home directory (~/.ssh/config).
  • sshd_config — The configuration file for the sshd daemon.
  • ssh_host_dsa_key — The DSA private key used by the sshd daemon.
  • ssh_host_dsa_key.pub — The DSA public key used by the sshd daemon.
  • ssh_host_key — The RSA private key used by the sshd daemon for version 1 of the SSH protocol.
  • ssh_host_key.pub — The RSA public key used by the sshd daemon for version 1 of the SSH protocol.
  • ssh_host_rsa_key — The RSA private key used by the sshd daemon for version 2 of the SSH protocol.
  • ssh_host_rsa_key.pub — The RSA public key used by the sshd for version 2 of the SSH protocol.
User-specific SSH configuration information is stored in the user's home directory within the ~/.ssh/ directory:
  • authorized_keys — This file holds a list of authorized public keys for servers. When the client connects to a server, the server authenticates the client by checking its signed public key stored within this file.
  • id_dsa — Contains the DSA private key of the user.
  • id_dsa.pub — The DSA public key of the user.
  • id_rsa — The RSA private key used by ssh for version 2 of the SSH protocol.
  • id_rsa.pub — The RSA public key used by ssh for version 2 of the SSH protocol
  • identity — The RSA private key used by ssh for version 1 of the SSH protocol.
  • identity.pub — The RSA public key used by ssh for version 1 of the SSH protocol.
  • known_hosts — This file contains DSA host keys of SSH servers accessed by the user. This file is very important for ensuring that the SSH client is connecting the correct SSH server.

    Important

    If an SSH server's host key has changed, the client notifies the user that the connection cannot proceed until the server's host key is deleted from the known_hosts file using a text editor. Before doing this, however, contact the system administrator of the SSH server to verify the server is not compromised.
Refer to the ssh_config and sshd_config man pages for information concerning the various directives available in the SSH configuration files.

20.6. Configuring an OpenSSH Client

To connect to an OpenSSH server from a client machine, you must have the openssh-clients and openssh packages installed on the client machine.

20.6.1. Using the ssh Command

The ssh command is a secure replacement for the rlogin,