Table of Contents
- About the Author
- Tell Us What You Think!
- Part I: Introduction to Mac OS X
- Chapter 1. Mac OS X Component Architecture
- Chapter 2. Installing Mac OS X
- Chapter 3. Mac OS X Basics
- Chapter 4. The Finder: Working with Files and Applications
- Chapter 5. Running Classic Mac OS Applications
- Part II: Inside Mac OS X
- Chapter 6. Native Utilities and Applications
- Chapter 7. Internet Communications
- Chapter 8. Installing Third-Party Applications
- Part III: User-Level OS X Configuration
- Chapter 9. Network Setup
- Chapter 10. Printer and Font Management
- Chapter 11. Additional System Components
- Part IV: Introduction to BSD Applications
- Chapter 12. Introducing the BSD Subsystem
- Chapter 13. Common Unix Shell Commands: File Operations
- Part V: Advanced Command-Line Concepts
- Chapter 14. Advanced Shell Concepts and Commands
- Chapter 15. Command-Line Applications and Application Suites
- Chapter 16. Command-Line Software Installation
- Chapter 17. Troubleshooting Software Installs, and Compiling and Debugging Manually
- Chapter 18. Advanced Unix Shell Use: Configuration and Programming (Shell Scripting)
- Part VI: Server/Network Administration
- Chapter 19. X Window System Applications
- Chapter 20. Command-Line Configuration and Administration
- Chapter 21. AppleScript
- Chapter 22. Perl Scripting and SQL Connectivity
- Chapter 23. File and Resource Sharing with NetInfo
- Chapter 24. User Management and Machine Clustering
- Chapter 25. FTP Serving
- Chapter 26. Remote Access and Administration
- Chapter 27. Web Serving
- Part VII: Server Health
- Chapter 28. Web Programming
- Chapter 29. Creating a Mail Server
- Chapter 30. Accessing and Serving a Windows Network
- Chapter 31. Server Security and Advanced Network Configuration
- Chapter 32. System Maintenance
- Appendix A. Command-Line Reference
- Appendix B. Administration Reference
With a complex operating system like Mac OS X, things can sometimes go wrong, and the user is left with little recourse for solving the problem. Operations such as repairing damaged Mac OS X installations, resetting the root password, and fixing damaged disks can all be performed even if your machine is not booting into the operating system properly.
Mac OS 8 and 9, although hiding much of the system operation from the user, gave a clearer picture of what was going on during a system boot. When Mac OS X starts, dozens of support processes and drivers are loaded at the same time. If something fails, it is left to the imagination of the user to guess exactly what has gone wrong. In many cases, users might not even be aware that there are problems with their system configuration because the boot process hides behind a very simple GUI startup screen.
To view exactly what is happening as the Mac OS X system boots, you can hold down Command+V at power-on to force a verbose startup. The verbose boot displays all status and error messages while the computer starts. This can be a bit startling to many Mac users because instead of the usual blue or gray background present during startup, the screen is black and filled with text. Windows and Linux users will feel right at home.
The verbose startup messages are similar to those contained in /var/log/system.log. For example:
Jun 29 17:30:30 localhost mach_kernel: .Display_RADEON: i2cPower 1 Jun 29 17:30:30 localhost mach_kernel: .Display_RADEON: user ranges num:1 start:9c008000 size:640080 Jun 29 17:30:30 localhost mach_kernel: .Display_RADEON: using (1600x1024@0Hz,32 bpp) Jun 29 17:30:30 localhost mach_kernel: AirPortDriver: Ethernet address 00:30:65:11:37:15 Jun 29 17:30:30 localhost mach_kernel: ether_ifattach called for en Jun 29 17:30:30 localhost mach_kernel: kmod_create: com.apple.nke.ppp (id 58), 6 pages loaded at 0xc27a000, header size 0x1000 Jun 29 17:30:30 localhost mach_kernel: kmod_create: com.apple.nke.SharedIP (id 59), 5 pages loaded at 0xc28d000, header size 0x1000 Jun 29 17:30:30 localhost mach_kernel: kmod_create: IPFirewall (id 60), 5 pages loaded at 0xc292000, header size 0x1000 Jun 29 17:30:30 localhost mach_kernel: ipfw_load Jun 29 17:30:30 localhost mach_kernel: IP packet filtering initialized, divert enabled, rule-based forwarding enabled, default to accept, logging disabled Jun 29 17:30:31 localhost sharity:  Sharity daemon version 2.4 started Jun 29 17:30:39 localhost ntpdate: ntpdate 4.0.95 Sat Feb 17 02:38:39 PST 2001 (1) Jun 29 17:30:43 localhost ntpdate: no server suitable for synchronization found Jun 29 17:30:43 localhost ntpd: ntpd 4.0.95 Thu Apr 26 13:40:11 PDT 2001 (1) Jun 29 17:30:43 localhost ntpd: precision = 7 usec Jun 29 17:30:43 localhost ntpd: frequency initialized 0.000 from /var/run/ntp.drift Jun 29 17:30:43 localhost ntpd: server 184.108.40.206 minpoll 12 maxpoll 17
This small sample of the verbose output shows the Apple Radeon driver loading, followed by the AirPort software, Classic SharedIP driver, firewall, Sharity, and ntp (network time protocol) software.
Interestingly enough, in capturing this example, I ascertained what I had suspected for several weeks: The ntpdate utility, which is responsible for automatically contacting a remote time server for synchronization, has been failing:
Jun 29 17:30:39 localhost ntpdate: ntpdate 4.0.95 Sat Feb 17 02:38:39 PST 2001 (1) Jun 29 17:30:43 localhost ntpdate: no server suitable for synchronization found
Similar feedback is provided for almost all the services on the computer, from low-level device drivers to Apache and Sendmail. If your computer hangs during boot, you can use the verbose startup mode to determine exactly where the sequence has gone amiss.
Another interesting modification to the startup process is booting into single-user mode. Holding down Command+S will start Mac OS X in single-user mode, allowing an administrator to directly access the system through a command-line interface. This is a last-resort method of booting your computer that should be used only if absolutely necessary.
Single-user mode boots in a text-only fashion, just like the verbose startup mode. The process finishes by dropping the user to a shell:
Singleuser boot — fsck not done Root device is mounted read-only If you want to make modifications to files, run '/sbin/fsck -y' first and them '/sbin/mount -uw /' localhost#
Using the fsck command, you can repair local file systems from the command line. To fix a damaged file system, type fsck -y at the single-user prompt. This is equivalent to running the First Aid Disk Utility:
localhost# fsck -y ** /dev/rdisk0s9 ** Root file system ** Checking HFS Plus volume ** Checking Extents Overflow file. ** Checking Catalog file. ** Checking multi-linked files. ** Checking Catalog heirarchy. ** Checking volume bitmap. ** Checking volume information. ** The volume Rmac OS XS appears to be OK.
If an error occurs during this process, you might have to tell the system that it is okay to perform repairs. Table 32.4 lists additional command-line arguments for fsck.
Table 32.4. fsck Command-Line Options
|-d||Debugging mode. Displays the commands that fsck will execute without actually carrying them out.|
|-f||Forces a check of the file systems, even if they are considered clean.|
|-l <max parallel processes>||Sets the number of scans that fsck will run in parallel. Usually defaults to one scan per disk.|
|-n||Assumes that the answer to all interactive questions is no.|
|-p||Preen (clean) the file systems marked as dirty.|
|-y||Answers yes to all interactive questions.|
When booted into single-user mode, the Mac OS X file system is mounted read-only as a precaution. If you've installed a new daemon or script that is stalling the system at startup, it would be useful to be able to edit files from within single-user mode. To mount the file system with write permissions, use /sbin/mount -uw /.
Again, be aware that changes made while in single-user mode are made as the root user. When dealing with stalled startups, take the same approach as with extensions and control panels under Mac OS 8 and 9: Remove the last item to load before the system failure, and then reboot.
As you already know, both the /Library/Startupitems and /System/Library/Startupitems directories contain the services that are started at boot time. Make these your starting locations for pinpointing hang-ups when Mac OS X is booting. In addition, the /etc/hostconfig and /private/var/db/SystemConfiguration/preferences.xml files hold information on your machine's network configuration and boot parameters. Although editing these files isn't a guaranteed cure for any problem, they're a good place to start.
Commercial Repair Tools
At the time of this writing, only a single disk repair utility is available under OS X: Drive 10 from MicroMat. This is expected to change in late 2001/early 2002, but that is of little consolation for those of us using the operating system currently.
Thankfully, because Mac OS X uses the same default file system as Mac OS 9, the big-name commercial disk repair utilities have been updated to work under the new operating system:
- Drive 10 by Micromat Inc. (www.micromat.com/drive10) Drive 10 offers extensive disk diagnostic utilities ranging from power supply tests to buffer validation. Unfortunately, it is lacking several of the more useful features—such as more generalized system diagnostics and drive optimization—of its big brother, TechTool Pro.
- TechTool Pro by Micromat Inc. (www.micromat.com/techTool_Pro3) TechTool Pro is the undisputed king of diagnostics. It can locate problems with almost any hardware component, from memory to CPU failures. It also includes extensive drive repair and optimization facilities.
- Norton Utilities by Symantec, Inc. (www.symantec.com/product/home-mac.html) Norton Utilities is the oldest and best-known Macintosh repair software available. NU focuses entirely on drive repair, optimization, and data loss prevention.
It has been my experience that TechTool Pro and Norton Utilities can be used in conjunction with one another to successfully diagnose and solve problems that neither can handle alone. Drive 10, although effective as a complete disk drive diagnostic tool, does not offer as complete a package as the non-native TechTool Pro.
Most Windows users are familiar with the word reinstall. I've listened in on many support calls, only to hear the technician give up and tell the end user to reinstall. Unfortunately, Mac OS X users might find themselves doing the same thing. The difference, however, is that reinstalling Mac OS X does not replace your system accounts, information, or configuration.
I have found on numerous occasions that rerunning the Mac OS X installer is the fastest and easiest way to return to a viable system. There are, however, a few drawbacks—most notably, the system updates are replaced by the original version of the operating system. After running the Mac OS X Installer to recover a damaged system, be sure to open the /Library/Receipts folder and throw away any receipt files stored by system updates, and then manually force a software update to reinstall the latest versions of the Mac OS X support software.
Another anomaly is that if you've moved or removed any of the system-installed applications, they will be restored during the install process.
Restoring the Administrator Password
If the Mac OS X administrator password is forgotten or misplaced, Apple has provided a facility for restoring a password. Boot your computer from the Mac OS X install CD (hold down the C key while turning your computer on with the CD in the CD-ROM drive). When the Installer application starts, choose Reset Password from the Installer application menu. Figure 32.8 shows the interface to the Password Reset facility.
Figure 32.8 Use the boot CD and Password Reset application to ease your forgetful head.
Detected Mac OS X volumes are listed along the top of the Window. Click the main boot drive to load the password database for that volume.
Next, use the pop-up menu to choose the user account that you want to reset. Fill in the new password in both of the password fields provided.
Finally, click Save to store the new password.
This really isn't useful for much beyond resetting the administrator password. As long as there is access to the administrator account from the command line, you can easily use passwd <username> to reset the named user's password:
[primal:~] jray% sudo passwd robyn Changing password for robyn. New password: Retype new password: