Whamcloud - gitweb
f7ef4dfe3c51b8fcc09a8acfd0cfdc6782af0969
[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
7 . $OBDDIR/demos/config.sh
8
9
10 # prepare the snapshot drive with a file to be COW'd
11
12 mount | grep $MNTOBD > /dev/null 2>&1
13 if [ x$? = x0 ]; then 
14     echo "Stuff still mounted on $MNTOBD; clean up first."
15     exit 
16 fi
17
18 if [ ! -d /mnt/obd/lost+found ]; then 
19     $OBDDIR/demos/obdfssetup.sh
20     if [ x$? != x0 ]; then 
21         echo "Error in obdfssetup.sh"
22         exit 4
23    fi
24 fi
25
26 if [ ! -f $MNTOBD/hello ]; then
27         $OBDDIR/demos/obdtest.sh
28         if [ x$? != x0 ]; then 
29             echo "Error in obdfssetup.sh"
30         exit 4
31     fi
32 fi
33
34 umount $MNTOBD
35
36 insmod $OBDDIR/snap/obdsnap.o
37
38 rm -f $SNAPTABLE
39
40 plog log "NEW SNAP SETUP"
41 # Create two snapshots using the OBD snapshot driver.  One will be the
42 # "current" snapshot (in obd device 1), where changes will take place.
43 # The current snapshot is required in order to use the filesystem.  The
44 # second will be a snapshot of the filesystem taken "now" (in obd device 2)
45 # that will remain static (historical read-only) filesystem as changes
46 # are made to the current snapshot.
47 $OBDDIR/class/obdcontrol -f << EOF
48 snaptable
49 $SNAPTABLE
50 a
51 1
52 current
53 a
54 2
55 now
56 q
57 y
58 snapset 0 $SNAPTABLE
59 device /dev/obd1
60 attach snap_obd 0 1 0
61 setup
62 device /dev/obd2
63 attach snap_obd 0 2 0
64 setup
65 quit
66 EOF
67
68 # Mount the two filesystems.  The filesystem under $MNTOBD will be the
69 # one where changes are made, while $MNTSNAP will contain the original
70 # files at the point when the snapshot was taken.
71
72 plog mount -t obdfs -odevice=/dev/obd1 none $MNTOBD
73 plog mount -t obdfs -oro,device=/dev/obd2 none $MNTSNAP