X-Git-Url: http://git.ipfire.org/?p=ipfire-2.x.git;a=blobdiff_plain;f=src%2Finitscripts%2Finit.d%2Fpartresize;h=8c05f4d15e6e11921039e0ac75d4045ec7af691d;hp=33b56266a403289b181ed8ede518a5c372c94afb;hb=b1c1a589944c88d24cfbc20387d607419e2fb61c;hpb=e384ca20f634bcea499448cb0ae84b2d200ff87c diff --git a/src/initscripts/init.d/partresize b/src/initscripts/init.d/partresize index 33b56266a4..8c05f4d15e 100644 --- a/src/initscripts/init.d/partresize +++ b/src/initscripts/init.d/partresize @@ -6,7 +6,7 @@ # # Authors : Arne Fitzenreiter - arne_f@ipfire.org # -# Version : 1.01 +# Version : 1.04 # # Notes : # @@ -17,30 +17,54 @@ case "${1}" in start) + if [ -e "/.partresize" ]; then + boot_mesg "Mounting root file system in read/write mode ..." + mount -o remount,rw / > /dev/null + evaluate_retval - boot_mesg "Mounting root file system in read/write mode ..." - mount -o remount,rw / > /dev/null - evaluate_retval + boot_mesg "Create /etc/mtab..." + > /etc/mtab + mount -f / || failed=1 + (exit ${failed}) + evaluate_retval - # Detect device - ROOT=`mount | grep -m1 " / " | cut -d" " -f1`; - if [ "${ROOT:`expr length $ROOT`-2:1}" == "p" ]; then - DRV=${ROOT::`expr length $ROOT`-2} - else - DRV=${ROOT::`expr length $ROOT`-1} - fi + # Detect device + mount | while read -r dev tmp1 mountpoint tmp2; do + [ "${dev}" = "rootfs" ] && continue + + if [ "${mountpoint}" = "/" ]; then + # Find root partition number + part_num="${dev: -1}" + + # Find path to the root device + root_dev="${dev::-1}" + if [ ! -b "${dev::-1}" -a "${root_dev: -1}" = "p" ]; then + root_dev="${dev::-2}" + fi - boot_mesg "Change Partition ${DRV}3 to all free space ..." - echo -e 'd\n3\nn\np\n3\n\n\nw\nq\n' | fdisk ${DRV} + boot_mesg "Growing root partition to maximum size..." + echo -e ',+' | sfdisk --no-reread -f -N${part_num} "${root_dev}" 2>/dev/null - # Erase symlink, it should run only once - rm -f /etc/rc.d/rcsysinit.d/S25partresize + # Update c,h,s values of the boot partition... + if [ ${part_num} -ne 1 -a -b "${root_dev}1" ]; then + echo -e ',' | sfdisk --no-reread -f -N1 ${DRV} &> /dev/null + fi - boot_mesg "Rebooting ..." - sync - mount -o remount,ro / > /dev/null - reboot -f + # The filesystem should be resized after + # this operation + touch /.resizefs + # Remove marker + rm -f /.partresize + + # Reboot + boot_mesg "Rebooting system..." + mount -o remount,ro / &>/dev/null + sleep 15 + reboot -f + fi + done + fi ;; *) echo "Usage: ${0} {start}" @@ -49,4 +73,3 @@ case "${1}" in esac # End $rc_base/init.d/partresize -