Commit 899ed1d2 authored by Mike Hibler's avatar Mike Hibler
Browse files

Un-hack the image capture and distribution scripts now that we handle GPT.

parent 315910bd
#!/usr/bin/perl -w
#
# Copyright (c) 2000-2014 University of Utah and the Flux Group.
# Copyright (c) 2000-2015 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -185,31 +185,10 @@ if ($^O eq 'linux') {
$device = "/dev/sd$dunit";
}
#
# XXX we don't support GPT right now, so we can only do Linux partition
# images directly from the partition device.
#
my $isgpt = 0;
if ($^O eq 'linux' && -x "/sbin/sgdisk" &&
!system("$sudo /sbin/sgdisk $device >/dev/null 2>&1")) {
if ($slicenum == 0) {
print STDERR
"Cannot take whole disk image of GPT disk\n";
exit(3);
}
$isgpt = 1;
}
#
# If imageid is defined, we use the frisbee uploader.
#
my $cmd = "$sudo $zipper";
if ($isgpt) {
# force imagezip to treat as an ext filesystem and use the slice device
$cmd .= " -S 131 $device$slicenum $filename";
} else {
$cmd .= " $slice $device $filename";
}
my $cmd = "$sudo $zipper $slice $device $filename";
if (defined($imageid)) {
# use basic shell sleezy trick to capture exit status from imagezip
$cmd = "( $cmd || echo \$? > /tmp/imagezip.stat )";
......
......@@ -573,21 +573,6 @@ sub process_image($)
exit(3);
}
#
# XXX we don't support GPT right now, so we can only do Linux partition
# images directly from the partition device.
#
my $isgpt = 0;
if ($^O eq 'linux' && -x "/sbin/sgdisk" &&
!mysystem("$sudo /sbin/sgdisk ".$iinfo{$iid}{'disk'}." >/dev/null 2>&1")) {
if ($iinfo{$iid}{'part'} == 0) {
print STDERR
"Cannot take whole disk image of GPT disk\n";
exit(3);
}
$isgpt = 1;
}
#
# Fire off the command:
#
......@@ -606,13 +591,8 @@ sub process_image($)
if (exists($iinfo{$iid}{'izopts'})) {
$cmd .= $iinfo{$iid}{'izopts'};
}
if ($isgpt) {
# force imagezip to treat as an ext filesystem
$cmd .= " -S 131";
} else {
if ($iinfo{$iid}{'part'} != 0) {
$cmd .= " -s " . $iinfo{$iid}{'part'};
}
if ($iinfo{$iid}{'part'} != 0) {
$cmd .= " -s " . $iinfo{$iid}{'part'};
}
if (exists($iinfo{$iid}{'sigfile'})) {
$cmd .= " -H $localdir/sigfile";
......@@ -621,10 +601,6 @@ sub process_image($)
$cmd .= " -U $localdir/nsigfile";
}
$cmd .= " " . $iinfo{$iid}{'disk'};
if ($isgpt) {
# use the slice device
$cmd .= $iinfo{$iid}{'part'};
}
my $image = $iinfo{$iid}{'iname'};
if ($iinfo{$iid}{'method'} eq "file") {
......
......@@ -315,6 +315,7 @@ loadone() {
echo "Need to download $ADDR"
isurl=1
ispath=0
if [ ! -d /images ]; then
echo "Need to create or mount /images directory!"
return 1
......@@ -326,6 +327,7 @@ loadone() {
imagefile=`echo $ADDR | sed -e 's,^http[s]*://[^/]*/,,'`
imagefile="/images/$imagefile"
elif [ x"$ispath" != x ]; then
isurl=0
ispath=1
if [ ! -e $ADDR ]; then
......
......@@ -251,27 +251,32 @@ loadone() {
fi
#
# XXX we don't grok GPT yet, so we must write directly to the
# partition device (no -s option). We also use a fixed GPT which
# has only partitions 1, 2, and 15. And we only do Linux right now.
# XXX we only recognize 4 partitions in Emulab right now, so
# there is no way to directly specify the boot partition (15).
# So if PART == 3 (the conventional swap partition) we treat
# that as 15.
#
# XXX XXX we only recognize 4 partitions in Emulab right now, so
# map partition 4 from the DB to partition 15!
if [ "$_PART" == "3" ]; then
_PART=15
fi
#
# XXX we only do Linux right now.
#
if [ "$_PART" != "0" ]; then
case $_PART in
4)
_PART=15
;;
1|2|15)
1|2|4|15)
;;
*)
echo "Cannot load partition '$_PART', must be 1, 2, or 15"
echo "Cannot load partition '$_PART', must be 1, 2, 4, or 15"
return 1
;;
esac
SLICE="-s $_PART"
case $PARTOS in
Linux|Unknown|Other)
Fedora|Linux|Unknown|Other)
SLICE="$SLICE -D 131"
PTYPE=131
;;
*)
echo "Cannot load OS type '$PARTOS' image"
......@@ -444,17 +449,12 @@ loadone() {
zapsuperblocks $_DISK
fi
# XXX for now, since we are actually writing to the partition device
if [ $_PART -eq 0 ]; then
$_PART=""
fi
if [ x"$imagefile" != x ]; then
echo "`date`: Running $BINDIR/imageunzip -f -o -O -W 32 $ZFILL $imagefile /dev/${_DISK}${_PART}"
$BINDIR/imageunzip -o -O -W 32 $ZFILL $imagefile /dev/${_DISK}${_PART}
else
echo "`date`: Running $BINDIR/frisbee -f -S $SERVER $MEMARGS $KA $ZFILL $IMAGEID /dev/$_DISK$_PART"
$BINDIR/frisbee -S $SERVER $MEMARGS $KA $ZFILL $IMAGEID /dev/$_DISK$_PART
echo "`date`: Running $BINDIR/frisbee -f -S $SERVER $MEMARGS $KA $ZFILL $SLICE $IMAGEID /dev/$_DISK"
$BINDIR/frisbee -S $SERVER $MEMARGS $KA $ZFILL $SLICE $IMAGEID /dev/$_DISK
fi
fstat=$?
......@@ -503,7 +503,7 @@ fixone() {
101)
RPART=2
;;
102)
*)
RPART=1
;;
esac
......
#!/bin/sh
#
# Copyright (c) 2000-2014 University of Utah and the Flux Group.
# Copyright (c) 2000-2015 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -268,7 +268,7 @@ dolinux() {
fixone() {
echo "*** ${disk}${part}:"
ptype=`sgdisk -p /dev/$disk | \
sed -n "s/^ *$part *.* \([0-9a-fA-F][0-9a-fA-F]*\) *$/\1/p"`
sed -n "s/^ *$part *.*iB *\([0-9A-F][0-9A-F]*\) */\1/p"`
ptype=${ptype:-0}
case $ptype in
......@@ -276,12 +276,6 @@ fixone() {
dolinux
return $?
;;
8200)
echo "ignoring Linux swap partition"
;;
7|0x7)
echo "ignoring NTFS partition"
;;
0)
;;
*)
......@@ -295,6 +289,7 @@ case $part in
0)
part=1; fixone
part=2; fixone
part=4; fixone
part=15; fixone
# when fixing all partitions, do not fail on an error
......
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