]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - src/initscripts/init.d/fsresize
Merge remote-tracking branch 'mfischer/daq' into next
[ipfire-2.x.git] / src / initscripts / init.d / fsresize
index 0afe77900c13b89f5836e0af83f6eb175c9ba18f..79aeb36fc7e089a2818afc4061b67210ec78ee9c 100644 (file)
@@ -2,11 +2,11 @@
 ########################################################################
 # Begin $rc_base/init.d/fsresize
 #
-# Description : Resize the /var filesystem
+# Description : Resize the root filesystem in the background
 #
 # Authors     : Arne Fitzenreiter - arne_f@ipfire.org
 #
-# Version     : 1.00
+# Version     : 1.01
 #
 # Notes       :
 #
 
 case "${1}" in
        start)
-               boot_mesg "Mounting root file system in read/write mode ..."
-               mount -o remount,rw / > /dev/null
-               evaluate_retval
+               if [ -e "/.resizefs" ]; then
+                       boot_mesg "Re-sizing root partition..."
 
-               boot_mesg "Autoresize /var partition to use the whole drive ..."
-               # Detect device
-               ROOT=`mount | grep -m1 " / " | cut -d" " -f1`;
-               DRV=${ROOT::`expr length $ROOT`-1}
-               boot_mesg " * check filesystem on ${DRV}4 before resize ..."
-               fsck -f ${DRV}4
+                       # Find root device
+                       mount | while read -r dev tmp1 mountpoint tmp2; do
+                               # Skip generic entries
+                               [ "${dev}" = "rootfs" ] && continue
 
-               boot_mesg " * resize ${DRV}4 ..."
-               resize2fs -p ${DRV}4
-               evaluate_retval
+                               if [ "${mountpoint}" = "/" ]; then
+                                       # Resize filesystem
+                                       resize2fs -p "${dev}"
 
-               # Erase symlink, it should run only once
-               rm -f /etc/rc.d/rcsysinit.d/S26fsresize
-               sync
-
-               exit 0;
+                                       # Remove marker
+                                       rm -f /.resizefs
+                                       break
+                               fi
+                       done
+               fi
                ;;
+
        *)
                echo "Usage: ${0} {start}"
                exit 1