Index: branches/releng-11/nanobsd/tools/image
===================================================================
--- branches/releng-11/nanobsd/tools/image	(revision 13707)
+++ branches/releng-11/nanobsd/tools/image	(revision 13709)
@@ -53,39 +53,37 @@
   # Release update cycle depends on the release we are coming from
   echo "# Host has FreeBSD Release: $release"
-  if echo $release | grep -q '^[1234567]\.*-RELEASE'; then
+  updatecmd="/tmp/update$$"
+  cat >> $updatecmd <<'EOF'
+#
+# Pre-cleaning of /cfg
+#
+mount -wo noatime /cfg || exit 1
+find /cfg -type f | grep -v -e '^/cfg/\(pf.hybrid.conf.local\|resolv.conf\|motd\|rc.conf.local\)$' \
+	-e '^/cfg/local/\(ntp.drift\|dhcpd.conf\|dnsmasq.conf\|unbound.wleiden.conf\|wleiden.yaml\)$' \
+	-e '^/cfg/ssh/ssh_host_*' \
+	-e '^/cfg/ssh/authorized_keys$' \
+	| xargs rm -v || exit 1
+umount /cfg || exit 1
+
+#
+# Release specific update
+#
+EOF
+  if echo $release | grep -q -e '^9\.[0-9]-RELEASE[-$]'; then
+    cat >> $updatecmd <<'EOF'
+tunefs -L WLIMGs3 /dev/ada0s3 || exit 1
+echo /tools/update || exit 1
+EOF
+  elif echo $release | grep -q -e '^11\.[0-9]-RELEASE[-$]'; then
+    cat >> $updatecmd <<'EOF'
+echo /tools/update || exit 1
+EOF
+  else
     p_err "$release not supported for upgrade"
     exit 1
-  elif echo $release | grep -q '^8\.*-RELEASE'; then
-    # Hack to make sure we update the fstab the right way when converting from
-    # 8.X-RELEASE to 9.X-RELEASE. ad0 naming changed to ada0, secondly an
-    # specific update script had to be called.
-    command="/tmp/update$$"
-    cat > $command <<'EOF'
-# Write new image
-echo "FreeBSD Release : `uname -r`"
-echo "Active Partition: `df -H / | tail -1`"
-if [ "`uname -r`" = "9.0-RELEASE" ]; then 
-  echo "Error not valid update cycle!"
-  exit 1
-else
-  if df / | grep -q '1a ' ; then
-    echo  "New Partition   : /dev/ad0s2a"
-    echo /tools/updatep2
-
-    # Quirck to fix partitions
-    # mount -uwo noatime /dev/ad0s2a
-    # sed -i "" "s/ada0s1/ada0s2/" /mnt/conf/base/etc/fstab /mnt/etc/fstab
-    # umount 
-  else
-    echo  "New Partition   : /dev/ad0s1a"
-    echo /tools/updatep1
-  fi
-fi
-EOF
-    cat $command | ssh $host "cat > $command" || exit 1
-    cat $img | ssh $host "sh $command" || exit 1
-  else
-    cat $img | ssh $host /tools/update || exit 1
-  fi
+  fi
+
+  cat $updatecmd | ssh $host "cat > $updatecmd" || exit 1
+  cat $img | ssh $host "sh -x $updatecmd" || exit 1
 
   if $do_reboot; then
