Whamcloud - gitweb
862b271f74fa4d0538407ffd33babf790c1c14ae
[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" = "" ] && OBDDIR=".."
7 . $OBDDIR/demos/config.sh
8
9 [ ! -d $MNTOBD/lost+found ] && $OBDDIR/demos/obdsetup.sh
10
11 [ ! -f $MNTDIR/hello ] && $OBDDIR/demos/obdtest.sh
12
13 umount $MNTOBD
14
15 insmod $OBDDIR/snap/obdsnap.o
16
17 rm -f $SNAPTABLE
18
19 plog log "NEW SNAP SETUP"
20 # Create two snapshots using the OBD snapshot driver.  One will be the
21 # "current" snapshot (in obd device 1), where changes will take place.
22 # The current snapshot is required in order to use the filesystem.  The
23 # second will be a snapshot of the filesystem taken "now" (in obd device 2)
24 # that will remain static (historical read-only) filesystem as changes
25 # are made to the current snapshot.
26 $OBDDIR/class/obdcontrol -f << EOF
27 snaptable
28 $SNAPTABLE
29 a
30 1
31 current
32 a
33 2
34 now
35 q
36 y
37 snapset 0 $SNAPTABLE
38 device /dev/obd1
39 attach snap_obd 0 1 0
40 setup snap_obd
41 device /dev/obd2
42 attach snap_obd 0 2 0
43 setup snap_obd
44 quit
45 EOF
46
47 # Mount the two filesystems.  The filesystem under $MNTOBD will be the
48 # one where changes are made, while $MNTSNAP will contain the original
49 # files at the point when the snapshot was taken.
50 [ ! -d $MNTOBD ] && mkdir $MNTOBD
51 plog mount -t obdfs -odevice=/dev/obd1 /dev/obd1 $MNTOBD
52 [ ! -d $MNTSNAP ] && mkdir $MNTSNAP
53 plog mount -t obdfs -oro,device=/dev/obd2 /dev/obd2 $MNTSNAP