3.11 Restoring the Directory Services Database

If the local directory database is damaged, boot into single- user mode by holding down figs/command.gif -S as the system starts up. Next , check to see if you have a backup of the NetInfo database. The /etc/daily cron job backs up the database each time it is run. You can find the backup in /var/ backups /local.nidump . If you don't have a backup, you won't be able to restore. The local.nidump file is overwritten each time the cron job runs, so make sure you back it up regularly (preferably to some form of removable media).

If your computer is generally not turned on at 3:15 a.m. (the default time for the daily cron job), you'll never get a backup of your local directory. You can solve this problem by editing /etc/crontab to run this job at a different time, or to run the job periodically with the command sudo periodic daily . see Section 2.3.1 in Chapter 2 for more details.

After the system boots in single-user mode, you should:

  1. Wait for the root# prompt to come up.

  2. Fix any filesystem errors; if you are using a journaled filesystem, this step won't be necessary (and if you try to run this command, you'll get an error):

     # /sbin/fsck -y 
  3. Mount the root filesystem as read/write:

     # /sbin/mount -uw / 
  4. Change directories and go to the NetInfo database directory:

     # cd /var/db/netinfo/ 
  5. Move the database out of the way and give it a different name :

     # mv local.nidb/ local.nidb.broken 
  6. Start enough of the system to use NetInfo (each of these commands may take several seconds or more to complete; the last message you see should be "Startup complete."):

     # /usr/libexec/kextd # /usr/sbin/configd # /sbin/SystemStarter 
  7. Create a blank NetInfo database and start NetInfo (be sure you are still in the /var/db/netinfo directory from step 4):

     # /usr/libexec/create_nidb # /usr/sbin/netinfod -s local 
  8. Load the backup into NetInfo:

     # /usr/bin/niload  -d -r / . < /var/backups/local.nidump 

After you have completed these steps, reboot the system with the reboot command.

If you totally mess up and find that you forgot to backup your NetInfo database, you can stop at step 8, and issue the command rm /var/db/.AppleSetupDone . This makes Mac OS X think that it's being booted for the first time next time you reboot, and will run the setup assistant so you can create the initial user for the system, bringing your system to a usable state for further repairs .

Mac OS X Panther for Unix Geeks
Mac OS X Panther for Unix Geeks
ISBN: 0596006071
EAN: 2147483647
Year: 2003
Pages: 212

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net