-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathrepit-fs-f2fs.sh
114 lines (85 loc) · 2.63 KB
/
repit-fs-f2fs.sh
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#####################################################
# Lanchon REPIT - File System Handler #
# Copyright 2016, Lanchon #
#####################################################
#####################################################
# Lanchon REPIT is free software licensed under #
# the GNU General Public License (GPL) version 3 #
# and any later version. #
#####################################################
### f2fs
checkTools_fs_f2fs() {
# only require tools if actually needed
#checkTool mkfs.f2fs
#checkTool fsck.f2fs
:
}
processPar_f2fs_wipe_dry() {
local n=$1
local dev=$2
local oldStart=$3
local oldSize=$4
local newStart=$5
local newSize=$6
info "will format the partition in f2fs and trim it"
checkTool mkfs.f2fs
}
processPar_f2fs_wipe_wet() {
local n=$1
local dev=$2
local oldStart=$3
local oldSize=$4
local newStart=$5
local newSize=$6
local footerSize=$(parFooterSize $n)
local newFsSize=$(( newSize - footerSize ))
processParRecreate $n $oldStart $oldSize $newStart $newSize
processParWipeCryptoFooter $n $newStart $newSize $footerSize
info "formatting the partition in f2fs and trimming it"
mkfs.f2fs -t 1 $dev ${newFsSize}
}
checkFs_f2fs() {
local n=$1
local dev=$2
if [ -z "$(which fsck.f2fs)" ]; then
warning "skipping file system check (tool 'fsck.f2fs' is not available)"
else
info "checking the file system"
if ! fsck.f2fs -f $dev; then
fatal "file system errors in $(parName $n) could not be fixed"
fi
fi
}
processPar_f2fs_keep_dry() {
local n=$1
local dev=$2
local oldStart=$3
local oldSize=$4
local newStart=$5
local newSize=$6
if [ $(( newSize != oldSize )) -ne 0 ]; then
fatal "cannot resize f2fs partitions"
fi
if [ $(( newStart != oldStart )) -ne 0 ]; then
info "will move the f2fs partition"
warning "moving a big f2fs partition can take a very long time; it requires copying the complete partition, including its free space"
fi
#checkTool fsck.f2fs
checkFs_f2fs $n $dev
}
processPar_f2fs_keep_wet() {
local n=$1
local dev=$2
local oldStart=$3
local oldSize=$4
local newStart=$5
local newSize=$6
if [ $(( newSize != oldSize )) -ne 0 ]; then
fatal "assertion failed: cannot resize f2fs partitions"
fi
if [ $(( newStart != oldStart )) -ne 0 ]; then
info "moving the f2fs partition"
processParMove $n $oldStart $newStart $oldSize
checkFs_f2fs $n $dev
fi
}