Index: trunk/Nebulous-Server/bin/nebdiskd
===================================================================
--- trunk/Nebulous-Server/bin/nebdiskd	(revision 24521)
+++ trunk/Nebulous-Server/bin/nebdiskd	(revision 24539)
@@ -67,5 +67,5 @@
 $retry      ||= $c->get_retry   || 1;
 
-my $mounts = $c->get_mounts;
+#my $mounts = $c->get_mounts;
 my $poll_interval = $c->get_poll_interval || 5;
 
@@ -178,6 +178,17 @@
     eval {
         my $r_query = $dbh->prepare_cached("REPLACE INTO mount VALUES(?, ?, ?)");
-        my $d_query = $dbh->prepare_cached("DELETE FROM mount WHERE mountpoint = ?");
-
+        my $d_query = $dbh->prepare_cached("DELETE FROM mount, mountedvol WHERE mountpoint = ?");
+
+        # get list of mount points
+        my $mounts = [];
+        {
+            my $query = $dbh->prepared_cached("SELECT mountpoint FROM volume");
+            $query->execute;
+            while (my $row = $query->fetchrow_hashref) {
+                push @$mounts, $row->{'mountpoint'};
+            }
+            $query->finish;
+        }
+        
         # determine valid mountpoints
         foreach my $mnt (@$mounts) {
@@ -212,4 +223,5 @@
             }
 
+            # find vol_id(s) for mountpoint
             $r_query->execute($mnt, @$dev_info{qw( blocks used )});
             $log->debug("adding $mnt to db");
Index: trunk/Nebulous-Server/lib/Nebulous/Server/SQL.pm
===================================================================
--- trunk/Nebulous-Server/lib/Nebulous/Server/SQL.pm	(revision 24521)
+++ trunk/Nebulous-Server/lib/Nebulous/Server/SQL.pm	(revision 24539)
@@ -517,5 +517,6 @@
     name VARCHAR(255) UNIQUE NOT NULL,
     host VARCHAR(255) NOT NULL,
-    path VARCHAR(255) NOT NULL,
+    path VARCHAR(255) UNIQUE NOT NULL,
+    mountpoint VARCHAR(255) NOT NULL,
     allocate BOOLEAN DEFAULT FALSE,
     available BOOLEAN DEFAULT FALSE,
@@ -523,5 +524,5 @@
     PRIMARY KEY(vol_id),
     KEY(host(16)),
-    KEY(path(255)),
+    KEY(mountpoint(255)),
     KEY(allocate),
     KEY(available)
@@ -609,7 +610,7 @@
 
     -- store the okey checking state
-    SELECT @@FOREIGN_KEY_CHECKS INTO key_checks; 
+--    SELECT @@FOREIGN_KEY_CHECKS INTO key_checks; 
     -- disable foregin check checks to prevent deadlocks on the mountedvol table
-    SET FOREIGN_KEY_CHECKS=0;
+--    SET FOREIGN_KEY_CHECKS=0;
 
     -- make sure the temp table does not already exist... this can happy if the
@@ -630,10 +631,8 @@
     OPEN cur1;
 
-    DELETE FROM mountedvol;
-
     myloop: LOOP
         FETCH cur1 INTO vol_idvar, namevar, hostvar, pathvar, allocatevar, availablevar, xattrvar;
         IF `done` THEN LEAVE myloop; END IF;
-        INSERT INTO mountedvol
+        REPLACE INTO mountedvol
             SELECT mountpoint, total, used, vol_idvar, namevar, hostvar, pathvar, allocatevar, availablevar, xattrvar
             FROM
@@ -651,9 +650,9 @@
 
     -- restore the original key checking state
-    SET @@FOREIGN_KEY_CHECKS = key_checks; 
+--    SET @@FOREIGN_KEY_CHECKS = key_checks; 
 
     DROP TABLE IF EXISTS myvolume;
 
-    SET FOREIGN_KEY_CHECKS=1;
+--    SET FOREIGN_KEY_CHECKS=1;
 
     COMMIT;
Index: trunk/Nebulous-Server/scripts/dirize.pl
===================================================================
--- trunk/Nebulous-Server/scripts/dirize.pl	(revision 24521)
+++ trunk/Nebulous-Server/scripts/dirize.pl	(revision 24539)
@@ -44,13 +44,13 @@
 # non-existant value
 $db->do("SET FOREIGN_KEY_CHECKS=0");
-$db->do("UPDATE storage_object SET dir_id = 0");
+#$db->do("UPDATE storage_object SET dir_id = 0");
 
 # completely reset the directory table
-$db->do("DELETE FROM directory");
-$db->do("ALTER TABLE directory AUTO_INCREMENT = 1");
+#$db->do("DELETE FROM directory");
+#$db->do("ALTER TABLE directory AUTO_INCREMENT = 1");
 # make sure these duplicates can't happen again
-$db->do("alter table directory add unique key(dirname,parent_id)");
+#$db->do("alter table directory add unique key(dirname,parent_id)");
 # seed the root ('/') directory
-$db->do("INSERT INTO directory VALUES(1, '/', 1)");
+#$db->do("INSERT INTO directory VALUES(1, '/', 1)");
 
 my $i = 0;
