Commit d93fe4f9 authored by Ryan Jackson's avatar Ryan Jackson

Zap superblocks and MBR on all disks if in reloading experiment to prevent

Linux mounting a filesystem with the same label or UUID from the wrong disk.
parent 25694da3
......@@ -83,6 +83,18 @@ tweakmbr() {
dd if=/etc/emulab/mbr${_NEW}.dd of=/dev/$_DSK bs=512 count=1
}
find_disks() {
local disks
for d in `sed -n 's/^\([a-z]*[0-9][0-9]*\): [0-9][0-9]*MB/\1/p' /var/run/dmesg.boot`; do
case $d in
ad*|da*|ar*|aacd*) disks="$disks $d"
esac
done
echo $disks
}
#
# Function to zero all potential superblocks in the DOS partitions that
# could interfere with the OSes on the image being loaded.
......@@ -122,6 +134,7 @@ $BINDIR/tmcc state RELOADSETUP
BOSSINFO=`$BINDIR/tmcc bossinfo`
LOADINFO=`$BINDIR/tmcc loadinfo`
STATUS=`$BINDIR/tmcc status`
# For testing purposes.
#BOSSINFO='boss.emulab.net 155.101.128.70'
......@@ -326,6 +339,23 @@ if [ x"$ADDRESS" != x ]; then
zapsuperblocks $DISK
fi
# HACK ALERT: If we're reloading we need to zap the superblocks and
# MBRs of any other disks in the system. This is to prevent Linux from
# finding an old filesystem with the same label or UUID and mounting
# that instead of the right one. We skip the disks that are mounted
# and the disk we're going to write to.
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
zapsuperblocks $d
dd if=/dev/zero of=/dev/$disk bs=512 count=1
done
;;
esac
$BINDIR/tmcc state RELOADING
if [ x"$imagefile" != x ]; then
......
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