Skip to content
Snippets Groups Projects
Commit 1337906f authored by Per Cederqvist's avatar Per Cederqvist
Browse files

Added lysrdiff-move-many and lysrdiff-clone-tasks.

parent 1e32dfc2
No related branches found
No related tags found
No related merge requests found
......@@ -12,6 +12,8 @@ install: install-one-task
cp lysrdiff-df $(BINDIR)/
cp lysrdiff-move-obsolete $(BINDIR)/
cp lysrdiff-move-job $(BINDIR)/
cp lysrdiff-clone-tasks $(BINDIR)/
cp lysrdiff-move-many $(BINDIR)/
cp lysrdiff-label-disk $(BINDIR)/
cp lysrdiff-sizechange.py $(BINDIR)/
......
#!/bin/sh
for disk in 1 2
do
for copy in A B
do
for part in 0 1
do
id="/lysrdiff/$disk/$copy/$part/lysrdiff.id"
if [ -f "$id" ]
then
if [ "`cat $id`" != "$disk $copy $part" ]
then
echo wrong disk mounted at /lysrdiff/$disk/$copy/$part >&2
else
cp /lysrdiff/$disk/perm/$part/lysrdiff/tasks \
/lysrdiff/$disk/$copy/$part/lysrdiff/tasks.tmp \
&& mv -f /lysrdiff/$disk/$copy/$part/lysrdiff/tasks.tmp \
/lysrdiff/$disk/$copy/$part/lysrdiff/tasks
fi
fi
done
done
done
#!/bin/sh
usage () {
echo $0: usage:
echo " $0 fromdisk/frompart todisk/topart size"
echo
echo Example:
echo " $0 1/0 2/1 12"
echo would move 12 GB from /lysrdiff/1/perm/0 to /lysrdiff/2/perm/1.
echo
echo Please use lysrdiff-move-obsolete to fix the clones.
}
if [ $# -ne 3 ]
then
usage >&2
exit 1
fi
case "$1" in
*/*) ;;
*) usage;
exit 1;;
esac
case "$2" in
*/*) ;;
*) usage;
exit 1;;
esac
SRC_DISK=`echo $1 | sed 's%/.*%%'`
SRC_PART=`echo $1 | sed 's%.*/%%'`
DST_DISK=`echo $2 | sed 's%/.*%%'`
DST_PART=`echo $2 | sed 's%.*/%%'`
SIZE_GB=$3
SRC_ID=/lysrdiff/$SRC_DISK/perm/$SRC_PART/lysrdiff.id
DST_ID=/lysrdiff/$DST_DISK/perm/$DST_PART/lysrdiff.id
free_space () {
stat -f -c '%f * %S' $1|xargs expr
}
if [ $SRC_ID = $DST_ID ]
then
echo cannot move to self >&2
exit 1
fi
DST_START_SIZE=`free_space $DST_ID`
GB=`expr 1024 '*' 1024 '*' 1024`
SIZE_BYTES=`expr $SIZE_GB '*' $GB`
DST_TARGET_SIZE=`expr $DST_START_SIZE - $SIZE_BYTES`
if [ $DST_TARGET_SIZE -lt $GB ]
then
echo This move would leave less than 1 GB free space >&2
exit 1
fi
while [ `free_space $DST_ID` -gt $DST_TARGET_SIZE ]
do
lysrdiff-move-job $SRC_DISK/$SRC_PART $DST_DISK/$DST_PART || exit 1
done
echo Move complete.
echo
echo Please use lysrdiff-move-obsolete to clean up.
exit 0
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment