Whamcloud - gitweb
LU-657 test: limit the write size in run_dd
[fs/lustre-release.git] / lustre / scripts / lustre_up14
1 #!/bin/bash
2 #
3 # Reads old MDS config logs for transferring to a MGS
4 #
5 ###############################################################################
6
7 TMP=${TMP:-/tmp/logs}
8
9 # Usage
10 usage() {
11         cat >&2 <<EOF
12
13 Usage:  `basename $0` <mdsdev> <newfsname>
14
15         <mdsdev>                the MDS disk device (e.g. /dev/sda1)
16         <newfsname>             the name of the new filesystem (e.g. testfs)
17
18         This script will extract old config logs from an MDS device to a
19         temporary location ($TMP). During the upgrade procedure, mount the
20         MGS disk as type ldiskfs (e.g. mount -t ldiskfs /dev/sda
21         /mnt/temp), then copy these logs into the CONFIGS directory on the
22         MGS (e.g. /mnt/temp/CONFIGS).  Logs from many MDS's can be added
23         in this way.  When done, unmount the MGS, and then re-mount it as
24         type lustre to start the service.
25
26 EOF
27         exit 1
28 }
29
30 if [ $# -lt 2 ]; then
31         usage
32 fi
33
34 DEV=$1
35 FSNAME=$2
36 DEBUGFS="debugfs -c -R"
37 mkdir -p $TMP
38
39 FILES=`$DEBUGFS "ls -l LOGS" $DEV | awk '{print $9}' | awk '/[a-z]/ {print $1}'`
40
41 for FILE in ${FILES}; do 
42     $DEBUGFS "dump LOGS/$FILE $TMP/temp" $DEV 2> /dev/null
43     MDC=`strings $TMP/temp | grep MDC`
44     LOV=`strings $TMP/temp | grep lov`
45     if [ -n "$MDC" ]; then
46         TYPE=client
47     else
48         if [ -n "$LOV" ]; then
49             TYPE=MDT0000
50         else
51             echo "Can't determine type for log '$FILE', skipping"
52             continue 
53         fi
54     fi
55     echo -n "Copying log '$FILE' to '${FSNAME}-${TYPE}'. Okay [y/n]?"
56     read OK
57     if [ "$OK" = "y" ]; then
58         mv $TMP/temp $TMP/${FSNAME}-${TYPE}
59     else
60         rm $TMP/temp
61     fi
62 done
63
64 echo ls -l $TMP
65 ls -l $TMP
66