Codebase list partman-partitioning / 7ce117f
Major whitespace cleanup and a few minor coding style fixes Source base.sh from resize.sh instead of the parent script. r50650 Frans Pop 16 years ago
8 changed file(s) with 485 addition(s) and 465 deletion(s). Raw diff Collapse all Expand all
1414 [ "$RET" = 'true' ] || exit 0
1515
1616 ask_for_source () {
17 local noninteractive
18 noninteractive=true
19 while true; do
20 source_dev=''
21 source_id=''
22 while [ ! "$source_id" ]; do
23 choices=$(partition_tree_choices)
24 debconf_select critical partman-partitioning/source_partition "$choices" asdfasdfasdf
25 case $? in
26 1)
27 $noninteractive
28 ;;
29 255)
30 return 1
31 ;;
32 esac
33 noninteractive='return 1'
34 source_dev=${RET%//*}
35 source_id=${RET#*//}
17 local noninteractive
18 noninteractive=true
19 while true; do
20 source_dev=''
21 source_id=''
22 while [ ! "$source_id" ]; do
23 choices=$(partition_tree_choices)
24 debconf_select critical partman-partitioning/source_partition "$choices" asdfasdfasdf
25 case $? in
26 1)
27 $noninteractive
28 ;;
29 255)
30 return 1
31 ;;
32 esac
33 noninteractive='return 1'
34 source_dev=${RET%//*}
35 source_id=${RET#*//}
36 done
37 source_dev=${source_dev##*/}
38 if perform_copying; then break; fi
3639 done
37 source_dev=${source_dev##*/}
38 if perform_copying; then break; fi
39 done
40 return 0
40 return 0
4141 }
4242
4343 perform_copying () {
44 commit_changes partman-partitioning/copy_commit_failed || exit 0
44 commit_changes partman-partitioning/copy_commit_failed || exit 0
4545
46 name_progress_bar partman-partitioning/progress_copying
47 open_dialog COPY_PARTITION $id $source_dev $source_id
48 close_dialog
46 name_progress_bar partman-partitioning/progress_copying
47 open_dialog COPY_PARTITION $id $source_dev $source_id
48 close_dialog
4949
50 for s in /lib/partman/init.d/*; do
51 if [ -x $s ]; then
52 $s || exit 0
53 fi
54 done
50 for s in /lib/partman/init.d/*; do
51 if [ -x $s ]; then
52 $s || exit 0
53 fi
54 done
5555 }
5656
5757 ask_for_source
00 #!/bin/sh
11
2 . /lib/partman/lib/base.sh
32 . /lib/partman/lib/resize.sh
43
54 dev=$2
1110
1211 if [ "$virtual" = no ] && [ -f $oldid/detected_filesystem ]; then
1312 case "$(cat $oldid/detected_filesystem)" in
14 ntfs)
15 if ! get_ntfs_resize_range; then
16 db_input critical partman-partitioning/impossible_resize || true
17 db_go || true
18 exit 1
19 fi
20 ;;
21 ext2|ext3)
22 if ! get_ext2_resize_range; then
23 db_input critical partman-partitioning/impossible_resize || true
24 db_go || true
25 exit 1
26 fi
27 ;;
28 *)
29 get_resize_range
30 ;;
13 ntfs)
14 if ! get_ntfs_resize_range; then
15 db_input critical partman-partitioning/impossible_resize || true
16 db_go || true
17 exit 1
18 fi
19 ;;
20 ext2|ext3)
21 if ! get_ext2_resize_range; then
22 db_input critical partman-partitioning/impossible_resize || true
23 db_go || true
24 exit 1
25 fi
26 ;;
27 *)
28 get_resize_range
29 ;;
3130 esac
3231 else
3332 get_resize_range
0 partman-partitioning (55) UNRELEASED; urgency=low
1
2 * Major whitespace cleanup and a few minor coding style fixes.
3 * Source base.sh from resize.sh instead of the parent script.
4
5 -- Frans Pop <fjp@debian.org> Thu, 27 Dec 2007 13:28:08 +0100
6
07 partman-partitioning (54) unstable; urgency=low
18
29 [ Frans Pop ]
1818 printf "new\t${RET}\n"
1919 ;;
2020 esac
21
1717 freehsize=$(longint2human $freesize)
1818
1919 ask_for_size () {
20 local noninteractive
21 noninteractive=true
22 while true; do
23 size=''
24 while [ ! "$size" ]; do
25 db_set partman-partitioning/new_partition_size "$freehsize"
26 db_subst partman-partitioning/new_partition_size MAXSIZE "$freehsize"
27 db_input critical partman-partitioning/new_partition_size ||
28 $noninteractive
29 noninteractive="return 1"
30 db_go || return 1
31 db_get partman-partitioning/new_partition_size
32
33 case "$RET" in
34 max)
35 size=$freesize
36 hsize="$freehsize"
37 ;;
38 *%)
39 digits=$(expr "$RET" : '\([1-9][0-9]*\) *%$')
40 if [ "$digits" ]; then
41 maxmb=$(expr 0000000"$freesize" : '0*\(..*\)......$')
42 size=$(($digits * $maxmb / 100))000000
43 fi
44 if [ "$digits" = 100 ]; then
45 hsize="$freehsize"
46 else
47 hsize=some_number
48 fi
49 ;;
50 *)
51 if valid_human "$RET"; then
52 size=$(human2longint "$RET")
53 fi
54 hsize="$RET"
55 ;;
56 esac
57
58 if [ -z "$size" ]; then
59 db_input high partman-partitioning/bad_new_partition_size || true
60 db_go || true
61 fi
62 done
63 if ask_for_type; then break; fi
64 done
65 return 0
20 local noninteractive
21 noninteractive=true
22 while true; do
23 size=''
24 while [ ! "$size" ]; do
25 db_set partman-partitioning/new_partition_size "$freehsize"
26 db_subst partman-partitioning/new_partition_size MAXSIZE "$freehsize"
27 db_input critical partman-partitioning/new_partition_size ||
28 $noninteractive
29 noninteractive="return 1"
30 db_go || return 1
31 db_get partman-partitioning/new_partition_size
32
33 case "$RET" in
34 max)
35 size=$freesize
36 hsize="$freehsize"
37 ;;
38 *%)
39 digits=$(expr "$RET" : '\([1-9][0-9]*\) *%$')
40 if [ "$digits" ]; then
41 maxmb=$(expr 0000000"$freesize" : '0*\(..*\)......$')
42 size=$(($digits * $maxmb / 100))000000
43 fi
44 if [ "$digits" = 100 ]; then
45 hsize="$freehsize"
46 else
47 hsize=some_number
48 fi
49 ;;
50 *)
51 if valid_human "$RET"; then
52 size=$(human2longint "$RET")
53 fi
54 hsize="$RET"
55 ;;
56 esac
57
58 if [ -z "$size" ]; then
59 db_input high partman-partitioning/bad_new_partition_size || true
60 db_go || true
61 fi
62 done
63 if ask_for_type; then break; fi
64 done
65 return 0
6666 }
6767
6868 ask_for_type () {
7070 has_extended=no
7171 open_dialog PARTITIONS
7272 while { read_line x1 x2 x3 parttype x5 x6 x7; [ "$parttype" ]; }; do
73 if [ "$parttype" = logical ]; then
74 has_extended=yes
75 fi
73 if [ "$parttype" = logical ]; then
74 has_extended=yes
75 fi
7676 done
7777 close_dialog
7878
7979 noninteractive=true
8080 while true; do
8181 case "$freetype" in
82 primary)
82 primary)
8383 $noninteractive
8484 type=Primary
8585 ;;
86 logical)
86 logical)
8787 $noninteractive
8888 type=Logical
8989 ;;
90 pri/log)
90 pri/log)
9191 if [ "$has_extended" = yes ]; then
92 db_set partman-partitioning/new_partition_type Logical
92 db_set partman-partitioning/new_partition_type Logical
9393 else
94 db_set partman-partitioning/new_partition_type Primary
94 db_set partman-partitioning/new_partition_type Primary
9595 fi
9696 db_input critical partman-partitioning/new_partition_type ||
9797 $noninteractive
134134 numparts=1
135135 open_dialog PARTITIONS
136136 while { read_line x1 part x3 x4 x5 x6 x7; [ "$part" ]; }; do
137 partitions="$partitions $part"
138 numparts=$(($numparts + 1))
137 partitions="$partitions $part"
138 numparts=$(($numparts + 1))
139139 done
140140 close_dialog
141141
145145 # Cannot set "Use as" for SATA RAID partitions under the parent device
146146 if [ -f sataraid ]; then
147147 :
148 elif [ -n "$id" -a -f ../../ext3 ]; then
149 # make better defaults for the new partition
150 mkdir -p $id
151 echo format >$id/method
152 >$id/format
153 >$id/use_filesystem
154 echo ext3 >$id/filesystem
155 mkdir $id/options
156 mplist='/ /home /usr /var /tmp /usr/local /opt /srv /boot'
157 mpcurrent=$(
158 for dev in $DEVICES/*; do
159 [ -d $dev ] || continue
160 cd $dev
161 open_dialog PARTITIONS
162 while { read_line num id size type fs path name; [ "$id" ]; }; do
163 [ $fs != free ] || continue
164 [ -f "$id/method" ] || continue
165 [ -f "$id/acting_filesystem" ] || continue
166 [ -f "$id/use_filesystem" ] || continue
167 [ -f "$id/mountpoint" ] || continue
168 echo $(cat $id/mountpoint) # echo ensures 1 line
169 done
170 close_dialog
171 done
172 )
173 for mp in $mpcurrent; do
174 mplist=$(echo $mplist | sed "s,$mp,,")
175 done
176 mp=''
177 for mp in $mplist; do
178 break
179 done
180 if [ "$mp" ]; then
181 echo $mp >$id/mountpoint
182 fi
183 menudir_default_choice /lib/partman/active_partition ext3 mountpoint || true
184 menudir_default_choice /lib/partman/choose_partition partition_tree $dev//$id || true
185 # setting the bootable flag is too much unnecessary work:
186 # 1. check if the disk label supports bootable flag
187 # 2. check if the mount point is / or /boot and the partition
188 # type is `primary'
189 # 3. get the current flags
190 # 4. add `boot' and set the new flags
191 # 5. moreover, when the boot loader is installed in MBR
192 # no bootable flag is necessary
148 elif [ "$id" ] && [ -f ../../ext3 ]; then
149 # make better defaults for the new partition
150 mkdir -p $id
151 echo format >$id/method
152 >$id/format
153 >$id/use_filesystem
154 echo ext3 >$id/filesystem
155 mkdir $id/options
156 mplist='/ /home /usr /var /tmp /usr/local /opt /srv /boot'
157 mpcurrent=$(
158 for dev in $DEVICES/*; do
159 [ -d $dev ] || continue
160 cd $dev
161 open_dialog PARTITIONS
162 while { read_line num id size type fs path name; [ "$id" ]; }; do
163 [ $fs != free ] || continue
164 [ -f "$id/method" ] || continue
165 [ -f "$id/acting_filesystem" ] || continue
166 [ -f "$id/use_filesystem" ] || continue
167 [ -f "$id/mountpoint" ] || continue
168 echo $(cat $id/mountpoint) # echo ensures 1 line
169 done
170 close_dialog
171 done
172 )
173 for mp in $mpcurrent; do
174 mplist=$(echo $mplist | sed "s,$mp,,")
175 done
176 mp=''
177 for mp in $mplist; do
178 break
179 done
180 if [ "$mp" ]; then
181 echo $mp >$id/mountpoint
182 fi
183 menudir_default_choice /lib/partman/active_partition ext3 mountpoint || true
184 menudir_default_choice /lib/partman/choose_partition partition_tree $dev//$id || true
185 # setting the bootable flag is too much unnecessary work:
186 # 1. check if the disk label supports bootable flag
187 # 2. check if the mount point is / or /boot and the partition
188 # type is `primary'
189 # 3. get the current flags
190 # 4. add `boot' and set the new flags
191 # 5. moreover, when the boot loader is installed in MBR
192 # no bootable flag is necessary
193193 fi
194194
195195 db_progress STEP 1
196196
197197 for part in $partitions; do
198 update_partition $dev $part
199 db_progress STEP 1
198 update_partition $dev $part
199 db_progress STEP 1
200200 done
201201
202202 db_progress STOP
203203
204204 if [ "$id" ]; then
205 while true; do
206 set +e
207 device="$(humandev $(cat device))"
208 db_subst partman/active_partition DEVICE "$device"
209 db_subst partman/active_partition PARTITION "$num"
210 db_metaget partman/text/none_detected description
211 db_subst partman/active_partition OTHERINFO "${RET}"
212 ask_user /lib/partman/active_partition "$dev" "$id"
213 exitcode="$?"
214 if [ "$exitcode" -ge 100 ]; then
215 break
216 fi
217 set -e
218 done
205 while true; do
206 set +e
207 device="$(humandev $(cat device))"
208 db_subst partman/active_partition DEVICE "$device"
209 db_subst partman/active_partition PARTITION "$num"
210 db_metaget partman/text/none_detected description
211 db_subst partman/active_partition OTHERINFO "${RET}"
212 ask_user /lib/partman/active_partition "$dev" "$id"
213 exitcode="$?"
214 if [ "$exitcode" -ge 100 ]; then
215 break
216 fi
217 set -e
218 done
219219 fi
220220 }
221221
222222 ask_for_size || exit $?
223223 exit 0
224
00 #!/bin/sh
11
22 if [ -f /var/lib/partman/supported ]; then
3 exit 0
3 exit 0
44 fi
55
66 . /lib/partman/lib/disk-label.sh
1616 db_go || exit 10
1717 db_get partman-partitioning/unknown_label
1818 if [ "$RET" = false ]; then
19 db_reset partman-partitioning/unknown_label
20 exit 10
19 db_reset partman-partitioning/unknown_label
20 exit 10
2121 fi
2222 db_reset partman-partitioning/unknown_label
2323 exit 0
2727 db_go || exit 10
2828 db_get partman-partitioning/unsupported_label
2929 if [ "$RET" = false ]; then
30 db_reset partman-partitioning/unsupported_label
31 exit 10
30 db_reset partman-partitioning/unsupported_label
31 exit 10
3232 fi
3333 db_reset partman-partitioning/unsupported_label
3434 exit 0
1616 echo bsd
1717 else
1818 echo msdos
19 fi;;
19 fi;;
2020 arm|armel)
2121 case "$sub" in
2222 iop32x)
0 . /lib/partman/lib/base.sh
1
02 # Sets $virtual; used by other functions here.
13 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
57 }
68
79 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
3234 }
3335
3436 do_ntfsresize () {
4143 }
4244
4345 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
6264 }
6365
6466 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
8590 }
8691
8792 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
9196 }
9297
9398 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")"
98103 }
99104
100105 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
137109 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
143151 done
144 if perform_resizing; then break; fi
145 done
146 return 0
152 return 0
147153 }
148154
149155 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
179220 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
182312 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
192318 read_line newid
193319 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
241334 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
278340 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 }