equal
deleted
inserted
replaced
|
1 #! /bin/sh |
|
2 |
|
3 set -e |
|
4 |
|
5 cleanup() { |
|
6 umount $mnt 2>/dev/null || true |
|
7 losetup -vd $loop || true |
|
8 rm -r $dir |
|
9 } |
|
10 |
|
11 trap cleanup EXIT |
|
12 |
|
13 dir=`mktemp -d` |
|
14 |
|
15 image=$dir/image |
|
16 mnt=$dir/mnt |
|
17 record=$dir/dumpdates |
|
18 |
|
19 echo "# creating sparse image file $image" |
|
20 dd of=$image count=0 bs=1M seek=128 |
|
21 |
|
22 echo "# creating the mountpoint" |
|
23 mkdir $dir/mnt |
|
24 |
|
25 x=$(losetup -fv $image) |
|
26 loop=${x##* } |
|
27 echo "# image connected to $loop" |
|
28 |
|
29 mkfs -t ext4 $loop |
|
30 |
|
31 # installing sample data |
|
32 mount $loop $mnt |
|
33 mkdir $mnt/abc.d |
|
34 touch $mnt/abc.d/foo |
|
35 sync |
|
36 umount $mnt |
|
37 |
|
38 dump -0 -u -D $record -f $dir/dump-0 $loop |
|
39 |
|
40 # remove the dir |
|
41 mount $loop $mnt |
|
42 mv $mnt/abc.d/foo $mnt/ |
|
43 rmdir $mnt/abc.d |
|
44 sync |
|
45 umount $mnt |
|
46 |
|
47 dump -1 -u -D $record -f $dir/dump-1 $loop |
|
48 |
|
49 # now starting a shell |
|
50 cd $dir |
|
51 $SHELL |