Commit b0e86d9b authored by Mike Hibler's avatar Mike Hibler

First step is allowing a different "standard" disk layout:

 * Somewhere in the DB, probably images, we will store the MBR "version"
   required by a partition (non-whole-disk) image.  This info will be
   passed to the client (us).

 * We use this info to install the correct MBR on the disk before starting
   frisbee.  The various MBRs (all two of them) will be stored in the
   frisbee MFS since they are only 512 bytes each.

This checkin handles the client-side of things and is backward compatible
(i.e., assumes MBR version 1 if nothing is passed).

One immediate benefit is that this will allow us to install a partition
image on a new (or otherwise MBR-free) disk, as it detects the case of no
MBR and installs one.
parent 9c98fbd0
......@@ -24,6 +24,58 @@ else
# Update the MBR of the given disk to the indicated "version."
# XXX this is somewhat of a hack right now. We recognize two
# versions of the MBR:
# v1 (partition 1 size 6281352)
# v2 (partition 1 size 12305790)
# Currently we only install a new MBR if the existing one is the
# wrong size, just in case the user has customized the boot program.
tweakmbr() {
dd if=/dev/$_DSK of=/dev/null bs=512 count=1 2>/dev/null || {
echo "WARNING: could not read from $_DSK, MBR not changed"
_size=`fdisk -s $_DSK 2>/dev/null | sed -n -e 's/^ *1: *[0-9][0-9]* *\([0-9][0-9]*\).*$/\1/p'`
case ${_size}s in
# special case: no part1 so probably no MBR at all, make sure we install
echo "Found no MBR on $_DSK, installing version $_NEW"
echo "WARNING: custom MBR on $_DSK, not changed"
if [ $_CUR = $_NEW ]; then
# now set it if we can
if [ ! -r "/etc/emulab/mbr${_NEW}.dd" ]; then
echo "WARNING: cannot find MBR version $_NEW, not installed"
echo "Installing MBR version $_NEW ..."
dd if=/etc/emulab/mbr${_NEW}.dd of=/dev/$_DSK bs=512 count=1
# Function to zero all potential superblocks in the DOS partitions that
# could interfere with the OSes on the image being loaded.
......@@ -87,6 +139,8 @@ ZFILL=`echo $LOADINFO | awk -F= '{ printf $6 }' | awk -F' ' '{ print $1 }'`
ACPI=`echo $LOADINFO | awk -F= '{ printf $7 }' | awk -F' ' '{ print $1 }'`
MBR=`echo $LOADINFO | awk -F= '{ printf $8 }' | awk -F' ' '{ print $1 }'`
if [ "$PARTITION" != "0" ]; then
......@@ -184,6 +238,14 @@ if [ x"$ADDRESS" != x ]; then
# For slice images, ensure that the MBR is the correct version
# and replace if not.
if [ "$PARTITION" != "0" ]; then
tweakmbr $DISK $MBR
# If not zeroing the disk and we are loading a full disk image
# we need to ensure that we at least invalidate any old superblocks
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