Commit faa7c6f1 authored by Ryan Jackson's avatar Ryan Jackson

Wipe superblocks and mbr of all disks when reloading to keep from accidentally

mounting the wrong filesystem if it has the same UUID or label as the one we want.
parent d93fe4f9
......@@ -273,6 +273,22 @@ write_image()
return $rc
}
find_disks() {
local disks
if [ $OS = "FreeBSD" ]; then
for d in `dmesg | sed -n 's/^\([a-z]*[0-9][0-9]*\): [0-9][0-9]*MB/\1/p'`; do
case $d in
ad*|da*|ar*|aacd*) disks="$disks $d"
esac
done
elif [ $OS = "Linux" ]; then
disks=`ls /sys/block/[hs]d* | sed 's;.*/\([^/]*\)$;\1;'`
fi
echo $disks
}
$BINDIR/tmcc state RELOADSETUP
time=30
......@@ -290,6 +306,7 @@ fi
BOSSINFO=`$BINDIR/tmcc bossinfo`
BOSSIP=${BOSSINFO##* }
STATUS=`$BINDIR/tmcc status`
# For testing purposes.
#BOSSINFO='boss.emulab.net 155.101.128.70'
......@@ -406,6 +423,18 @@ if [ $is_remote -eq 0 -a $PARTITION -eq 0 -a $ZFILL -eq 0 ]; then
zap_superblocks /dev/$DISK
fi
case $STATUS in
*ALLOCATED=emulab-ops/reloading*)
disks=`find_disks`
for d in $disks; do
[ $d = $DISK ] && continue
mount | grep "^/dev/$d" > /dev/null && continue
zap_superblocks $d
dd if=/dev/zero of=/dev/$disk bs=512 count=1
done
;;
esac
install_mbr /dev/$DISK $MBR
echo "Resizing final disk partition"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment