blob: 5339daf378d2afd4a7ec1ab878b17533c4a0b7bf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
#!/bin/bash
set -o nounset
set -o errexit
set -o errtrace
set -o pipefail
while getopts "hd:m:f:" arg; do
case $arg in
h)
usage
exit 0
;;
d)
DEV=$OPTARG
;;
m)
MNT=$OPTARG
;;
f)
FS=$OPTARG
;;
esac
done
if [[ -z ${DEV-} ]]; then
echo "Required parameter -d missing: device to test"
exit 1
fi
if [[ -z ${MNT-} ]]; then
echo "Required parameter -m missing: mount point"
exit 1
fi
if [[ -z ${FS-} ]]; then
echo "Required parameter -f missing: filesystem type"
exit 1
fi
umount $DEV >/dev/null 2>&1 || true
umount $MNT >/dev/null 2>&1 || true
blkdiscard -s $DEV >/dev/null 2>&1 ||
blkdiscard $DEV >/dev/null 2>&1 ||
true
wipefs -af $DEV
case $FS in
bcache)
bcache format -f $DEV
;;
ext4)
mkfs.ext4 -F $DEV
;;
ext4-no-journal)
mkfs.ext4 -F -O ^has_journal $DEV
;;
xfs)
mkfs.xfs -f $DEV
;;
btrfs)
mkfs.btrfs -f $DEV
;;
esac
mount $DEV $MNT
|