Commit 8174369d authored by Mike Hibler's avatar Mike Hibler

Fixes for CD boot:

1. tbbootconfig: ensure block is zeroed on first init, fix cut/paste error
2. rc.frisbee: cleanup interface to slicefix
3. slicefix: cleanup, make it work correctly, init tbboot block for cd boot

Unrelated:
1. link-agent makefile: build link-agent when doing client-install
parent 83d7a973
/*
* EMULAB-COPYRIGHT
* Copyright (c) 2000-2003 University of Utah and the Flux Group.
* Copyright (c) 2000-2004 University of Utah and the Flux Group.
* All rights reserved.
*/
......@@ -160,7 +160,7 @@ main(argc, argv)
if (bootfromdisk != -1)
tbboot_hdr.bootfromdisk = bootfromdisk;
if (validimage != -1)
tbboot_hdr.validimage = bootfromdisk;
tbboot_hdr.validimage = validimage;
if (emulabkey) {
if (strlen(emulabkey) > TBBOOT_MAXKEYLEN - 1) {
......@@ -214,6 +214,7 @@ readhdr(int devfd, tbboot_t *tbhdr)
warnx("Bad magic number in header!");
if (! force)
exit(1);
bzero(tbhdr, sizeof(*tbhdr));
tbhdr->magic1 = TBBOOT_MAGIC1;
tbhdr->magic2 = TBBOOT_MAGIC2;
tbhdr->version = TBBOOT_VERSION;
......
......@@ -42,7 +42,7 @@ $(PROGRAMS): ../lib/libevent.a ../lib/event.h
install:
client-install:
client-install: link-agent
$(INSTALL_PROGRAM) link-agent \
$(DESTDIR)$(CLIENT_BINDIR)/link-agent
......
......@@ -19,7 +19,7 @@ LOADINFO=`$BINDIR/tmcc loadinfo`
# For testing purposes.
#BOSSINFO='boss.emulab.net 155.101.128.70'
#LOADINFO='ADDR=234.5.6.69:4444 PART=0' # for testing
#LOADINFO='ADDR=234.5.6.69:4444'
BOSSIP=`echo $BOSSINFO | awk '{ print $2 }'`
......@@ -32,11 +32,12 @@ fi
ADDRESS=`echo $LOADINFO | awk -F= '{ printf $2 }' | awk -F' ' '{ print $1 }'`
PARTITION=`echo $LOADINFO | awk -F= '{ printf $3 }' | awk -F' ' '{ print $1 }'`
PARTITION=${PARTITION:-'0'}
PARTOS=`echo $LOADINFO | awk -F= '{ printf $4 }' | awk -F' ' '{ print $1 }'`
DISK=`echo $LOADINFO | awk -F= '{ printf $5 }' | awk -F' ' '{ print $1 }'`
DISK=${DISK:-'ad0'}
if [ x"$PARTITION" != x -a "$PARTITION" != "0" ]; then
if [ "$PARTITION" != "0" ]; then
SLICE="-s $PARTITION";
case $PARTOS in
FreeBSD)
......@@ -103,16 +104,13 @@ if [ x"$ADDRESS" != x ]; then
echo "Frisbee run finished";
echo "Resizing final disk partition";
$BINDIR/growdisk -vW /dev/$DISK;
if [ x"$PTYPE" != x -a -x $BINDIR/slicefix ]; then
#
# XXX limit the use of slicefix for now to just
# those machines with "ad4" as their root disk
#
if [ -x $BINDIR/slicefix -a "$DISK" = "ad4" ]; then
echo "Adjusting slice-related files";
if [ x"$SLICE" != x ]; then
$BINDIR/slicefix $PARTITION $DISK
else
$BINDIR/slicefix 1 $DISK
$BINDIR/slicefix 2 $DISK
$BINDIR/slicefix 3 $DISK
$BINDIR/slicefix 4 $DISK
fi
$BINDIR/slicefix $PARTITION $DISK
fi
echo "Image load complete, rebooting ...";
$BINDIR/tmcc state RELOADDONE;
......
......@@ -5,6 +5,12 @@
# All rights reserved.
#
if [ -r /etc/emulab/paths.sh ]; then
. /etc/emulab/paths.sh
else
BINDIR=/etc/testbed
fi
disk="ad0"
case $# in
......@@ -20,12 +26,9 @@ case $# in
exit 1
esac
ptype=`fdisk -$part | grep sysid | sed 's/.*sysid \([0-9][0-9]*\),.*/\1/'`
ptype=${ptype:-0}
dofreebsd() {
# see if there is a root ('a') partition on this BSD slice
`disklabel ${disk}s${part} 2>1 | grep -s -E '^[ ]+a:' >/dev/null` || {
`disklabel ${disk}s${part} 2>&1 | grep -s -E '^[ ]+a:' >/dev/null` || {
return 1
}
......@@ -39,12 +42,12 @@ dofreebsd() {
echo "Mount of $rootdev failed"
return 1
}
sed -i .orig -e "s/${disk}s./${disk}s${part}/" /mnt/etc/fstab || {
sed -E -i .orig -e "s;^/dev/[a-zA-Z]+[0-9]+s[0-9]+;/dev/${disk}s${part};" /mnt/etc/fstab || {
echo "Failed to update /etc/fstab"
umount $rootdev
return 1
}
sed -i .orig -e "s/${disk}s./${disk}s${part}/" /mnt/etc/dumpdates || {
sed -E -i .orig -e "s;^/dev/[a-zA-Z]+[0-9]+s[0-9]+;/dev/${disk}s${part};" /mnt/etc/dumpdates || {
echo "Failed to update /etc/dumpdates"
umount $rootdev
return 1
......@@ -55,18 +58,53 @@ dofreebsd() {
dolinux() {
# need to update fstab, lilo.conf
echo "do not do linux yet"
return 0
}
case $ptype in
165)
fixone() {
echo "*** ${disk}s${part}:"
ptype=`fdisk -${part} ${disk} | grep sysid | sed 's/.*sysid \([0-9][0-9]*\),.*/\1/'`
ptype=${ptype:-0}
case $ptype in
165)
dofreebsd
exit $?
return $?
;;
0)
131)
dolinux
return $?
;;
*)
0)
echo "unused"
;;
*)
echo "ignoring partition type $ptype"
;;
esac
return 0
}
case $part in
0)
part=1; fixone
part=2; fixone
part=3; fixone
part=4; fixone
# for the CD boot, we need to intialize the magic boot block
if [ -e /cdrom.inf -a -x $BINDIR/tbbootconfig ]; then
$BINDIR/tbbootconfig -f -c 1 -k 0 -m 1 /dev/${disk}
fi
;;
1|2|3|4)
fixone
;;
*)
echo "bad partition: $part"
false
;;
esac
exit 0
exit $?
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