|
0 |
. /lib/partman/lib/base.sh
|
|
1 |
|
0 | 2 |
# Sets $virtual; used by other functions here.
|
1 | 3 |
check_virtual () {
|
2 | |
open_dialog VIRTUAL $oldid
|
3 | |
read_line virtual
|
4 | |
close_dialog
|
|
4 |
open_dialog VIRTUAL $oldid
|
|
5 |
read_line virtual
|
|
6 |
close_dialog
|
5 | 7 |
}
|
6 | 8 |
|
7 | 9 |
get_real_device () {
|
8 | |
local backupdev num
|
9 | |
# A weird way to get the real device path. The partition numbers
|
10 | |
# in parted_server may be changed and the partition table is still
|
11 | |
# not commited to the disk
|
12 | |
backupdev=/var/lib/partman/backup/${dev#/var/lib/partman/devices/}
|
13 | |
if [ -f $backupdev/$oldid/view -a -f $backupdev/device ]; then
|
14 | |
num=$(sed 's/^[^0-9]*\([0-9]*\)[^0-9].*/\1/' $backupdev/$oldid/view)
|
15 | |
bdev=$(cat $backupdev/device)
|
16 | |
case $bdev in
|
17 | |
*/disc)
|
18 | |
bdev=${bdev%/disc}/part$num
|
19 | |
;;
|
20 | |
/dev/[hs]d[a-z])
|
21 | |
bdev=$bdev$num
|
22 | |
;;
|
23 | |
*)
|
24 | |
log "get_real_device: strange device name $bdev"
|
25 | |
return
|
26 | |
;;
|
27 | |
esac
|
28 | |
if [ ! -b $bdev ]; then
|
29 | |
bdev=
|
30 | |
fi
|
31 | |
fi
|
|
10 |
local backupdev num
|
|
11 |
# A weird way to get the real device path. The partition numbers
|
|
12 |
# in parted_server may be changed and the partition table is still
|
|
13 |
# not commited to the disk.
|
|
14 |
backupdev=/var/lib/partman/backup/${dev#/var/lib/partman/devices/}
|
|
15 |
if [ -f $backupdev/$oldid/view ] && [ -f $backupdev/device ]; then
|
|
16 |
num=$(sed 's/^[^0-9]*\([0-9]*\)[^0-9].*/\1/' $backupdev/$oldid/view)
|
|
17 |
bdev=$(cat $backupdev/device)
|
|
18 |
case $bdev in
|
|
19 |
*/disc)
|
|
20 |
bdev=${bdev%/disc}/part$num
|
|
21 |
;;
|
|
22 |
/dev/[hs]d[a-z])
|
|
23 |
bdev=$bdev$num
|
|
24 |
;;
|
|
25 |
*)
|
|
26 |
log "get_real_device: strange device name $bdev"
|
|
27 |
return
|
|
28 |
;;
|
|
29 |
esac
|
|
30 |
if [ ! -b $bdev ]; then
|
|
31 |
bdev=
|
|
32 |
fi
|
|
33 |
fi
|
32 | 34 |
}
|
33 | 35 |
|
34 | 36 |
do_ntfsresize () {
|
|
41 | 43 |
}
|
42 | 44 |
|
43 | 45 |
get_ntfs_resize_range () {
|
44 | |
local bdev size
|
45 | |
open_dialog GET_VIRTUAL_RESIZE_RANGE $oldid
|
46 | |
read_line minsize cursize maxsize
|
47 | |
close_dialog
|
48 | |
get_real_device
|
49 | |
if [ "$bdev" ]; then
|
50 | |
if ! do_ntfsresize -f -i $bdev; then
|
51 | |
logger -t partman "Error running 'ntfsresize --info'"
|
52 | |
return 1
|
53 | |
fi
|
54 | |
size=$(echo "$ntfsresize" \
|
55 | |
| grep '^You might resize at' \
|
56 | |
| sed 's/^You might resize at \([0-9]*\) bytes.*/\1/' \
|
57 | |
| grep '^[0-9]*$')
|
58 | |
if [ "$size" ]; then
|
59 | |
minsize=$size
|
60 | |
fi
|
61 | |
fi
|
|
46 |
local bdev size
|
|
47 |
open_dialog GET_VIRTUAL_RESIZE_RANGE $oldid
|
|
48 |
read_line minsize cursize maxsize
|
|
49 |
close_dialog
|
|
50 |
get_real_device
|
|
51 |
if [ "$bdev" ]; then
|
|
52 |
if ! do_ntfsresize -f -i $bdev; then
|
|
53 |
logger -t partman "Error running 'ntfsresize --info'"
|
|
54 |
return 1
|
|
55 |
fi
|
|
56 |
size=$(echo "$ntfsresize" | \
|
|
57 |
grep '^You might resize at' | \
|
|
58 |
sed 's/^You might resize at \([0-9]*\) bytes.*/\1/' | \
|
|
59 |
grep '^[0-9]*$')
|
|
60 |
if [ "$size" ]; then
|
|
61 |
minsize=$size
|
|
62 |
fi
|
|
63 |
fi
|
62 | 64 |
}
|
63 | 65 |
|
64 | 66 |
get_ext2_resize_range () {
|
65 | |
local bdev tune2fs block_size block_count free_blocks
|
66 | |
open_dialog GET_VIRTUAL_RESIZE_RANGE $oldid
|
67 | |
read_line minsize cursize maxsize
|
68 | |
close_dialog
|
69 | |
get_real_device
|
70 | |
if [ "$bdev" ]; then
|
71 | |
if ! tune2fs="$(tune2fs -l $bdev)"; then
|
72 | |
logger -t partman "Error running 'tune2fs -l $bdev'"
|
73 | |
return 1
|
74 | |
fi
|
75 | |
block_size="$(echo "$tune2fs" | grep '^Block size:' | head -n1 | sed 's/.*:[[:space:]]*//')"
|
76 | |
block_count="$(echo "$tune2fs" | grep '^Block count:' | head -n1 | sed 's/.*:[[:space:]]*//')"
|
77 | |
free_blocks="$(echo "$tune2fs" | grep '^Free blocks:' | head -n1 | sed 's/.*:[[:space:]]*//')"
|
78 | |
if expr "$block_size" : '[0-9][0-9]*$' >/dev/null && \
|
79 | |
expr "$block_count" : '[0-9][0-9]*$' >/dev/null && \
|
80 | |
expr "$free_blocks" : '[0-9][0-9]*$' >/dev/null; then
|
81 | |
minsize="$(expr \( "$block_count" - "$free_blocks" \) \* "$block_size")"
|
82 | |
fi
|
83 | |
fi
|
84 | |
return 0
|
|
67 |
local bdev tune2fs block_size block_count free_blocks
|
|
68 |
open_dialog GET_VIRTUAL_RESIZE_RANGE $oldid
|
|
69 |
read_line minsize cursize maxsize
|
|
70 |
close_dialog
|
|
71 |
get_real_device
|
|
72 |
if [ "$bdev" ]; then
|
|
73 |
if ! tune2fs="$(tune2fs -l $bdev)"; then
|
|
74 |
logger -t partman "Error running 'tune2fs -l $bdev'"
|
|
75 |
return 1
|
|
76 |
fi
|
|
77 |
block_size="$(echo "$tune2fs" | grep '^Block size:' | \
|
|
78 |
head -n1 | sed 's/.*:[[:space:]]*//')"
|
|
79 |
block_count="$(echo "$tune2fs" | grep '^Block count:' | \
|
|
80 |
head -n1 | sed 's/.*:[[:space:]]*//')"
|
|
81 |
free_blocks="$(echo "$tune2fs" | grep '^Free blocks:' | \
|
|
82 |
head -n1 | sed 's/.*:[[:space:]]*//')"
|
|
83 |
if expr "$block_size" : '[0-9][0-9]*$' >/dev/null && \
|
|
84 |
expr "$block_count" : '[0-9][0-9]*$' >/dev/null && \
|
|
85 |
expr "$free_blocks" : '[0-9][0-9]*$' >/dev/null; then
|
|
86 |
minsize="$(expr \( "$block_count" - "$free_blocks" \) \* "$block_size")"
|
|
87 |
fi
|
|
88 |
fi
|
|
89 |
return 0
|
85 | 90 |
}
|
86 | 91 |
|
87 | 92 |
get_resize_range () {
|
88 | |
open_dialog GET_RESIZE_RANGE $oldid
|
89 | |
read_line minsize cursize maxsize
|
90 | |
close_dialog
|
|
93 |
open_dialog GET_RESIZE_RANGE $oldid
|
|
94 |
read_line minsize cursize maxsize
|
|
95 |
close_dialog
|
91 | 96 |
}
|
92 | 97 |
|
93 | 98 |
human_resize_range () {
|
94 | |
hminsize=$(longint2human $minsize)
|
95 | |
hcursize=$(longint2human $cursize)
|
96 | |
hmaxsize=$(longint2human $maxsize)
|
97 | |
minpercent="$(expr 100 \* "$minsize" / "$maxsize")"
|
|
99 |
hminsize=$(longint2human $minsize)
|
|
100 |
hcursize=$(longint2human $cursize)
|
|
101 |
hmaxsize=$(longint2human $maxsize)
|
|
102 |
minpercent="$(expr 100 \* "$minsize" / "$maxsize")"
|
98 | 103 |
}
|
99 | 104 |
|
100 | 105 |
ask_for_size () {
|
101 | |
local noninteractive digits minmb
|
102 | |
noninteractive=true
|
103 | |
while true; do
|
104 | |
newsize=''
|
105 | |
while [ ! "$newsize" ]; do
|
106 | |
db_set partman-partitioning/new_size "$hcursize"
|
107 | |
db_subst partman-partitioning/new_size MINSIZE "$hminsize"
|
108 | |
db_subst partman-partitioning/new_size MAXSIZE "$hmaxsize"
|
109 | |
db_subst partman-partitioning/new_size PERCENT "$minpercent%"
|
110 | |
db_input critical partman-partitioning/new_size || $noninteractive
|
111 | |
noninteractive="return 1"
|
112 | |
db_go || return 1
|
113 | |
db_get partman-partitioning/new_size
|
114 | |
case "$RET" in
|
115 | |
max)
|
116 | |
newsize=$maxsize
|
117 | |
;;
|
118 | |
*%)
|
119 | |
digits=$(expr "$RET" : '\([1-9][0-9]*\) *%$')
|
120 | |
if [ "$digits" ]; then
|
121 | |
maxmb=$(expr 0000000"$maxsize" : '0*\(..*\)......$')
|
122 | |
newsize=$(($digits * $maxmb / 100))000000
|
123 | |
fi
|
124 | |
;;
|
125 | |
*)
|
126 | |
if valid_human "$RET"; then
|
127 | |
newsize=$(human2longint "$RET")
|
128 | |
fi
|
129 | |
;;
|
130 | |
esac
|
131 | |
if [ -z "$newsize" ]; then
|
132 | |
db_input high partman-partitioning/bad_new_size || true
|
133 | |
db_go || true
|
134 | |
elif ! longint_le "$newsize" "$maxsize"; then
|
135 | |
db_input high partman-partitioning/big_new_size || true
|
136 | |
db_go || true
|
|
106 |
local noninteractive digits minmb
|
|
107 |
noninteractive=true
|
|
108 |
while true; do
|
137 | 109 |
newsize=''
|
138 | |
elif ! longint_le "$minsize" "$newsize"; then
|
139 | |
db_input high partman-partitioning/small_new_size || true
|
140 | |
db_go || true
|
141 | |
newsize=''
|
142 | |
fi
|
|
110 |
while [ ! "$newsize" ]; do
|
|
111 |
db_set partman-partitioning/new_size "$hcursize"
|
|
112 |
db_subst partman-partitioning/new_size MINSIZE "$hminsize"
|
|
113 |
db_subst partman-partitioning/new_size MAXSIZE "$hmaxsize"
|
|
114 |
db_subst partman-partitioning/new_size PERCENT "$minpercent%"
|
|
115 |
db_input critical partman-partitioning/new_size || $noninteractive
|
|
116 |
noninteractive="return 1"
|
|
117 |
db_go || return 1
|
|
118 |
db_get partman-partitioning/new_size
|
|
119 |
case "$RET" in
|
|
120 |
max)
|
|
121 |
newsize=$maxsize
|
|
122 |
;;
|
|
123 |
*%)
|
|
124 |
digits=$(expr "$RET" : '\([1-9][0-9]*\) *%$')
|
|
125 |
if [ "$digits" ]; then
|
|
126 |
maxmb=$(expr 0000000"$maxsize" : '0*\(..*\)......$')
|
|
127 |
newsize=$(($digits * $maxmb / 100))000000
|
|
128 |
fi
|
|
129 |
;;
|
|
130 |
*)
|
|
131 |
if valid_human "$RET"; then
|
|
132 |
newsize=$(human2longint "$RET")
|
|
133 |
fi
|
|
134 |
;;
|
|
135 |
esac
|
|
136 |
if [ -z "$newsize" ]; then
|
|
137 |
db_input high partman-partitioning/bad_new_size || true
|
|
138 |
db_go || true
|
|
139 |
elif ! longint_le "$newsize" "$maxsize"; then
|
|
140 |
db_input high partman-partitioning/big_new_size || true
|
|
141 |
db_go || true
|
|
142 |
newsize=''
|
|
143 |
elif ! longint_le "$minsize" "$newsize"; then
|
|
144 |
db_input high partman-partitioning/small_new_size || true
|
|
145 |
db_go || true
|
|
146 |
newsize=''
|
|
147 |
fi
|
|
148 |
done
|
|
149 |
|
|
150 |
if perform_resizing; then break; fi
|
143 | 151 |
done
|
144 | |
if perform_resizing; then break; fi
|
145 | |
done
|
146 | |
return 0
|
|
152 |
return 0
|
147 | 153 |
}
|
148 | 154 |
|
149 | 155 |
perform_resizing () {
|
150 | |
if [ "$virtual" = no ]; then
|
151 | |
commit_changes partman-partitioning/new_size_commit_failed || exit 100
|
152 | |
fi
|
153 | |
|
154 | |
disable_swap
|
155 | |
|
156 | |
if \
|
157 | |
[ "$virtual" = no ] \
|
158 | |
&& [ -f $oldid/detected_filesystem ] \
|
159 | |
&& [ "$(cat $oldid/detected_filesystem)" = ntfs ]
|
160 | |
then
|
161 | |
# resize NTFS
|
162 | |
db_progress START 0 1000 partman/text/please_wait
|
163 | |
db_progress INFO partman-partitioning/progress_resizing
|
164 | |
if longint_le "$cursize" "$newsize"; then
|
165 | |
open_dialog VIRTUAL_RESIZE_PARTITION $oldid $newsize
|
166 | |
read_line newid
|
167 | |
close_dialog
|
168 | |
open_dialog COMMIT
|
169 | |
close_dialog
|
170 | |
open_dialog PARTITION_INFO $newid
|
171 | |
read_line x1 x2 x3 x4 x5 path x7
|
172 | |
close_dialog
|
173 | |
# Wait for the device file to be created again
|
174 | |
update-dev
|
175 | |
if ! echo y | do_ntfsresize -f $path; then
|
176 | |
logger -t partman "Error resizing the NTFS file system to the partition size"
|
177 | |
db_input high partman-partitioning/new_size_commit_failed || true
|
178 | |
db_go || true
|
|
156 |
if [ "$virtual" = no ]; then
|
|
157 |
commit_changes partman-partitioning/new_size_commit_failed || exit 100
|
|
158 |
fi
|
|
159 |
|
|
160 |
disable_swap
|
|
161 |
|
|
162 |
if [ "$virtual" = no ] && \
|
|
163 |
[ -f $oldid/detected_filesystem ] && \
|
|
164 |
[ "$(cat $oldid/detected_filesystem)" = ntfs ]; then
|
|
165 |
|
|
166 |
# Resize NTFS
|
|
167 |
db_progress START 0 1000 partman/text/please_wait
|
|
168 |
db_progress INFO partman-partitioning/progress_resizing
|
|
169 |
if longint_le "$cursize" "$newsize"; then
|
|
170 |
open_dialog VIRTUAL_RESIZE_PARTITION $oldid $newsize
|
|
171 |
read_line newid
|
|
172 |
close_dialog
|
|
173 |
open_dialog COMMIT
|
|
174 |
close_dialog
|
|
175 |
open_dialog PARTITION_INFO $newid
|
|
176 |
read_line x1 x2 x3 x4 x5 path x7
|
|
177 |
close_dialog
|
|
178 |
# Wait for the device file to be created again
|
|
179 |
update-dev
|
|
180 |
|
|
181 |
if ! echo y | do_ntfsresize -f $path; then
|
|
182 |
logger -t partman "Error resizing the NTFS file system to the partition size"
|
|
183 |
db_input high partman-partitioning/new_size_commit_failed || true
|
|
184 |
db_go || true
|
|
185 |
db_progress STOP
|
|
186 |
exit 100
|
|
187 |
fi
|
|
188 |
else
|
|
189 |
open_dialog COMMIT
|
|
190 |
close_dialog
|
|
191 |
open_dialog PARTITION_INFO $oldid
|
|
192 |
read_line x1 x2 x3 x4 x5 path x7
|
|
193 |
close_dialog
|
|
194 |
# Wait for the device file to be created
|
|
195 |
update-dev
|
|
196 |
|
|
197 |
if echo y | do_ntfsresize -f --size "$newsize" $path; then
|
|
198 |
open_dialog VIRTUAL_RESIZE_PARTITION $oldid $newsize
|
|
199 |
read_line newid
|
|
200 |
close_dialog
|
|
201 |
# Wait for the device file to be created
|
|
202 |
update-dev
|
|
203 |
|
|
204 |
if ! echo y | do_ntfsresize -f $path; then
|
|
205 |
logger -t partman "Error resizing the NTFS file system to the partition size"
|
|
206 |
db_input high partman-partitioning/new_size_commit_failed || true
|
|
207 |
db_go || true
|
|
208 |
db_progress STOP
|
|
209 |
exit 100
|
|
210 |
fi
|
|
211 |
else
|
|
212 |
logger -t partman "Error resizing the NTFS file system"
|
|
213 |
db_input high partman-partitioning/new_size_commit_failed || true
|
|
214 |
db_go || true
|
|
215 |
db_progress STOP
|
|
216 |
exit 100
|
|
217 |
fi
|
|
218 |
fi
|
|
219 |
db_progress SET 1000
|
179 | 220 |
db_progress STOP
|
180 | |
exit 100
|
181 | |
fi
|
|
221 |
|
|
222 |
elif [ "$virtual" = no ] && \
|
|
223 |
[ -f $oldid/detected_filesystem ] && \
|
|
224 |
([ "$(cat $oldid/detected_filesystem)" = ext2 ] || \
|
|
225 |
[ "$(cat $oldid/detected_filesystem)" = ext3 ]); then
|
|
226 |
|
|
227 |
# Resize ext2/ext3; parted can handle simple cases but can't deal
|
|
228 |
# with certain common features such as resize_inode
|
|
229 |
fs="$(cat $oldid/detected_filesystem)"
|
|
230 |
db_progress START 0 1000 partman/text/please_wait
|
|
231 |
open_dialog PARTITION_INFO $oldid
|
|
232 |
read_line num x2 x3 x4 x5 x6 x7
|
|
233 |
close_dialog
|
|
234 |
|
|
235 |
db_metaget "partman/filesystem_short/$fs" description || RET=
|
|
236 |
[ "$RET" ] || RET="$fs"
|
|
237 |
db_subst partman-basicfilesystems/progress_checking TYPE "$RET"
|
|
238 |
db_subst partman-basicfilesystems/progress_checking PARTITION "$num"
|
|
239 |
db_subst partman-basicfilesystems/progress_checking DEVICE "$(humandev $(cat device))"
|
|
240 |
db_progress INFO partman-basicfilesystems/progress_checking
|
|
241 |
|
|
242 |
if longint_le "$cursize" "$newsize"; then
|
|
243 |
open_dialog VIRTUAL_RESIZE_PARTITION $oldid $newsize
|
|
244 |
read_line newid
|
|
245 |
close_dialog
|
|
246 |
open_dialog COMMIT
|
|
247 |
close_dialog
|
|
248 |
open_dialog PARTITION_INFO $newid
|
|
249 |
read_line x1 x2 x3 x4 x5 path x7
|
|
250 |
close_dialog
|
|
251 |
else
|
|
252 |
open_dialog COMMIT
|
|
253 |
close_dialog
|
|
254 |
open_dialog PARTITION_INFO $oldid
|
|
255 |
read_line x1 x2 x3 x4 x5 path x7
|
|
256 |
close_dialog
|
|
257 |
fi
|
|
258 |
# Wait for the device file to be created
|
|
259 |
update-dev
|
|
260 |
|
|
261 |
e2fsck_code=0
|
|
262 |
e2fsck -f -p $path || e2fsck_code=$?
|
|
263 |
if [ $e2fsck_code -gt 1 ]; then
|
|
264 |
db_subst partman-basicfilesystems/check_failed TYPE "$fs"
|
|
265 |
db_subst partman-basicfilesystems/check_failed PARTITION "$num"
|
|
266 |
db_subst partman-basicfilesystems/check_failed DEVICE "$(humandev $(cat device))"
|
|
267 |
db_set partman-basicfilesystems/check_failed 'true'
|
|
268 |
db_input critical partman-basicfilesystems/check_failed || true
|
|
269 |
db_go || true
|
|
270 |
db_get partman-basicfilesystems/check_failed
|
|
271 |
if [ "$RET" = 'true' ]; then
|
|
272 |
exit 100
|
|
273 |
fi
|
|
274 |
fi
|
|
275 |
|
|
276 |
db_progress INFO partman-partitioning/progress_resizing
|
|
277 |
db_progress SET 500
|
|
278 |
if longint_le "$cursize" "$newsize"; then
|
|
279 |
if ! resize2fs $path; then
|
|
280 |
logger -t partman "Error resizing the ext2/ext3 file system to the partition size"
|
|
281 |
db_input high partman-partitioning/new_size_commit_failed || true
|
|
282 |
db_go || true
|
|
283 |
db_progress STOP
|
|
284 |
exit 100
|
|
285 |
fi
|
|
286 |
else
|
|
287 |
if resize2fs $path "$(expr "$newsize" / 1024)K"; then
|
|
288 |
open_dialog VIRTUAL_RESIZE_PARTITION $oldid $newsize
|
|
289 |
read_line newid
|
|
290 |
close_dialog
|
|
291 |
# Wait for the device file to be created
|
|
292 |
update-dev
|
|
293 |
|
|
294 |
if ! resize2fs $path; then
|
|
295 |
logger -t partman "Error resizing the ext2/ext3 file system to the partition size"
|
|
296 |
db_input high partman-partitioning/new_size_commit_failed || true
|
|
297 |
db_go || true
|
|
298 |
db_progress STOP
|
|
299 |
exit 100
|
|
300 |
fi
|
|
301 |
else
|
|
302 |
logger -t partman "Error resizing the ext2/ext3 file system"
|
|
303 |
db_input high partman-partitioning/new_size_commit_failed || true
|
|
304 |
db_go || true
|
|
305 |
db_progress STOP
|
|
306 |
exit 100
|
|
307 |
fi
|
|
308 |
fi
|
|
309 |
db_progress SET 1000
|
|
310 |
db_progress STOP
|
|
311 |
|
182 | 312 |
else
|
183 | |
open_dialog COMMIT
|
184 | |
close_dialog
|
185 | |
open_dialog PARTITION_INFO $oldid
|
186 | |
read_line x1 x2 x3 x4 x5 path x7
|
187 | |
close_dialog
|
188 | |
# Wait for the device file to be created
|
189 | |
update-dev
|
190 | |
if echo y | do_ntfsresize -f --size "$newsize" $path; then
|
191 | |
open_dialog VIRTUAL_RESIZE_PARTITION $oldid $newsize
|
|
313 |
|
|
314 |
# Resize virtual partitions, ext2, ext3, swap, fat16, fat32
|
|
315 |
# and probably reiserfs
|
|
316 |
name_progress_bar partman-partitioning/progress_resizing
|
|
317 |
open_dialog RESIZE_PARTITION $oldid $newsize
|
192 | 318 |
read_line newid
|
193 | 319 |
close_dialog
|
194 | |
# Wait for the device file to be created
|
195 | |
update-dev
|
196 | |
if ! echo y | do_ntfsresize -f $path; then
|
197 | |
logger -t partman "Error resizing the NTFS file system to the partition size"
|
198 | |
db_input high partman-partitioning/new_size_commit_failed || true
|
199 | |
db_go || true
|
200 | |
db_progress STOP
|
201 | |
exit 100
|
202 | |
fi
|
203 | |
else
|
204 | |
logger -t partman "Error resizing the NTFS file system"
|
205 | |
db_input high partman-partitioning/new_size_commit_failed || true
|
206 | |
db_go || true
|
207 | |
db_progress STOP
|
208 | |
exit 100
|
209 | |
fi
|
210 | |
fi
|
211 | |
db_progress SET 1000
|
212 | |
db_progress STOP
|
213 | |
elif \
|
214 | |
[ "$virtual" = no ] \
|
215 | |
&& [ -f $oldid/detected_filesystem ] \
|
216 | |
&& ([ "$(cat $oldid/detected_filesystem)" = ext2 ] \
|
217 | |
|| [ "$(cat $oldid/detected_filesystem)" = ext3 ])
|
218 | |
then
|
219 | |
# resize ext2/ext3; parted can handle simple cases but can't deal
|
220 | |
# with certain common features such as resize_inode
|
221 | |
fs="$(cat $oldid/detected_filesystem)"
|
222 | |
db_progress START 0 1000 partman/text/please_wait
|
223 | |
open_dialog PARTITION_INFO $oldid
|
224 | |
read_line num x2 x3 x4 x5 x6 x7
|
225 | |
close_dialog
|
226 | |
db_metaget "partman/filesystem_short/$fs" description || RET=
|
227 | |
[ "$RET" ] || RET="$fs"
|
228 | |
db_subst partman-basicfilesystems/progress_checking TYPE "$RET"
|
229 | |
db_subst partman-basicfilesystems/progress_checking PARTITION "$num"
|
230 | |
db_subst partman-basicfilesystems/progress_checking DEVICE "$(humandev $(cat device))"
|
231 | |
db_progress INFO partman-basicfilesystems/progress_checking
|
232 | |
if longint_le "$cursize" "$newsize"; then
|
233 | |
open_dialog VIRTUAL_RESIZE_PARTITION $oldid $newsize
|
234 | |
read_line newid
|
235 | |
close_dialog
|
236 | |
open_dialog COMMIT
|
237 | |
close_dialog
|
238 | |
open_dialog PARTITION_INFO $newid
|
239 | |
read_line x1 x2 x3 x4 x5 path x7
|
240 | |
close_dialog
|
|
320 |
|
|
321 |
fi
|
|
322 |
|
|
323 |
if [ "$newid" ] && [ "$newid" != "$oldid" ]; then
|
|
324 |
rm -rf $newid
|
|
325 |
mkdir $newid
|
|
326 |
cp -r $oldid/* $newid/
|
|
327 |
fi
|
|
328 |
if [ "$virtual" = no ]; then
|
|
329 |
for s in /lib/partman/init.d/*; do
|
|
330 |
if [ -x $s ]; then
|
|
331 |
$s || exit 100
|
|
332 |
fi
|
|
333 |
done
|
241 | 334 |
else
|
242 | |
open_dialog COMMIT
|
243 | |
close_dialog
|
244 | |
open_dialog PARTITION_INFO $oldid
|
245 | |
read_line x1 x2 x3 x4 x5 path x7
|
246 | |
close_dialog
|
247 | |
fi
|
248 | |
# Wait for the device file to be created
|
249 | |
update-dev
|
250 | |
e2fsck_code=0
|
251 | |
e2fsck -f -p $path || e2fsck_code=$?
|
252 | |
if [ $e2fsck_code -gt 1 ]; then
|
253 | |
db_subst partman-basicfilesystems/check_failed TYPE "$fs"
|
254 | |
db_subst partman-basicfilesystems/check_failed PARTITION "$num"
|
255 | |
db_subst partman-basicfilesystems/check_failed DEVICE "$(humandev $(cat device))"
|
256 | |
db_set partman-basicfilesystems/check_failed 'true'
|
257 | |
db_input critical partman-basicfilesystems/check_failed || true
|
258 | |
db_go || true
|
259 | |
db_get partman-basicfilesystems/check_failed
|
260 | |
if [ "$RET" = 'true' ]; then
|
261 | |
exit 100
|
262 | |
fi
|
263 | |
fi
|
264 | |
db_progress INFO partman-partitioning/progress_resizing
|
265 | |
db_progress SET 500
|
266 | |
if longint_le "$cursize" "$newsize"; then
|
267 | |
if ! resize2fs $path; then
|
268 | |
logger -t partman "Error resizing the ext2/ext3 file system to the partition size"
|
269 | |
db_input high partman-partitioning/new_size_commit_failed || true
|
270 | |
db_go || true
|
271 | |
db_progress STOP
|
272 | |
exit 100
|
273 | |
fi
|
274 | |
else
|
275 | |
if resize2fs $path "$(expr "$newsize" / 1024)K"; then
|
276 | |
open_dialog VIRTUAL_RESIZE_PARTITION $oldid $newsize
|
277 | |
read_line newid
|
|
335 |
partitions=''
|
|
336 |
open_dialog PARTITIONS
|
|
337 |
while { read_line num part size type fs path name; [ "$part" ]; }; do
|
|
338 |
partitions="$partitions $part"
|
|
339 |
done
|
278 | 340 |
close_dialog
|
279 | |
# Wait for the device file to be created
|
280 | |
update-dev
|
281 | |
if ! resize2fs $path; then
|
282 | |
logger -t partman "Error resizing the ext2/ext3 file system to the partition size"
|
283 | |
db_input high partman-partitioning/new_size_commit_failed || true
|
284 | |
db_go || true
|
285 | |
db_progress STOP
|
286 | |
exit 100
|
287 | |
fi
|
288 | |
else
|
289 | |
logger -t partman "Error resizing the ext2/ext3 file system"
|
290 | |
db_input high partman-partitioning/new_size_commit_failed || true
|
291 | |
db_go || true
|
292 | |
db_progress STOP
|
293 | |
exit 100
|
294 | |
fi
|
295 | |
fi
|
296 | |
db_progress SET 1000
|
297 | |
db_progress STOP
|
298 | |
else
|
299 | |
# resize virtual partitions, ext2, ext3, swap, fat16, fat32
|
300 | |
# and probably reiserfs
|
301 | |
name_progress_bar partman-partitioning/progress_resizing
|
302 | |
open_dialog RESIZE_PARTITION $oldid $newsize
|
303 | |
read_line newid
|
304 | |
close_dialog
|
305 | |
fi
|
306 | |
|
307 | |
if [ -n "$newid" -a "$newid" != "$oldid" ]; then
|
308 | |
[ ! -e "$newid" ] || rm -rf $newid
|
309 | |
mkdir $newid
|
310 | |
cp -r $oldid/* $newid/
|
311 | |
fi
|
312 | |
if [ "$virtual" = no ]; then
|
313 | |
for s in /lib/partman/init.d/*; do
|
314 | |
if [ -x $s ]; then
|
315 | |
$s || exit 100
|
316 | |
fi
|
317 | |
done
|
318 | |
else
|
319 | |
partitions=''
|
320 | |
open_dialog PARTITIONS
|
321 | |
while { read_line num part size type fs path name; [ "$part" ]; }; do
|
322 | |
partitions="$partitions $part"
|
323 | |
done
|
324 | |
close_dialog
|
325 | |
for part in $partitions; do
|
326 | |
update_partition $dev $part
|
327 | |
done
|
328 | |
fi
|
329 | |
}
|
|
341 |
for part in $partitions; do
|
|
342 |
update_partition $dev $part
|
|
343 |
done
|
|
344 |
fi
|
|
345 |
}
|