1919
2020nm=$( basename " $0 " )
2121err=0
22+ mmc=" "
2223opt=" -k"
2324
2425# External button or bootloader changed kernel command line
@@ -53,17 +54,22 @@ factory_reset()
5354
5455is_mmc ()
5556{
57+ [ -n " $mmc " ] && return $mmc
58+
5659 # Check if primary or secondary partition (our rootfs) is on MMC
5760 for label in primary secondary; do
5861 devname=$( find_partition_by_label " $label " 2> /dev/null)
5962 if [ -n " $devname " ]; then
6063 case " $devname " in
6164 mmcblk* )
65+ mmc=0
6266 return 0
6367 ;;
6468 esac
6569 fi
6670 done
71+
72+ mmc=1
6773 return 1
6874}
6975
@@ -89,8 +95,15 @@ find_partition_by_label()
8995
9096 for diskpath in /sys/class/block/* ; do
9197 devname=$( basename " $diskpath " )
98+
99+ # Skip partitions, only check whole disks
92100 [ -f " $diskpath /partition" ] && continue
93101
102+ # Skip ram, loop, and other virtual devices
103+ case " $devname " in
104+ ram* |loop* |nullb* |dm-* ) continue ;;
105+ esac
106+
94107 disk=" /dev/$devname "
95108 result=$( sgdisk -p " $disk " 2> /dev/null | awk -v label=" $label " -v devname=" $devname " '
96109 /^ *[0-9]/ {
@@ -133,7 +146,7 @@ status()
133146
134147print_start ()
135148{
136- printf ' \r%s%s' " $( status 3) " " $* " > /dev/console
149+ printf ' \r\033[K %s%s' " $( status 3) " " $* " > /dev/console
137150}
138151
139152print_end ()
@@ -146,6 +159,12 @@ print_end()
146159 fi
147160}
148161
162+ # Restore Finit's original progress message so its [ OK ] appears correctly
163+ print_restore ()
164+ {
165+ print_start " Mounting filesystems from /etc/fstab"
166+ }
167+
149168# Helper to log resize error and create failure marker (stage 1)
150169resize_err ()
151170{
@@ -245,9 +264,7 @@ resize_filesystem()
245264 mv /mnt/aux/resized.pending /mnt/aux/resized
246265 sync
247266
248- # Restore Finit's original progress message so its [ OK ] appears correctly
249- print_start " Mounting filesystems from /etc/fstab"
250-
267+ print_restore
251268 return 0
252269}
253270
@@ -259,15 +276,21 @@ mount_rw()
259276 # Check if /var has been resized to fill the sdcard/eMMC
260277 if [ " $1 " = " var" ] && is_mmc; then
261278 if [ -f /mnt/aux/resized ] || [ -f /mnt/aux/resized.failed ]; then
279+ # 3. Already done
262280 :
263281 elif [ -f /mnt/aux/resized.pending ]; then
282+ # 2. After reboot we can resize ext4
264283 resize_filesystem " $1 "
265284 else
285+ # 1. Start with resizing the var partition to the end of the media
266286 resize_partition " $1 "
267287 fi
268288 fi
269289
270290 # TODO: Also look for UBI partitions
291+
292+ #
293+ tune2fs -c 0 -i 0 LABEL=" $1 " 2> /dev/null
271294 mount LABEL=" $1 " 2> /dev/null && return 0
272295
273296 return 1
0 commit comments