Whamcloud - gitweb
obdsyncd: removed from CVS
[fs/lustre-release.git] / lustre / demos / snapsetup.sh
1 #! /bin/bash
2 # Utility script to create an OBD snapshot.  If an existing filesystem is
3 # not already mounted on /mnt/obd, we call the basic OBD setup script to
4 # create and mount a filesystem for us.
5 OBDDIR="`dirname $0`/.."
6 . $OBDDIR/demos/config.sh
7
8
9 # prepare the snapshot drive with a file to be COW'd
10 if [ ! -d /mnt/obd/lost+found ]; then 
11     $OBDDIR/demos/obdfssetup.sh
12     if [ x$? != x0 ]; then 
13         echo "Error running obdfssetup.sh"
14         exit 4
15    fi
16 fi
17
18 if [ ! -f $MNTOBD/hello ]; then
19         $OBDDIR/demos/obdtest.sh
20         if [ x$? != x0 ]; then 
21             echo "Error in obdfssetup.sh"
22         exit 4
23     fi
24 fi
25
26 plog umount $MNTOBD
27
28 plog insmod $OBDDIR/snap/obdsnap.o
29
30 rm -f $SNAPTABLE
31
32 plog log "NEW SNAP SETUP"
33 # Create two snapshots using the OBD snapshot driver.  One will be the
34 # "current" snapshot (in obd device 1), where changes will take place.
35 # The current snapshot is required in order to use the filesystem.  The
36 # second will be a snapshot of the filesystem taken "now" (in obd device 2)
37 # that will remain static (historical read-only) filesystem as changes
38 # are made to the current snapshot.
39 $OBDDIR/class/obdcontrol -f << EOF
40 snaptable
41 $SNAPTABLE
42 a
43 1
44 current
45 a
46 2
47 now
48 q
49 y
50 snapset 0 $SNAPTABLE
51 device /dev/obd1
52 attach snap_obd 0 1 0
53 setup
54 device /dev/obd2
55 attach snap_obd 0 2 0
56 setup
57 quit
58 EOF
59
60 # Mount the two filesystems.  The filesystem under $MNTOBD will be the
61 # one where changes are made, while $MNTSNAP will contain the original
62 # files at the point when the snapshot was taken.
63
64 [ ! -d "$MNTOBD" ] &&  mkdir $MNTOBD
65 [ ! -d "$MNTSNAP" ] &&  mkdir $MNTSNAP
66 plog mount -t obdfs -odevice=/dev/obd1 none $MNTOBD
67 plog mount -t obdfs -oro,device=/dev/obd2 none $MNTSNAP