2014-11-19 14:42:19 +00:00
|
|
|
#!/bin/bash
|
2011-06-08 21:17:31 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# This postscript sets up a scratch area on the local disk for stateless
|
|
|
|
# nodes. It is for Linux only.
|
2011-06-15 14:10:34 +00:00
|
|
|
# If run with -f flag, it will wipe out all the contents on the disk and
|
|
|
|
# repartition the disk before setting up the scratch area.
|
2011-06-08 21:17:31 +00:00
|
|
|
#
|
|
|
|
#====================================================================
|
|
|
|
ME="setupscratch"
|
|
|
|
|
2011-06-15 14:10:34 +00:00
|
|
|
mydir="/scratch"
|
|
|
|
umount $mydir
|
|
|
|
|
|
|
|
if [[ $1 != "-f" ]]
|
2011-06-08 21:17:31 +00:00
|
|
|
then
|
2011-06-15 14:10:34 +00:00
|
|
|
if grep sda1 /proc/partitions >/dev/null 2>&1
|
|
|
|
then
|
|
|
|
echo Autodetected existing /dev/sda1
|
2012-05-15 08:15:32 +00:00
|
|
|
logger -t xcat -p local4.info $ME Autodetected existing /dev/sda1
|
2011-06-15 14:10:34 +00:00
|
|
|
echo Checking filesystem /dev/sda1
|
2012-05-15 08:15:32 +00:00
|
|
|
logger -t xcat -p local4.info $ME Checking filesystem /dev/sda1
|
2011-06-15 14:10:34 +00:00
|
|
|
fsck -y /dev/sda1
|
|
|
|
mkdir -p $mydir
|
|
|
|
echo mounting existing /dev/sda1 to $mydir
|
2012-05-15 08:15:32 +00:00
|
|
|
logger -t xcat -p local4.info $ME mounting existing /dev/sda1 to $mydir
|
2011-06-15 14:10:34 +00:00
|
|
|
if mount /dev/sda1 $mydir
|
|
|
|
then
|
|
|
|
echo
|
|
|
|
echo Done!
|
|
|
|
echo
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
echo mounting /dev/sda1 to $mydir failed
|
2012-05-15 08:15:32 +00:00
|
|
|
logger -t xcat -p local4.warning $ME mounting /dev/sda1 to $mydir failed
|
2011-06-15 14:10:34 +00:00
|
|
|
fi
|
|
|
|
fi
|
2011-06-08 21:17:31 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
echo Creating Partition
|
2012-05-15 08:15:32 +00:00
|
|
|
logger -t xcat -p local4.info $ME Creating Partition
|
2011-06-15 14:10:34 +00:00
|
|
|
parted -s /dev/sda mklabel gpt
|
|
|
|
parted -s -- /dev/sda mkpart primary ext3 0 -0
|
2011-06-08 21:17:31 +00:00
|
|
|
if grep sda1 /proc/partitions >/dev/null 2>&1
|
|
|
|
then
|
|
|
|
sleep 5
|
|
|
|
else
|
|
|
|
echo failed to create partition, exiting $ME
|
2012-05-15 08:15:32 +00:00
|
|
|
logger -t xcat -p local4.err $ME failed to create partition, exiting $ME
|
2011-06-08 21:17:31 +00:00
|
|
|
echo
|
|
|
|
echo Failed!
|
|
|
|
echo
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo Creating new ext3 filesystem: /dev/sda1
|
2012-05-15 08:15:32 +00:00
|
|
|
logger -t xcat -p local4.info $ME Creating new ext3 filesystem: /dev/sda1
|
2011-06-08 21:17:31 +00:00
|
|
|
mke2fs -j /dev/sda1
|
2011-06-15 14:10:34 +00:00
|
|
|
mkdir -p $mydir
|
|
|
|
echo mounting new /dev/sda1 to $mydir
|
2012-05-15 08:15:32 +00:00
|
|
|
logger -t xcat -p local4.info $ME mounting new /dev/sda1 to $mydir
|
2011-06-15 14:10:34 +00:00
|
|
|
mount /dev/sda1 $mydir
|
2011-06-08 21:17:31 +00:00
|
|
|
echo
|
|
|
|
echo Done!
|
|
|
|
echo
|
|
|
|
exit 0
|