Mac OS X Server 1.x: What Is NetInfo?

This article explains the fundamentals of NetInfo. It also describes how to back the database up, and restore the database to its default state. The final part of the article is a set of links to other articles that aid in understanding how NetInfo operates.
This article has been archived and is no longer updated by Apple.
Note: This article pertains to Mac OS X Server versions 1.x, which were released prior to May 2001.

NetInfo is a hierarchical distributed database that is used to keep track of administrative data in NeXTSTEP, OpenStep for Mach, and Mac OS X Server. It can store information on user and group accounts, e-mail configurations, NFS (network filesystem), printers, computers and other resources. Since this information is stored in NetInfo these resources are easily configurable, and can easily be shared over in a network environment.

A NetInfo Domain is the basic unit of the NetInfo hierarchy. For a discussion of domains please see article:

Article 30832 "Mac OS X Server: Basic Introduction To NetInfo Domains."

NetInfo Servers

Every computer that runs NetInfo is also a NetInfo server. This is because every computer has a local domain and information in this domain is accessed via NetInfo. In a NetInfo network, at least one network domain will be present and the computer that serves the network domain will have two NetInfo servers running. One server will be for the network domain and the other for the local domain. Computers that are part of the network domain will have access to the information stored in the network domain and any domains that may be above it.

Reading Information from the NetInfo database

NetInfo is an information storehouse. It is a passive database that stores information on configurations and resources. This means that NetInfo that information stored in the NetInfo database will have to be read out of the database to another application for it to be used.

There are two ways for information to read information from NetInfo. The first is through lookupd. Lookupd is a background process that is used to read information from NetInfo. Lookupd is used by applications that use the standard library (libc) to call lookupd. Applications can also read information directly from NetInfo using the NetInfo APIs (Application Program Interface). The application that controls logins ( reads information directly from the NetInfo database.

Location of NetInfo

The NetInfo databases are stored in the /etc/netinfo directory. All computers that use NetInfo will have a local.nidb directory inside the netinfo directory. If the computer is a NetInfo server, databases for the domain(s) that the computer is serving will also be here. These databases will have the same name as the domain they server.

Structure of a NetInfo database

A NetInfo database contains directories that are organized hierarchically, similar to the way a file system is organized. Each directory has properties and values. These properties and values are the basic units of the administrative data that NetInfo stores. A property is referenced by its property key. The property key is simply the name of that property. Each property can have any number of values depending on the property.

Figure 1: Directory Browser window.

In Figure 1 the first directory under Directory Browser is the root directory and it is called "/", just like the root directory of the file system. It is lacking the property key "/name" so NetInfo references it by directory ID number, which is 0. Each of the other directories in the picture has the property key "name", and the value of that key is the name of the directory. If a directory does not have the key "name" NetInfo references it by ID number. Other property keys in Figure 1 are gid, realname, shell, passwd, home, shadow passwd, and uid. Each of these keys has a value except for shadow passwd.

The Template NetInfo Database

As part of the installation of Mac OS X Server, template files have been included on the hard drive. The template files are default files, similar to default preferences. The /usr/template/client/etc directory contains a default NetInfo database. This can be used to set a computer back to its shipping NetInfo configuration. Before this is done, the original NetInfo database should be moved to a new location. This is to ensure that any corruption that may exist in the old NetInfo database is not transferred to the new database.

Once the default NetInfo database has been restored the computer must be rebooted for the changes to take effect. After the computer has been restarted the computer will boot into the Setup Assistant.

Making Backups

The NetInfo database stores some of the most important information on the computer and backups should be made frequently. However, a NetInfo database is in use while the server is booted into multi-user mode. Backing up the server in this mode may result in a database that is in flux (being changed while it is being backed up). If this is the case the backup will not properly load when it is restored.

There are two ways around this problem. The easiest is to boot the computer into single-user mode and manually copy the database at the command line. Example:

#cp -R /etc/netinfo/local.nidb /etc/netinfo/local.backup

This command will copy the local NetInfo database to a file called local.backup in the same directory as the original database.

The second way to backup the database does not require the server be rebooted, but it is more time consuming. Make a backup of the NetInfo database by selecting Save Backup from the Domain menu of NetInfoManager. Wait 5 minutes, then make another backup (use a different name so the original backup is not overwritten). Use (available only if the developer packages are installed) or the command line utility "sum", to compare the two backups. If the two backups are identically either one can be used as the backup. If they are different, repeat the process until no differences are found.

To restore a backup, go to the Domain menu and choose Restore From Backup in NetInfoManager. Locate the backup and click the restore button. The computer will need to be restarted for the restored database to be read.

Files Not Used By NetInfo

For users that are not experienced with NetInfo, but are experienced with other Unix-style operating systems here is a list of files in the /etc directory that are not used when NetInfo is running; group, hosts, hosts.eq, passwd, netgroup, networks, printcap, protocols, rpc, and services. These files are still used if the computer is booted into single-user mode, but once NetInfo has started it takes over the functionality of these files.

Related Articles

The articles listed below will aid in understanding NetInfo and its surrounding processes.
Article 30832 "Mac OS X Server: Basic Introduction To NetInfo Domains."
Article 30770: "What is Lookupd?"
Article 24719: "Creating a 2 level domain in NetInfo"

These links are to articles that will aid in the configuration of Netinfo.

Article 60032: "SMac OS X Server: Importing NFS Directories with NetworkManager"
Article 60025: "Managing Users and Groups with NetworkManager"
Article 60026: "Managing Computers with NetworkManager"

Published Date: Feb 18, 2012