cnid2_create — Convert CNID 1 database to CNID 2


cnid2_create volume


cnid2_create converts a CNID database created with Netatalk 1 to a CNID database compatible with Netatalk 2.


This section is borrowed with minor modification from the Upgrade guide in the Netatalk 2 manual.

The steps to upgrade depend on what version of Berkeley DB is installed on your system. If you already use one of the supported versions of Berkeley DB (4.1.25 or 4.2.52) for your old Netatalk installation and plan to use it for Netatalk 2 as well, just use the db_dump and db_load utilities that came with it as indicated below. Otherwise it is probably best to have the old and the new (to be used with Netatalk 2) version of Berkeley DB installed side by side until you have finished the upgrade. The reason for this is that we will dump out the old databases with the currently installed version of Berkeley DB in ASCII format and reload them with the new version. This avoids any incompatibility problems between Berkeley DB releases with respect to the on-disk format.

For each volume to be upgraded, follow these steps

  • Stop all afpd daemons accessing the volume.

  • Change to the database directory for that volume, most likely the .AppleDB subdirectory of the volume toplevel directory in question.

  • Dump the contents of cnid.db and didname.db using the old (installed) version of Berkeley DB like this:

     db_dump -f cnid.dump cnid.db 
     db_dump -f didname.dump didname.db

    Make sure the db_dump utility you are using is the correct (currently used) one. Use the full path to the db_dump executable if in doubt. So if this database was created with Berkeley DB 3.xx installed in /usr/local/db3 use /usr/local/db3/bin/db_dump instead. This will create two files, cnid.dump and didname.dump in the current directory.

  • Run the cnid2_create script:


    The script assumes that .AppleDB is a subdirectory of the volume directory to be upgraded. If that is not the case give the full path name of the volume as the first argument to cnid2_create. The script will create a file cnid2.dump in ASCII format.

  • Remove the old Berkeley DB environment and logfiles (if present):

     rm __db.* log.*
  • Load cnid2.dump into the new database. You should use the db_load utility of Berkeley DB that will be used with version 2 of Netatalk. So if Berkeley DB 4.xx lives in /usr/local/db4 use

     /usr/local/db4/bin/db_load -f cnid2.dump cnid2.db 

    This will create the new database file, cnid2.db. Remove the old database files cnid.db, didname.db and devino.db. The intermediate files cnid.dump, didname.dump and cnid2.dump can be removed now or at some later time.

If you do not want to have two versions of Berkeley DB installed side by side during the upgrade, you should first dump out the old databases as indicated above for all volumes, upgrade Berkeley DB and then load them with db_load. The cnid2_create script can be run before or after the upgrade. Berkeley DB environment and logfiles should still be removed before running db_load.

See Also