Red Hat ENTERPRISE LINUX 5 - DEPLOYMENT Deployment Manual

Page 1
Red Hat Enterprise Linux 5
Deployment Guide
Deployment, configuration and
administration of Red Hat Enterprise Linux 5
Deployment_Guide
Page 2
Deployment Guide
Copyright © 2007, 2008, 2009, 2010 Red Hat Inc..
The text of and illustrations in this document are licensed by Red Hat under a Creative Commons Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available at http://creativecommons.org/licenses/by-sa/3.0/. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version.
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.
All other trademarks are the property of their respective owners.
1801 Varsity Drive Raleigh, NC 27606-2072 USA Phone: +1 919 754 3700 Phone: 888 733 4281 Fax: +1 919 754 3701 PO Box 13588 Research Triangle Park, NC 27709 USA
The Deployment Guide documents relevant information reegarding the deployment, configuration and administration of Red Hat Enterprise Linux 5.
Page 3
iii
Introduction xxiii
1. Document Conventions ................................................................................................ xxiii
2. Send in Your Feedback ............................................................................................... xxvi
I. File Systems 1
1. File System Structure 3
1.1. Why Share a Common Structure? ......................................................................... 3
1.2. Overview of File System Hierarchy Standard (FHS) ................................................ 3
1.2.1. FHS Organization ...................................................................................... 3
1.3. Special File Locations Under Red Hat Enterprise Linux .......................................... 8
2. The ext3 File System 11
2.1. Features of ext3 ................................................................................................. 11
2.2. Creating an ext3 File System .............................................................................. 11
2.3. Converting to an ext3 File System ....................................................................... 12
2.4. Reverting to an ext2 File System ........................................................................ 12
3. The proc File System 15
3.1. A Virtual File System .......................................................................................... 15
3.1.1. Viewing Virtual Files ................................................................................ 15
3.1.2. Changing Virtual Files .............................................................................. 16
3.2. Top-level Files within the proc File System ......................................................... 16
3.2.1. /proc/apm ............................................................................................. 16
3.2.2. /proc/buddyinfo ................................................................................. 17
3.2.3. /proc/cmdline ..................................................................................... 17
3.2.4. /proc/cpuinfo ..................................................................................... 18
3.2.5. /proc/crypto ....................................................................................... 19
3.2.6. /proc/devices ..................................................................................... 19
3.2.7. /proc/dma ............................................................................................. 20
3.2.8. /proc/execdomains ............................................................................. 20
3.2.9. /proc/fb ............................................................................................... 21
3.2.10. /proc/filesystems ........................................................................... 21
3.2.11. /proc/interrupts ............................................................................. 21
3.2.12. /proc/iomem ....................................................................................... 22
3.2.13. /proc/ioports ................................................................................... 23
3.2.14. /proc/kcore ....................................................................................... 23
3.2.15. /proc/kmsg ......................................................................................... 23
3.2.16. /proc/loadavg ................................................................................... 24
3.2.17. /proc/locks ....................................................................................... 24
3.2.18. /proc/mdstat ..................................................................................... 24
3.2.19. /proc/meminfo ................................................................................... 25
3.2.20. /proc/misc ......................................................................................... 26
3.2.21. /proc/modules ................................................................................... 27
3.2.22. /proc/mounts ..................................................................................... 27
3.2.23. /proc/mtrr ......................................................................................... 28
3.2.24. /proc/partitions ............................................................................. 28
3.2.25. /proc/pci ........................................................................................... 29
3.2.26. /proc/slabinfo ................................................................................. 29
3.2.27. /proc/stat ......................................................................................... 30
3.2.28. /proc/swaps ....................................................................................... 31
3.2.29. /proc/sysrq-trigger ....................................................................... 32
Page 4
Deployment Guide
iv
3.2.30. /proc/uptime ..................................................................................... 32
3.2.31. /proc/version ................................................................................... 32
3.3. Directories within /proc/ ................................................................................... 32
3.3.1. Process Directories .................................................................................. 32
3.3.2. /proc/bus/ ........................................................................................... 34
3.3.3. /proc/driver/ ..................................................................................... 35
3.3.4. /proc/fs ............................................................................................... 36
3.3.5. /proc/ide/ ........................................................................................... 36
3.3.6. /proc/irq/ ........................................................................................... 37
3.3.7. /proc/net/ ........................................................................................... 37
3.3.8. /proc/scsi/ ......................................................................................... 38
3.3.9. /proc/sys/ ........................................................................................... 40
3.3.10. /proc/sysvipc/ ................................................................................. 51
3.3.11. /proc/tty/ ......................................................................................... 51
3.4. Using the sysctl Command .............................................................................. 51
3.5. Additional Resources .......................................................................................... 52
3.5.1. Installed Documentation ........................................................................... 52
3.5.2. Useful Websites ...................................................................................... 52
4. Redundant Array of Independent Disks (RAID) 53
4.1. What is RAID? ................................................................................................... 53
4.2. Who Should Use RAID? ..................................................................................... 53
4.3. Hardware RAID versus Software RAID ................................................................ 53
4.3.1. Hardware RAID ....................................................................................... 53
4.3.2. Software RAID ........................................................................................ 54
4.4. RAID Levels and Linear Support ......................................................................... 54
4.5. Configuring Software RAID ................................................................................. 55
4.5.1. Creating the RAID Partitions .................................................................... 56
4.5.2. Creating the RAID Devices and Mount Points ............................................ 59
5. Swap Space 65
5.1. What is Swap Space? ........................................................................................ 65
5.2. Adding Swap Space ........................................................................................... 65
5.2.1. Extending Swap on an LVM2 Logical Volume ............................................ 66
5.2.2. Creating an LVM2 Logical Volume for Swap .............................................. 66
5.2.3. Creating a Swap File ............................................................................... 67
5.3. Removing Swap Space ...................................................................................... 67
5.3.1. Reducing Swap on an LVM2 Logical Volume ............................................ 68
5.3.2. Removing an LVM2 Logical Volume for Swap ........................................... 68
5.3.3. Removing a Swap File ............................................................................. 69
5.4. Moving Swap Space ........................................................................................... 69
6. Managing Disk Storage 71
6.1. Standard Partitions using parted ....................................................................... 71
6.1.1. Viewing the Partition Table ....................................................................... 72
6.1.2. Creating a Partition .................................................................................. 73
6.1.3. Removing a Partition ............................................................................... 75
6.1.4. Resizing a Partition .................................................................................. 76
6.2. LVM Partition Management ................................................................................. 77
7. Implementing Disk Quotas 79
7.1. Configuring Disk Quotas ..................................................................................... 79
7.1.1. Enabling Quotas ...................................................................................... 79
Page 5
v
7.1.2. Remounting the File Systems ................................................................... 80
7.1.3. Creating the Quota Database Files ........................................................... 80
7.1.4. Assigning Quotas per User ...................................................................... 81
7.1.5. Assigning Quotas per Group .................................................................... 82
7.1.6. Setting the Grace Period for Soft Limits .................................................... 82
7.2. Managing Disk Quotas ....................................................................................... 82
7.2.1. Enabling and Disabling ............................................................................ 83
7.2.2. Reporting on Disk Quotas ........................................................................ 83
7.2.3. Keeping Quotas Accurate ......................................................................... 84
7.3. Additional Resources .......................................................................................... 84
7.3.1. Installed Documentation ........................................................................... 84
7.3.2. Related Books ......................................................................................... 84
8. Access Control Lists 85
8.1. Mounting File Systems ....................................................................................... 85
8.1.1. NFS ........................................................................................................ 85
8.2. Setting Access ACLs .......................................................................................... 85
8.3. Setting Default ACLs .......................................................................................... 86
8.4. Retrieving ACLs ................................................................................................. 87
8.5. Archiving File Systems With ACLs ....................................................................... 87
8.6. Compatibility with Older Systems ........................................................................ 88
8.7. Additional Resources .......................................................................................... 88
8.7.1. Installed Documentation ........................................................................... 88
8.7.2. Useful Websites ...................................................................................... 89
9. LVM (Logical Volume Manager) 91
9.1. What is LVM? .................................................................................................... 91
9.1.1. What is LVM2? ........................................................................................ 92
9.2. LVM Configuration .............................................................................................. 92
9.3. Automatic Partitioning ......................................................................................... 93
9.4. Manual LVM Partitioning ..................................................................................... 94
9.4.1. Creating the /boot/ Partition .................................................................. 94
9.4.2. Creating the LVM Physical Volumes ......................................................... 97
9.4.3. Creating the LVM Volume Groups ............................................................ 99
9.4.4. Creating the LVM Logical Volumes ......................................................... 100
9.5. Using the LVM utility system-config-lvm ...................................................... 103
9.5.1. Utilizing uninitialized entities ................................................................... 106
9.5.2. Adding Unallocated Volumes to a volume group ...................................... 107
9.5.3. Migrating extents ................................................................................... 109
9.5.4. Adding a new hard disk using LVM ......................................................... 111
9.5.5. Adding a new volume group ................................................................... 112
9.5.6. Extending a volume group ...................................................................... 114
9.5.7. Editing a Logical Volume ........................................................................ 115
9.6. Additional Resources ........................................................................................ 117
9.6.1. Installed Documentation ......................................................................... 117
9.6.2. Useful Websites ..................................................................................... 117
II. Package Management 119
10. Package Management with RPM 121
10.1. RPM Design Goals ......................................................................................... 121
10.2. Using RPM ..................................................................................................... 122
Page 6
Deployment Guide
vi
10.2.1. Finding RPM Packages ........................................................................ 122
10.2.2. Installing .............................................................................................. 122
10.2.3. Uninstalling .......................................................................................... 124
10.2.4. Upgrading ............................................................................................ 125
10.2.5. Freshening .......................................................................................... 126
10.2.6. Querying .............................................................................................. 126
10.2.7. Verifying .............................................................................................. 127
10.3. Checking a Package's Signature ..................................................................... 128
10.3.1. Importing Keys ..................................................................................... 128
10.3.2. Verifying Signature of Packages ........................................................... 129
10.4. Practical and Common Examples of RPM Usage .............................................. 129
10.5. Additional Resources ...................................................................................... 131
10.5.1. Installed Documentation ....................................................................... 131
10.5.2. Useful Websites ................................................................................... 131
10.5.3. Related Books ..................................................................................... 131
11. Package Management Tool 133
11.1. Listing and Analyzing Packages ...................................................................... 133
11.2. Installing and Removing Packages .................................................................. 134
12. YUM (Yellowdog Updater Modified) 141
12.1. Setting Up a yum Repository ........................................................................... 141
12.2. yum Commands .............................................................................................. 141
12.3. yum Options ................................................................................................... 142
12.4. Configuring yum .............................................................................................. 142
12.4.1. [main] Options .................................................................................. 143
12.4.2. [repository] Options ....................................................................... 144
12.5. Useful yum Variables ...................................................................................... 145
13. Red Hat Network 147
III. Network-Related Configuration 151
14. Network Interfaces 153
14.1. Network Configuration Files ............................................................................. 153
14.2. Interface Configuration Files ............................................................................ 154
14.2.1. Ethernet Interfaces ............................................................................... 154
14.2.2. IPsec Interfaces ................................................................................... 157
14.2.3. Channel Bonding Interfaces .................................................................. 158
14.2.4. Alias and Clone Files ........................................................................... 159
14.2.5. Dialup Interfaces .................................................................................. 160
14.2.6. Other Interfaces ................................................................................... 161
14.3. Interface Control Scripts .................................................................................. 162
14.4. Configuring Static Routes ................................................................................ 164
14.5. Network Function Files .................................................................................... 166
14.6. Additional Resources ...................................................................................... 166
14.6.1. Installed Documentation ....................................................................... 166
15. Network Configuration 167
15.1. Overview ........................................................................................................ 168
15.2. Establishing an Ethernet Connection ................................................................ 169
15.3. Establishing an ISDN Connection .................................................................... 172
15.4. Establishing a Modem Connection ................................................................... 173
Page 7
vii
15.5. Establishing an xDSL Connection .................................................................... 175
15.6. Establishing a Token Ring Connection ............................................................. 181
15.7. Establishing a Wireless Connection ................................................................. 183
15.8. Managing DNS Settings .................................................................................. 186
15.9. Managing Hosts .............................................................................................. 187
15.10. Working with Profiles .................................................................................... 189
15.11. Device Aliases .............................................................................................. 192
15.12. Saving and Restoring the Network Configuration ............................................. 194
16. Controlling Access to Services 195
16.1. Runlevels ....................................................................................................... 196
16.2. TCP Wrappers ................................................................................................ 196
16.2.1. xinetd ............................................................................................... 196
16.3. Services Configuration Tool ......................................................................... 197
16.4. ntsysv ........................................................................................................... 199
16.5. chkconfig .................................................................................................... 201
16.6. Additional Resources ...................................................................................... 201
16.6.1. Installed Documentation ....................................................................... 201
16.6.2. Useful Websites ................................................................................... 201
17. Berkeley Internet Name Domain (BIND) 203
17.1. Introduction to DNS ........................................................................................ 203
17.1.1. Nameserver Zones ............................................................................... 203
17.1.2. Nameserver Types ............................................................................... 204
17.1.3. BIND as a Nameserver ........................................................................ 204
17.2. /etc/named.conf ........................................................................................ 205
17.2.1. Common Statement Types ................................................................... 205
17.2.2. Other Statement Types ........................................................................ 210
17.2.3. Comment Tags .................................................................................... 211
17.3. Zone Files ...................................................................................................... 212
17.3.1. Zone File Directives ............................................................................. 212
17.3.2. Zone File Resource Records ................................................................ 213
17.3.3. Example Zone File ............................................................................... 216
17.3.4. Reverse Name Resolution Zone Files ................................................... 217
17.4. Using rndc .................................................................................................... 218
17.4.1. Configuring /etc/named.conf ........................................................... 218
17.4.2. Configuring /etc/rndc.conf ............................................................. 219
17.4.3. Command Line Options ........................................................................ 220
17.5. Advanced Features of BIND ............................................................................ 220
17.5.1. DNS Protocol Enhancements ................................................................ 221
17.5.2. Multiple Views ...................................................................................... 221
17.5.3. Security ............................................................................................... 221
17.5.4. IP version 6 ......................................................................................... 222
17.6. Common Mistakes to Avoid ............................................................................. 222
17.7. Additional Resources ...................................................................................... 223
17.7.1. Installed Documentation ....................................................................... 223
17.7.2. Useful Websites ................................................................................... 224
17.7.3. Related Books ..................................................................................... 224
18. OpenSSH 225
18.1. Features of SSH ............................................................................................. 225
18.1.1. Why Use SSH? ................................................................................... 225
18.2. SSH Protocol Versions .................................................................................... 226
Page 8
Deployment Guide
viii
18.3. Event Sequence of an SSH Connection ........................................................... 226
18.3.1. Transport Layer ................................................................................... 226
18.3.2. Authentication ...................................................................................... 227
18.3.3. Channels ............................................................................................. 228
18.4. Configuring an OpenSSH Server ..................................................................... 228
18.4.1. Requiring SSH for Remote Connections ................................................ 229
18.5. OpenSSH Configuration Files .......................................................................... 229
18.6. Configuring an OpenSSH Client ...................................................................... 230
18.6.1. Using the ssh Command ..................................................................... 230
18.6.2. Using the scp Command ..................................................................... 231
18.6.3. Using the sftp Command ................................................................... 232
18.7. More Than a Secure Shell .............................................................................. 232
18.7.1. X11 Forwarding ................................................................................... 232
18.7.2. Port Forwarding ................................................................................... 233
18.7.3. Generating Key Pairs ........................................................................... 234
18.8. Additional Resources ...................................................................................... 237
18.8.1. Installed Documentation ....................................................................... 237
18.8.2. Useful Websites ................................................................................... 237
19. Network File System (NFS) 239
19.1. How It Works ................................................................................................. 239
19.1.1. Required Services ................................................................................ 240
19.2. NFS Client Configuration ................................................................................. 241
19.2.1. Mounting NFS File Systems using /etc/fstab .................................... 241
19.3. autofs .......................................................................................................... 242
19.3.1. What's new in autofs version 5? ......................................................... 242
19.3.2. autofs Configuration .......................................................................... 243
19.3.3. autofs Common Tasks ....................................................................... 244
19.4. Common NFS Mount Options .......................................................................... 248
19.5. Starting and Stopping NFS .............................................................................. 249
19.6. NFS Server Configuration ............................................................................... 250
19.6.1. Exporting or Sharing NFS File Systems ................................................. 251
19.6.2. Command Line Configuration ................................................................ 255
19.6.3. Running NFS Behind a Firewall ............................................................ 256
19.6.4. Hostname Formats ............................................................................... 256
19.7. The /etc/exports Configuration File ............................................................ 256
19.7.1. The exportfs Command .................................................................... 258
19.8. Securing NFS ................................................................................................. 260
19.8.1. Host Access ........................................................................................ 260
19.8.2. File Permissions .................................................................................. 261
19.9. NFS and portmap ......................................................................................... 262
19.9.1. Troubleshooting NFS and portmap ...................................................... 262
19.10. Using NFS over TCP .................................................................................... 263
19.11. Additional Resources .................................................................................... 264
19.11.1. Installed Documentation ...................................................................... 264
19.11.2. Useful Websites ................................................................................. 264
19.11.3. Related Books ................................................................................... 264
20. Samba 265
20.1. Introduction to Samba ..................................................................................... 265
20.1.1. Samba Features .................................................................................. 265
20.2. Samba Daemons and Related Services ........................................................... 265
Page 9
ix
20.2.1. Samba Daemons ................................................................................. 266
20.3. Connecting to a Samba Share ......................................................................... 266
20.3.1. Command Line .................................................................................... 268
20.3.2. Mounting the Share .............................................................................. 269
20.4. Configuring a Samba Server ........................................................................... 269
20.4.1. Graphical Configuration ........................................................................ 269
20.4.2. Command Line Configuration ................................................................ 274
20.4.3. Encrypted Passwords ........................................................................... 274
20.5. Starting and Stopping Samba .......................................................................... 274
20.6. Samba Server Types and the smb.conf File ................................................... 275
20.6.1. Stand-alone Server .............................................................................. 276
20.6.2. Domain Member Server ....................................................................... 278
20.6.3. Domain Controller ................................................................................ 280
20.7. Samba Security Modes ................................................................................... 281
20.7.1. User-Level Security .............................................................................. 281
20.7.2. Share-Level Security ............................................................................ 283
20.8. Samba Account Information Databases ............................................................ 283
20.9. Samba Network Browsing ............................................................................... 284
20.9.1. Domain Browsing ................................................................................. 284
20.9.2. WINS (Windows Internetworking Name Server) ...................................... 285
20.10. Samba with CUPS Printing Support ............................................................... 285
20.10.1. Simple smb.conf Settings ................................................................. 285
20.11. Samba Distribution Programs ........................................................................ 286
20.12. Additional Resources .................................................................................... 290
20.12.1. Installed Documentation ...................................................................... 290
20.12.2. Related Books ................................................................................... 290
20.12.3. Useful Websites ................................................................................. 291
21. Dynamic Host Configuration Protocol (DHCP) 293
21.1. Why Use DHCP? ............................................................................................ 293
21.2. Configuring a DHCP Server ............................................................................ 293
21.2.1. Configuration File ................................................................................. 293
21.2.2. Lease Database ................................................................................... 297
21.2.3. Starting and Stopping the Server .......................................................... 297
21.2.4. DHCP Relay Agent .............................................................................. 298
21.3. Configuring a DHCP Client .............................................................................. 298
21.4. Configuring a Multihomed DHCP Server .......................................................... 299
21.4.1. Host Configuration ............................................................................... 301
21.5. Additional Resources ...................................................................................... 303
21.5.1. Installed Documentation ....................................................................... 303
22. Apache HTTP Server 305
22.1. Apache HTTP Server 2.2 ................................................................................ 305
22.1.1. Features of Apache HTTP Server 2.2 .................................................... 305
22.2. Migrating Apache HTTP Server Configuration Files ........................................... 306
22.2.1. Migrating Apache HTTP Server 2.0 Configuration Files ........................... 306
22.2.2. Migrating Apache HTTP Server 1.3 Configuration Files to 2.0 .................. 306
22.3. Starting and Stopping httpd .......................................................................... 316
22.4. Apache HTTP Server Configuration ................................................................. 317
22.4.1. Basic Settings ...................................................................................... 318
22.4.2. Default Settings ................................................................................... 320
22.5. Configuration Directives in httpd.conf .......................................................... 331
Page 10
Deployment Guide
x
22.5.1. General Configuration Tips ................................................................... 331
22.5.2. Configuration Directives for SSL ........................................................... 345
22.5.3. MPM Specific Server-Pool Directives ..................................................... 345
22.6. Adding Modules .............................................................................................. 347
22.7. Virtual Hosts ................................................................................................... 347
22.7.1. Setting Up Virtual Hosts ....................................................................... 347
22.8. Apache HTTP Secure Server Configuration ...................................................... 348
22.8.1. An Overview of Security-Related Packages ........................................... 349
22.8.2. An Overview of Certificates and Security ............................................... 349
22.8.3. Using Pre-Existing Keys and Certificates ............................................... 350
22.8.4. Types of Certificates ............................................................................ 350
22.8.5. Generating a Key ................................................................................. 352
22.8.6. How to configure the server to use the new key ..................................... 360
22.9. Additional Resources ...................................................................................... 360
22.9.1. Useful Websites ................................................................................... 361
23. FTP 363
23.1. The File Transfer Protocol ............................................................................... 363
23.1.1. Multiple Ports, Multiple Modes .............................................................. 363
23.2. FTP Servers ................................................................................................... 363
23.2.1. vsftpd ............................................................................................... 364
23.3. Files Installed with vsftpd ............................................................................. 364
23.4. Starting and Stopping vsftpd ........................................................................ 365
23.4.1. Starting Multiple Copies of vsftpd ....................................................... 366
23.5. vsftpd Configuration Options ......................................................................... 367
23.5.1. Daemon Options .................................................................................. 367
23.5.2. Log In Options and Access Controls ..................................................... 368
23.5.3. Anonymous User Options ..................................................................... 369
23.5.4. Local User Options .............................................................................. 370
23.5.5. Directory Options ................................................................................. 371
23.5.6. File Transfer Options ............................................................................ 372
23.5.7. Logging Options ................................................................................... 372
23.5.8. Network Options .................................................................................. 373
23.6. Additional Resources ...................................................................................... 375
23.6.1. Installed Documentation ....................................................................... 376
23.6.2. Useful Websites ................................................................................... 376
24. Email 377
24.1. Email Protocols .............................................................................................. 377
24.1.1. Mail Transport Protocols ....................................................................... 377
24.1.2. Mail Access Protocols .......................................................................... 378
24.2. Email Program Classifications ......................................................................... 380
24.2.1. Mail Transport Agent ............................................................................ 380
24.2.2. Mail Delivery Agent .............................................................................. 380
24.2.3. Mail User Agent ................................................................................... 380
24.3. Mail Transport Agents ..................................................................................... 381
24.3.1. Sendmail ............................................................................................. 381
24.3.2. Postfix ................................................................................................. 385
24.3.3. Fetchmail ............................................................................................. 387
24.4. Mail Transport Agent (MTA) Configuration ........................................................ 390
24.5. Mail Delivery Agents ....................................................................................... 392
24.5.1. Procmail Configuration ......................................................................... 392
Page 11
xi
24.5.2. Procmail Recipes ................................................................................. 393
24.6. Mail User Agents ............................................................................................ 398
24.6.1. Securing Communication ...................................................................... 398
24.7. Additional Resources ...................................................................................... 400
24.7.1. Installed Documentation ....................................................................... 400
24.7.2. Useful Websites ................................................................................... 401
24.7.3. Related Books ..................................................................................... 401
25. Lightweight Directory Access Protocol (LDAP) 403
25.1. Why Use LDAP? ............................................................................................ 403
25.1.1. OpenLDAP Features ............................................................................ 403
25.2. LDAP Terminology .......................................................................................... 404
25.3. OpenLDAP Daemons and Utilities ................................................................... 405
25.3.1. NSS, PAM, and LDAP .......................................................................... 406
25.3.2. PHP4, LDAP, and the Apache HTTP Server .......................................... 407
25.3.3. LDAP Client Applications ...................................................................... 407
25.4. OpenLDAP Configuration Files ........................................................................ 407
25.5. The /etc/openldap/schema/ Directory ....................................................... 408
25.6. OpenLDAP Setup Overview ............................................................................ 409
25.6.1. Editing /etc/openldap/slapd.conf ................................................ 409
25.7. Configuring a System to Authenticate Using OpenLDAP .................................... 410
25.7.1. PAM and LDAP ................................................................................... 411
25.7.2. Migrating Old Authentication Information to LDAP Format ....................... 411
25.8. Migrating Directories from Earlier Releases ...................................................... 412
25.9. Additional Resources ...................................................................................... 413
25.9.1. Installed Documentation ....................................................................... 413
25.9.2. Useful Websites ................................................................................... 414
25.9.3. Related Books ..................................................................................... 414
26. Authentication Configuration 415
26.1. User Information ............................................................................................. 415
26.2. Authentication ................................................................................................. 418
26.3. Options .......................................................................................................... 420
26.4. Command Line Version ................................................................................... 422
IV. System Configuration 425
27. Console Access 427
27.1. Disabling Shutdown Via Ctrl+Alt+Del .......................................................... 427
27.2. Disabling Console Program Access ................................................................. 428
27.3. Defining the Console ...................................................................................... 428
27.4. Making Files Accessible From the Console ...................................................... 428
27.5. Enabling Console Access for Other Applications ............................................... 429
27.6. The floppy Group ......................................................................................... 430
28. The sysconfig Directory 433
28.1. Files in the /etc/sysconfig/ Directory ........................................................ 433
28.1.1. /etc/sysconfig/amd ....................................................................... 433
28.1.2. /etc/sysconfig/apmd ..................................................................... 433
28.1.3. /etc/sysconfig/arpwatch ............................................................. 433
28.1.4. /etc/sysconfig/authconfig .......................................................... 433
28.1.5. /etc/sysconfig/autofs ................................................................. 434
28.1.6. /etc/sysconfig/clock ................................................................... 434
Page 12
Deployment Guide
xii
28.1.7. /etc/sysconfig/desktop ............................................................... 435
28.1.8. /etc/sysconfig/dhcpd ................................................................... 435
28.1.9. /etc/sysconfig/exim ..................................................................... 436
28.1.10. /etc/sysconfig/firstboot .......................................................... 436
28.1.11. /etc/sysconfig/gpm ...................................................................... 436
28.1.12. /etc/sysconfig/hwconf ................................................................ 436
28.1.13. /etc/sysconfig/i18n .................................................................... 436
28.1.14. /etc/sysconfig/init .................................................................... 437
28.1.15. /etc/sysconfig/ip6tables-config ............................................ 437
28.1.16. /etc/sysconfig/iptables-config .............................................. 438
28.1.17. /etc/sysconfig/irda .................................................................... 438
28.1.18. /etc/sysconfig/keyboard ............................................................ 439
28.1.19. /etc/sysconfig/kudzu .................................................................. 439
28.1.20. /etc/sysconfig/named .................................................................. 439
28.1.21. /etc/sysconfig/network .............................................................. 439
28.1.22. /etc/sysconfig/nfs ...................................................................... 440
28.1.23. /etc/sysconfig/ntpd .................................................................... 441
28.1.24. /etc/sysconfig/radvd .................................................................. 441
28.1.25. /etc/sysconfig/samba .................................................................. 441
28.1.26. /etc/sysconfig/selinux .............................................................. 441
28.1.27. /etc/sysconfig/sendmail ............................................................ 441
28.1.28. /etc/sysconfig/spamassassin .................................................... 442
28.1.29. /etc/sysconfig/squid .................................................................. 442
28.1.30. /etc/sysconfig/system-config-securitylevel ...................... 442
28.1.31. /etc/sysconfig/system-config-selinux .................................. 442
28.1.32. /etc/sysconfig/system-config-users ...................................... 442
28.1.33. /etc/sysconfig/system-logviewer ............................................ 442
28.1.34. /etc/sysconfig/tux ...................................................................... 443
28.1.35. /etc/sysconfig/vncservers ........................................................ 443
28.1.36. /etc/sysconfig/xinetd ................................................................ 443
28.2. Directories in the /etc/sysconfig/ Directory ................................................ 443
28.3. Additional Resources ...................................................................................... 444
28.3.1. Installed Documentation ....................................................................... 444
29. Date and Time Configuration 445
29.1. Time and Date Properties ............................................................................... 445
29.2. Network Time Protocol (NTP) Properties .......................................................... 447
29.3. Time Zone Configuration ................................................................................. 448
30. Keyboard Configuration 451
31. The X Window System 453
31.1. The X11R7.1 Release ..................................................................................... 453
31.2. Desktop Environments and Window Managers ................................................. 454
31.2.1. Desktop Environments .......................................................................... 454
31.2.2. Window Managers ............................................................................... 454
31.3. X Server Configuration Files ............................................................................ 455
31.3.1. xorg.conf ......................................................................................... 456
31.4. Fonts ............................................................................................................. 462
31.4.1. Fontconfig ............................................................................................ 462
31.4.2. Core X Font System ............................................................................ 464
31.5. Runlevels and X ............................................................................................. 465
31.5.1. Runlevel 3 ........................................................................................... 465
Page 13
xiii
31.5.2. Runlevel 5 ........................................................................................... 466
31.6. Additional Resources ...................................................................................... 467
31.6.1. Installed Documentation ....................................................................... 467
31.6.2. Useful Websites ................................................................................... 467
32. X Window System Configuration 469
32.1. Display Settings .............................................................................................. 469
32.2. Display Hardware Settings .............................................................................. 470
32.3. Dual Head Display Settings ............................................................................. 470
33. Users and Groups 473
33.1. User and Group Configuration ......................................................................... 473
33.1.1. Adding a New User .............................................................................. 474
33.1.2. Modifying User Properties ..................................................................... 476
33.1.3. Adding a New Group ............................................................................ 478
33.1.4. Modifying Group Properties .................................................................. 478
33.2. User and Group Management Tools ................................................................ 479
33.2.1. Command Line Configuration ................................................................ 479
33.2.2. Adding a User ..................................................................................... 479
33.2.3. Adding a Group ................................................................................... 480
33.2.4. Password Aging ................................................................................... 480
33.2.5. Explaining the Process ......................................................................... 483
33.3. Standard Users .............................................................................................. 484
33.4. Standard Groups ............................................................................................ 485
33.5. User Private Groups ....................................................................................... 487
33.5.1. Group Directories ................................................................................. 488
33.6. Shadow Passwords ........................................................................................ 488
33.7. Additional Resources ...................................................................................... 489
33.7.1. Installed Documentation ....................................................................... 489
34. Printer Configuration 491
34.1. Adding a Local Printer .................................................................................... 492
34.2. Adding an IPP Printer ..................................................................................... 493
34.3. Adding a Samba (SMB) Printer ....................................................................... 494
34.4. Adding a JetDirect Printer ............................................................................... 496
34.5. Selecting the Printer Model and Finishing ......................................................... 497
34.5.1. Confirming Printer Configuration ........................................................... 497
34.6. Printing a Test Page ....................................................................................... 498
34.7. Modifying Existing Printers .............................................................................. 498
34.7.1. The Settings Tab ................................................................................ 498
34.7.2. The Policies Tab ................................................................................. 499
34.7.3. The Access Control Tab ..................................................................... 499
34.7.4. The Printer and Job OptionsTab ......................................................... 500
34.8. Managing Print Jobs ....................................................................................... 501
34.9. Additional Resources ...................................................................................... 502
34.9.1. Installed Documentation ....................................................................... 502
34.9.2. Useful Websites ................................................................................... 503
35. Automated Tasks 505
35.1. Cron ............................................................................................................... 505
35.1.1. Configuring Cron Tasks ........................................................................ 505
35.1.2. Controlling Access to Cron ................................................................... 507
35.1.3. Starting and Stopping the Service ......................................................... 507
Page 14
Deployment Guide
xiv
35.2. At and Batch .................................................................................................. 507
35.2.1. Configuring At Jobs .............................................................................. 507
35.2.2. Configuring Batch Jobs ........................................................................ 508
35.2.3. Viewing Pending Jobs .......................................................................... 508
35.2.4. Additional Command Line Options ........................................................ 508
35.2.5. Controlling Access to At and Batch ....................................................... 509
35.2.6. Starting and Stopping the Service ......................................................... 509
35.3. Additional Resources ...................................................................................... 509
35.3.1. Installed Documentation ....................................................................... 509
36. Log Files 511
36.1. Locating Log Files .......................................................................................... 511
36.2. Viewing Log Files ........................................................................................... 511
36.3. Adding a Log File ........................................................................................... 514
36.4. Monitoring Log Files ....................................................................................... 515
V. System Monitoring 519
37. SystemTap 521
37.1. Introduction .................................................................................................... 521
37.2. Implementation ............................................................................................... 521
37.3. Using SystemTap ........................................................................................... 522
37.3.1. Tracing ............................................................................................... 522
38. Gathering System Information 525
38.1. System Processes .......................................................................................... 525
38.2. Memory Usage ............................................................................................... 527
38.3. File Systems .................................................................................................. 529
38.4. Hardware ....................................................................................................... 531
38.5. Additional Resources ...................................................................................... 534
38.5.1. Installed Documentation ....................................................................... 534
39. OProfile 535
39.1. Overview of Tools ........................................................................................... 535
39.2. Configuring OProfile ........................................................................................ 536
39.2.1. Specifying the Kernel ........................................................................... 536
39.2.2. Setting Events to Monitor ..................................................................... 537
39.2.3. Separating Kernel and User-space Profiles ............................................ 539
39.3. Starting and Stopping OProfile ........................................................................ 540
39.4. Saving Data ................................................................................................... 540
39.5. Analyzing the Data ......................................................................................... 541
39.5.1. Using opreport ................................................................................. 541
39.5.2. Using opreport on a Single Executable .............................................. 542
39.5.3. Getting more detailed output on the modules ......................................... 544
39.5.4. Using opannotate .............................................................................. 545
39.6. Understanding /dev/oprofile/ ................................................................... 545
39.7. Example Usage .............................................................................................. 546
39.8. Graphical Interface .......................................................................................... 546
39.9. Additional Resources ...................................................................................... 548
39.9.1. Installed Docs ...................................................................................... 548
39.9.2. Useful Websites ................................................................................... 548
VI. Kernel and Driver Configuration 549
Page 15
xv
40. Manually Upgrading the Kernel 551
40.1. Overview of Kernel Packages .......................................................................... 551
40.2. Preparing to Upgrade ...................................................................................... 552
40.3. Downloading the Upgraded Kernel ................................................................... 553
40.4. Performing the Upgrade .................................................................................. 553
40.5. Verifying the Initial RAM Disk Image ................................................................ 554
40.6. Verifying the Boot Loader ................................................................................ 554
40.6.1. x86 Systems ........................................................................................ 554
40.6.2. Itanium Systems .................................................................................. 555
40.6.3. IBM S/390 and IBM System z Systems ................................................. 556
40.6.4. IBM eServer iSeries Systems ............................................................... 556
40.6.5. IBM eServer pSeries Systems .............................................................. 556
41. General Parameters and Modules 559
41.1. Kernel Module Utilities .................................................................................... 559
41.2. Persistent Module Loading .............................................................................. 561
41.3. Specifying Module Parameters ........................................................................ 562
41.4. Storage parameters ........................................................................................ 562
41.5. Ethernet Parameters ....................................................................................... 567
41.5.1. Using Multiple Ethernet Cards .............................................................. 574
41.5.2. The Channel Bonding Module ............................................................... 574
41.6. Additional Resources ...................................................................................... 580
41.6.1. Installed Documentation ....................................................................... 580
41.6.2. Useful Websites ................................................................................... 580
VII. Security And Authentication 581
42. Security Overview 583
42.1. Introduction to Security ................................................................................... 583
42.1.1. What is Computer Security? ................................................................. 583
42.1.2. Security Controls .................................................................................. 585
42.1.3. Conclusion ........................................................................................... 586
42.2. Vulnerability Assessment ................................................................................. 586
42.2.1. Thinking Like the Enemy ...................................................................... 586
42.2.2. Defining Assessment and Testing ......................................................... 587
42.2.3. Evaluating the Tools ............................................................................. 588
42.3. Attackers and Vulnerabilities ............................................................................ 591
42.3.1. A Quick History of Hackers ................................................................... 591
42.3.2. Threats to Network Security .................................................................. 592
42.3.3. Threats to Server Security .................................................................... 592
42.3.4. Threats to Workstation and Home PC Security ....................................... 594
42.4. Common Exploits and Attacks ......................................................................... 595
42.5. Security Updates ............................................................................................ 597
42.5.1. Updating Packages .............................................................................. 598
43. Securing Your Network 603
43.1. Workstation Security ....................................................................................... 603
43.1.1. Evaluating Workstation Security ............................................................ 603
43.1.2. BIOS and Boot Loader Security ............................................................ 603
43.1.3. Password Security ............................................................................... 605
43.1.4. Administrative Controls ......................................................................... 611
43.1.5. Available Network Services ................................................................... 617
Page 16
Deployment Guide
xvi
43.1.6. Personal Firewalls ................................................................................ 620
43.1.7. Security Enhanced Communication Tools .............................................. 621
43.2. Server Security ............................................................................................... 621
43.2.1. Securing Services With TCP Wrappers and xinetd ................................. 622
43.2.2. Securing Portmap ................................................................................ 625
43.2.3. Securing NIS ....................................................................................... 626
43.2.4. Securing NFS ...................................................................................... 628
43.2.5. Securing the Apache HTTP Server ....................................................... 629
43.2.6. Securing FTP ...................................................................................... 630
43.2.7. Securing Sendmail ............................................................................... 633
43.2.8. Verifying Which Ports Are Listening ....................................................... 634
43.3. Single Sign-on (SSO) ...................................................................................... 635
43.3.1. Introduction .......................................................................................... 635
43.3.2. Getting Started with your new Smart Card ............................................. 637
43.3.3. How Smart Card Enrollment Works ....................................................... 638
43.3.4. How Smart Card Login Works .............................................................. 639
43.3.5. Configuring Firefox to use Kerberos for SSO ......................................... 640
43.4. Pluggable Authentication Modules (PAM) ......................................................... 642
43.4.1. Advantages of PAM ............................................................................. 643
43.4.2. PAM Configuration Files ....................................................................... 643
43.4.3. PAM Configuration File Format ............................................................. 643
43.4.4. Sample PAM Configuration Files ........................................................... 646
43.4.5. Creating PAM Modules ......................................................................... 647
43.4.6. PAM and Administrative Credential Caching .......................................... 647
43.4.7. PAM and Device Ownership ................................................................. 649
43.4.8. Additional Resources ............................................................................ 650
43.5. TCP Wrappers and xinetd ............................................................................... 651
43.5.1. TCP Wrappers ..................................................................................... 652
43.5.2. TCP Wrappers Configuration Files ........................................................ 653
43.5.3. xinetd .................................................................................................. 660
43.5.4. xinetd Configuration Files ..................................................................... 661
43.5.5. Additional Resources ............................................................................ 666
43.6. Kerberos ........................................................................................................ 667
43.6.1. What is Kerberos? ............................................................................... 667
43.6.2. Kerberos Terminology .......................................................................... 668
43.6.3. How Kerberos Works ........................................................................... 670
43.6.4. Kerberos and PAM ............................................................................... 671
43.6.5. Configuring a Kerberos 5 Server ........................................................... 672
43.6.6. Configuring a Kerberos 5 Client ............................................................ 674
43.6.7. Domain-to-Realm Mapping ................................................................... 675
43.6.8. Setting Up Secondary KDCs ................................................................. 675
43.6.9. Setting Up Cross Realm Authentication ................................................. 677
43.6.10. Additional Resources .......................................................................... 680
43.7. Virtual Private Networks (VPNs) ...................................................................... 682
43.7.1. How Does a VPN Work? ...................................................................... 682
43.7.2. VPNs and Red Hat Enterprise Linux ..................................................... 682
43.7.3. IPsec ................................................................................................... 683
43.7.4. Creating an IPsec Connection .............................................................. 683
43.7.5. IPsec Installation .................................................................................. 683
43.7.6. IPsec Host-to-Host Configuration .......................................................... 684
43.7.7. IPsec Network-to-Network Configuration ................................................ 690
Page 17
xvii
43.7.8. Starting and Stopping an IPsec Connection ........................................... 696
43.8. Firewalls ......................................................................................................... 697
43.8.1. Netfilter and IPTables ........................................................................... 698
43.8.2. Basic Firewall Configuration .................................................................. 698
43.8.3. Using IPTables .................................................................................... 702
43.8.4. Common IPTables Filtering ................................................................... 703
43.8.5. FORWARD and NAT Rules ..................................................................... 704
43.8.6. Malicious Software and Spoofed IP Addresses ....................................... 707
43.8.7. IPTables and Connection Tracking ........................................................ 708
43.8.8. IPv6 .................................................................................................... 708
43.8.9. Additional Resources ............................................................................ 709
43.9. IPTables ......................................................................................................... 709
43.9.1. Packet Filtering .................................................................................... 710
43.9.2. Differences Between IPTables and IPChains ......................................... 711
43.9.3. Command Options for IPTables ............................................................ 712
43.9.4. Saving IPTables Rules ......................................................................... 721
43.9.5. IPTables Control Scripts ....................................................................... 721
43.9.6. IPTables and IPv6 ............................................................................... 724
43.9.7. Additional Resources ............................................................................ 724
44. Security and SELinux 725
44.1. Access Control Mechanisms (ACMs) ............................................................... 725
44.1.1. Discretionary Access Control (DAC) ...................................................... 725
44.1.2. Access Control Lists (ACLs) ................................................................. 725
44.1.3. Mandatory Access Control (MAC) ......................................................... 725
44.1.4. Role-based Access Control (RBAC) ...................................................... 725
44.1.5. Multi-Level Security (MLS) .................................................................... 726
44.1.6. Multi-Category Security (MCS) .............................................................. 726
44.2. Introduction to SELinux ................................................................................... 726
44.2.1. SELinux Overview ................................................................................ 726
44.2.2. Files Related to SELinux ...................................................................... 727
44.2.3. Additional Resources ............................................................................ 731
44.3. Brief Background and History of SELinux ......................................................... 731
44.4. Multi-Category Security (MCS) ........................................................................ 732
44.4.1. Introduction .......................................................................................... 732
44.4.2. Applications for Multi-Category Security ................................................. 732
44.4.3. SELinux Security Contexts ................................................................... 732
44.5. Getting Started with Multi-Category Security (MCS) .......................................... 733
44.5.1. Introduction .......................................................................................... 733
44.5.2. Comparing SELinux and Standard Linux User Identities .......................... 734
44.5.3. Configuring Categories ......................................................................... 735
44.5.4. Assigning Categories to Users .............................................................. 736
44.5.5. Assigning Categories to Files ................................................................ 737
44.6. Multi-Level Security (MLS) .............................................................................. 738
44.6.1. Why Multi-Level? ................................................................................. 738
44.6.2. Security Levels, Objects and Subjects ................................................... 740
44.6.3. MLS Policy .......................................................................................... 741
44.6.4. LSPP Certification ................................................................................ 742
44.7. SELinux Policy Overview ................................................................................ 742
44.7.1. What is the SELinux Policy? ................................................................. 742
44.7.2. Where is the Policy? ............................................................................ 743
44.7.3. The Role of Policy in the Boot Process ................................................. 744
Page 18
Deployment Guide
xviii
44.7.4. Object Classes and Permissions ........................................................... 746
44.8. Targeted Policy Overview ................................................................................ 746
44.8.1. What is the Targeted Policy? ................................................................ 746
44.8.2. Files and Directories of the Targeted Policy ........................................... 747
44.8.3. Understanding the Users and Roles in the Targeted Policy ..................... 747
45. Working With SELinux 751
45.1. End User Control of SELinux ........................................................................... 751
45.1.1. Moving and Copying Files .................................................................... 751
45.1.2. Checking the Security Context of a Process, User, or File Object ............. 752
45.1.3. Relabeling a File or Directory ................................................................ 754
45.1.4. Creating Archives That Retain Security Contexts .................................... 756
45.2. Administrator Control of SELinux ..................................................................... 758
45.2.1. Viewing the Status of SELinux .............................................................. 758
45.2.2. Relabeling a File System ...................................................................... 759
45.2.3. Managing NFS Home Directories .......................................................... 760
45.2.4. Granting Access to a Directory or a Tree ............................................... 760
45.2.5. Backing Up and Restoring the System .................................................. 761
45.2.6. Enabling or Disabling Enforcement ........................................................ 761
45.2.7. Enable or Disable SELinux ................................................................... 763
45.2.8. Changing the Policy ............................................................................. 764
45.2.9. Specifying the Security Context of Entire File Systems ............................ 766
45.2.10. Changing the Security Category of a File or User ................................. 767
45.2.11. Running a Command in a Specific Security Context .............................. 767
45.2.12. Useful Commands for Scripts .............................................................. 767
45.2.13. Changing to a Different Role ............................................................... 768
45.2.14. When to Reboot ................................................................................. 768
45.3. Analyst Control of SELinux .............................................................................. 768
45.3.1. Enabling Kernel Auditing ...................................................................... 768
45.3.2. Dumping and Viewing Logs .................................................................. 769
46. Customizing SELinux Policy 771
46.1. Introduction .................................................................................................... 771
46.1.1. Modular Policy ..................................................................................... 771
46.2. Building a Local Policy Module ........................................................................ 772
46.2.1. Using audit2allow to Build a Local Policy Module ................................... 772
46.2.2. Analyzing the Type Enforcement (TE) File ............................................. 772
46.2.3. Loading the Policy Package .................................................................. 773
47. References 775
VIII. Red Hat Training And Certification 777
48. Red Hat Training and Certification 779
48.1. Three Ways to Train ....................................................................................... 779
48.2. Microsoft Certified Professional Resource Center .............................................. 779
49. Certification Tracks 781
49.1. Free Pre-assessment tests .............................................................................. 781
50. RH033: Red Hat Linux Essentials 783
50.1. Course Description ......................................................................................... 783
50.1.1. Prerequisites ........................................................................................ 783
50.1.2. Goal .................................................................................................... 783
Page 19
xix
50.1.3. Audience ............................................................................................. 783
50.1.4. Course Objectives ................................................................................ 783
50.1.5. Follow-on Courses ............................................................................... 784
51. RH035: Red Hat Linux Essentials for Windows Professionals 785
51.1. Course Description ......................................................................................... 785
51.1.1. Prerequisites ........................................................................................ 785
51.1.2. Goal .................................................................................................... 785
51.1.3. Audience ............................................................................................ 785
51.1.4. Course Objectives ................................................................................ 785
51.1.5. Follow-on Courses ............................................................................... 785
52. RH133: Red Hat Linux System Administration and Red Hat Certified Technician (RHCT) Certification 787
52.1. Course Description ......................................................................................... 787
52.1.1. Prerequisites ........................................................................................ 787
52.1.2. Goal .................................................................................................... 787
52.1.3. Audience ............................................................................................. 787
52.1.4. Course Objectives ................................................................................ 787
52.1.5. Follow-on Courses ............................................................................... 788
53. RH202 RHCT EXAM - The fastest growing credential in all of Linux. 789
53.1. Course Description ......................................................................................... 789
53.1.1. Prerequisites ........................................................................................ 789
54. RH253 Red Hat Linux Networking and Security Administration 791
54.1. Course Description ......................................................................................... 791
54.1.1. Prerequisites ........................................................................................ 791
54.1.2. Goal .................................................................................................... 791
54.1.3. Audience ............................................................................................ 791
54.1.4. Course Objectives ............................................................................... 791
54.1.5. Follow-on Courses ............................................................................... 792
55. RH300: RHCE Rapid track course (and RHCE exam) 793
55.1. Course Description ......................................................................................... 793
55.1.1. Prerequisites ........................................................................................ 793
55.1.2. Goal .................................................................................................... 793
55.1.3. Audience ............................................................................................ 793
55.1.4. Course Objectives ............................................................................... 793
55.1.5. Follow-on Courses ............................................................................... 793
56. RH302 RHCE EXAM 795
56.1. Course Description ......................................................................................... 795
56.1.1. Prerequisites ........................................................................................ 795
56.1.2. Content ............................................................................................... 795
57. RHS333: RED HAT enterprise security: network services 797
57.1. Course Description ......................................................................................... 797
57.1.1. Prerequisites ........................................................................................ 797
57.1.2. Goal .................................................................................................... 797
57.1.3. Audience ............................................................................................ 797
57.1.4. Course Objectives ................................................................................ 797
57.1.5. Follow-on Courses ............................................................................... 798
58. RH401: Red Hat Enterprise Deployment and systems management 799
Page 20
Deployment Guide
xx
58.1. Course Description ......................................................................................... 799
58.1.1. Prerequisites ........................................................................................ 799
58.1.2. Goal .................................................................................................... 799
58.1.3. Audience ............................................................................................ 799
58.1.4. Course Objectives ................................................................................ 799
58.1.5. Follow-on Courses ............................................................................... 800
59. RH423: Red Hat Enterprise Directory services and authentication 801
59.1. Course Description ......................................................................................... 801
59.1.1. Prerequisites ........................................................................................ 801
59.1.2. Goal .................................................................................................... 801
59.1.3. Audience ............................................................................................ 801
59.1.4. Course Objectives ................................................................................ 801
59.1.5. Follow-on Courses ............................................................................... 801
60. SELinux Courses 803
60.1. RHS427: Introduction to SELinux and Red Hat Targeted Policy ......................... 803
60.1.1. Audience ............................................................................................. 803
60.1.2. Course Summary ................................................................................. 803
60.2. RHS429: Red Hat Enterprise SELinux Policy Administration ............................. 803
61. RH436: Red Hat Enterprise storage management 805
61.1. Course Description ......................................................................................... 805
61.1.1. Prerequisites ........................................................................................ 805
61.1.2. Goal .................................................................................................... 805
61.1.3. Audience ............................................................................................ 805
61.1.4. Course Objectives ................................................................................ 805
61.1.5. Follow-on Courses ............................................................................... 806
62. RH442: Red Hat Enterprise system monitoring and performance tuning 807
62.1. Course Description ......................................................................................... 807
62.1.1. Prerequisites ........................................................................................ 807
62.1.2. Goal .................................................................................................... 807
62.1.3. Audience ............................................................................................ 807
62.1.4. Course Objectives ................................................................................ 807
62.1.5. Follow-on Courses ............................................................................... 808
63. Red Hat Enterprise Linux Developer Courses 809
63.1. RHD143: Red Hat Linux Programming Essentials ............................................ 809
63.2. RHD221 Red Hat Linux Device Drivers ........................................................... 809
63.3. RHD236 Red Hat Linux Kernel Internals ......................................................... 809
63.4. RHD256 Red Hat Linux Application Development and Porting ........................... 809
64. JBoss Courses 811
64.1. RHD161 JBoss and EJB3 for Java .................................................................. 811
64.1.1. Prerequisites ........................................................................................ 811
64.2. RHD163 JBoss for Web Developers ............................................................... 811
64.2.1. Prerequisites ........................................................................................ 811
64.3. RHD167: JBOSS - HIBERNATE ESSENTIALS ................................................. 812
64.3.1. Prerequisites ........................................................................................ 812
64.3.2. Course Summary ................................................................................. 812
64.4. RHD267: JBOSS - ADVANCED HIBERNATE ................................................... 812
64.4.1. Prerequisites ........................................................................................ 812
64.5. RHD261:JBOSS for advanced J2EE developers ............................................... 813
Page 21
xxi
64.5.1. Prerequisites ........................................................................................ 813
64.6. RH336: JBOSS for Administrators ................................................................... 814
64.6.1. Prerequisites ........................................................................................ 814
64.6.2. Course Summary ................................................................................. 814
64.7. RHD439: JBoss Clustering .............................................................................. 814
64.7.1. Prerequisites ...................................................................................... 815
64.8. RHD449: JBoss jBPM .................................................................................... 815
64.8.1. Description ......................................................................................... 815
64.8.2. Prerequisites ........................................................................................ 815
64.9. RHD451 JBoss Rules ..................................................................................... 816
64.9.1. Prerequisites ........................................................................................ 816
A. Revision History 817
65. Colophon 819
Page 22
xxii
Page 23
xxiii
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:
Page 24
Introduction
xxiv
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:
Page 25
Document Conventions
xxv
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.
Page 26
Introduction
xxvi
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.
Page 27
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.
Page 28
Page 29
Chapter 1.
3
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.
1
http://www.pathname.com/fhs
Page 30
Chapter 1. File System Structure
4
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 demon 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.
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.
Table 1.1. Examples of common files in the /dev
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.
Page 31
FHS Organization
5
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 removeable 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 removeable media, please use the /media/ directory. Automatically detected removeable 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 3, The proc File System.
Page 32
Chapter 1. File System Structure
6
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/
Page 33
FHS Organization
7
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/
Page 34
Chapter 1. File System Structure
8
|- 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 10, 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 the documentation online at https://rhn.redhat.com/.
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
Page 35
Special File Locations Under Red Hat Enterprise Linux
9
in this directory. Refer to Chapter 28, The sysconfig Directory for more information about what is within this directory and the role these files play in the boot process.
Page 36
10
Page 37
Chapter 2.
11
The ext3 File System
The default file system is the journaling ext3 file system.
2.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 2.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 formating sections below and go directly to Section 2.3, “Converting
to an ext3 File System”.
2.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:
Page 38
Chapter 2. The ext3 File System
12
1. Format the partition with the ext3 file system using mkfs.
2. Label the partition using e2label.
2.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:
/sbin/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.
2.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:
Page 39
Reverting to an ext2 File System
13
/sbin/tune2fs -O ^has_journal /dev/mapper/VolGroup00-LogVol02
Check the partition for errors by typing the following command as root:
/sbin/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.
Page 40
14
Page 41
Chapter 3.
15
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.
3.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.
3.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
Page 42
Chapter 3. The proc File System
16
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.
3.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 3.4, “Using the sysctl
Command”
For a listing of some of the kernel configuration files available in the /proc/sys/ subdirectory, refer to Section 3.3.9, “/proc/sys/.
3.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.
3.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:
Page 43
/proc/buddyinfo
17
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)
3.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 ...
3.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
Page 44
Chapter 3. The proc File System
18
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.
3.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
Page 45
/proc/crypto
19
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.
3.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
3.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
Page 46
Chapter 3. The proc File System
20
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
3.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
3.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.
Page 47
/proc/fb
21
3.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
3.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.
3.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
Page 48
Chapter 3. The proc File System
22
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.
3.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
Page 49
/proc/ioports
23
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.
3.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.
3.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.
3.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.
Page 50
Chapter 3. The proc File System
24
3.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.
3.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.
3.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.
Page 51
/proc/meminfo
25
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>
3.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.
Page 52
Chapter 3. The proc File System
26
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.
3.2.20. /proc/misc
This file lists miscellaneous drivers registered on the miscellaneous major device, which is device number 10:
Page 53
/proc/modules
27
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.
3.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.
3.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
Page 54
Chapter 3. The proc File System
28
/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.
3.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
3.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.
Page 55
/proc/pci
29
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.
3.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:
/sbin/lspci -vb
3.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:
Page 56
Chapter 3. The proc File System
30
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.
3.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
Page 57
/proc/swaps
31
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.
3.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/swap 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.
Page 58
Chapter 3. The proc File System
32
3.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 3.3.9.3, “/proc/sys/kernel/.
Although it is possible to write to this file, it cannot be read, even by the root user.
3.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.
3.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.
3.3. Directories within /proc/
Common groups of information concerning the kernel are grouped into directories and subdirectories within the /proc/ directory.
3.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.
Page 59
Process Directories
33
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.
Page 60
Chapter 3. The proc File System
34
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.
3.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.
3.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/.
Page 61
/proc/driver/
35
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
3.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.
Page 62
Chapter 3. The proc File System
36
3.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 19, Network File System (NFS).
3.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).
3.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.
Page 63
/proc/irq/
37
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
3.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
3.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.
Page 64
Chapter 3. The proc File System
38
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.
3.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.
Page 65
/proc/scsi/
39
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
Page 66
Chapter 3. The proc File System
40
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.
3.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
Page 67
/proc/sys/
41
-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 3.4, “Using the sysctl Command”.
The /proc/sys/ directory contains several subdirectories controlling different aspects of a running kernel.
3.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
Page 68
Chapter 3. The proc File System
42
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.
3.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.
3.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:
Page 69
/proc/sys/
43
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.
Page 70
Chapter 3. The proc File System
44
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
Page 71
/proc/sys/
45
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, in bytes. 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, in bytes. 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.
Page 72
Chapter 3. The proc File System
46
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.
Page 73
/proc/sys/
47
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.
3.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:
Page 74
Chapter 3. The proc File System
48
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:
Page 75
/proc/sys/
49
/usr/share/doc/kernel-doc-<version>/Documentation/filesystems/proc.txt
3.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:
Page 76
Chapter 3. The proc File System
50
/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.
Page 77
/proc/sysvipc/
51
3.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).
3.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.
3.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
Page 78
Chapter 3. The proc File System
52
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.
3.5. Additional Resources
Below are additional sources of information about proc file system.
3.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.
3.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.
Page 79
Chapter 4.
53
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.
4.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.
4.2. 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
4.3. Hardware RAID versus Software RAID
There are two possible RAID approaches: Hardware RAID and Software RAID.
4.3.1. 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.
Page 80
Chapter 4. Redundant Array of Independent Disks (RAID)
54
4.3.2. 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
4.4. 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.
A hot-swap chassis allows you to remove a hard drive without having to power-down your system.
Page 81
Configuring Software RAID
55
Level 4 — Level 4 uses parity (see Note) 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.
Note
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.
Level 5 — This 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.
4.5. Configuring Software RAID
Users can configure Software RAID during the graphical installation process (Disk Druid), the text­based installation process, or during a kickstart installation.This chapter covers Software RAID configuration during the installation process using the Disk Druid application.
• Apply software RAID partitions to the physical hard drives.
To add a boot partition (/boot/) to a RAID partition, ensure it is on a RAID1 partiton.
• Creating RAID devices from the software RAID partitions.
Optional: Configuring LVM from the RAID devices.
Page 82
Chapter 4. Redundant Array of Independent Disks (RAID)
56
• Creating file systems from the RAID devices.
Note
Although this procedure covers installating with a GUI application, system administrators can do the same with text-based installation.
Configuration of software RAID must be done manually in Disk Druid during the installation process.
These examples use two 9.1 GB SCSI drives (/dev/sda and /dev/sdb) to illustrate the creation of simple RAID1 configurations. They detail how to create a simple RAID 1 configuration by implementing multiple RAID devices.
On the Disk Partitioning Setup screen, select Manually partition with Disk Druid.
4.5.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 4.1, “Two Blank Drives, Ready For Configuration”.
Figure 4.1. Two Blank Drives, Ready For Configuration
1. In Disk Druid, choose RAID to enter the software RAID creation screen.
Page 83
Creating the RAID Partitions
57
2. Choose Create a software RAID partition to create a RAID partition as shown in Figure 4.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.
Figure 4.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.
Page 84
Chapter 4. Redundant Array of Independent Disks (RAID)
58
Figure 4.3. Adding a RAID Partition
4. Enter the size that you want the partition to be.
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.
7. Repeat these steps to create as many partitions as you need for your partitions.
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 4.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:
Page 85
Creating the RAID Devices and Mount Points
59
Figure 4.4. RAID 1 Partitions Ready, Pre-Device and Mount Point Creation
4.5.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. Select the RAID button on the Disk Druid main partitioning screen (refer to Figure 4.5, “RAID
Options”).
2. Figure 4.5, “RAID Options” appears. Select Create a RAID device.
Page 86
Chapter 4. Redundant Array of Independent Disks (RAID)
60
Figure 4.5. RAID Options
3. Next, Figure 4.6, “Making a RAID Device and Assigning a Mount Point” appears, where you can make a RAID device and assign a mount point.
Page 87
Creating the RAID Devices and Mount Points
61
Figure 4.6. Making a RAID Device and Assigning a Mount Point
4. Select a mount point.
5. Choose the file system type for the partition. At this point you can either configure a dynamic LVM file system or a traditional static ext2/ext3 file system. For more information on configuring LVM on a RAID device, select physical volume (LVM). If LVM is not required, continue on with the following instructions.
6. Select a device name such as md0 for the RAID device.
7. Choose your RAID level. You can choose from RAID 0, RAID 1, and RAID 5.
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 seperate RAID partition of /boot/, and you are making a RAID partition for the root file system (/), it must be RAID level 1 and must use one of the first two drives (IDE first, SCSI second).
Page 88
Chapter 4. Redundant Array of Independent Disks (RAID)
62
Figure 4.7. The /boot/ Mount Error
8. The RAID partitions created appear in the RAID Members list. Select which of these partitions should be used to create the RAID device.
9. If configuring RAID 1 or RAID 5, specify the number of spare partitions. 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).
10. After clicking OK, the RAID device appears in the Drive Summary list.
11. Repeat this chapter's entire process for configuring additional partitions, devices, and mount points, such as the root partition (/), /home/, or swap.
After completing the entire configuration, the figure as shown in Figure 4.8, “Final Sample RAID
Configuration” resembles the default configuration, except for the use of RAID.
Page 89
Creating the RAID Devices and Mount Points
63
Figure 4.8. Final Sample RAID Configuration
The figure as shown in Figure 4.9, “Final Sample RAID With LVM Configuration” is an example of a RAID and LVM configuration.
Page 90
Chapter 4. Redundant Array of Independent Disks (RAID)
64
Figure 4.9. Final Sample RAID With LVM Configuration
You can continue with your installation process. Refer to the Red Hat Enterprise Linux Installation Guide for further instructions.
Page 91
Chapter 5.
65
Swap Space
5.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.
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
Table 5.1. Recommended System 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.
5.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.
Page 92
Chapter 5. Swap Space
66
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.
5.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
5.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:
Page 93
Creating a Swap File
67
/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
5.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.
5.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.
Page 94
Chapter 5. Swap Space
68
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.
5.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
5.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 it to boot your system in rescue mode. Refer to 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
Page 95
Removing a Swap File
69
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
5.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
5.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.
Page 96
70
Page 97
Chapter 6.
71
Managing Disk Storage
6.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 38.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 it 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 6.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.
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
Page 98
Chapter 6. Managing Disk Storage
72
Command Description
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
Table 6.1. parted commands
6.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
Page 99
Creating a Partition
73
• 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.
6.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 6.1.4, “Resizing
a Partition” for details.
Page 100
Chapter 6. Managing Disk Storage
74
6.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.
6.1.2.2. Formating the Partition
The partition still does not have a file system. Create the file system:
/sbin/mkfs -t ext3 /dev/sda6
Warning
Formatting the partition permanently destroys any data that currently exists on the partition.
6.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:
Loading...