partresize: update c,h,s values before resize.
[people/teissler/ipfire-2.x.git] / src / initscripts / init.d / partresize
1 #!/bin/sh
2 ########################################################################
3 # Begin $rc_base/init.d/partresize
4 #
5 # Description : Resize the root partition to the drivesize
6 #
7 # Authors : Arne Fitzenreiter - arne_f@ipfire.org
8 #
9 # Version : 1.04
10 #
11 # Notes :
12 #
13 ########################################################################
14
15 . /etc/sysconfig/rc
16 . ${rc_functions}
17
18 case "${1}" in
19 start)
20
21 boot_mesg "Mounting root file system in read/write mode ..."
22 mount -o remount,rw / > /dev/null
23 evaluate_retval
24
25 boot_mesg "Create /etc/mtab..."
26 > /etc/mtab
27 mount -f / || failed=1
28 (exit ${failed})
29 evaluate_retval
30
31 # Detect device
32 ROOT=`mount | grep -m1 " / " | cut -d" " -f1`;
33 if [ "${ROOT:`expr length $ROOT`-2:1}" == "p" ]; then
34 DRV=${ROOT::`expr length $ROOT`-2}
35 else
36 DRV=${ROOT::`expr length $ROOT`-1}
37 fi
38
39 boot_mesg "Update c,h,s values of ${DRV} ..."
40 echo -e ',' | sfdisk --no-reread -f -N1 ${DRV} 2>&1 > /dev/null
41 echo -e ',' | sfdisk --no-reread -f -N3 ${DRV} 2>&1 > /dev/null
42
43 boot_mesg "Change Partition ${DRV}3 to all free space ..."
44 echo -e ',+' | sfdisk --no-reread -N3 ${DRV} 2>/dev/null
45
46 # Erase symlink, it should run only once
47 rm -f /etc/rc.d/rcsysinit.d/S25partresize
48
49 boot_mesg "Rebooting ..."
50 sync
51 mount -o remount,ro / 2>&1 > /dev/null
52 sleep 15
53 reboot -f
54
55 ;;
56 *)
57 echo "Usage: ${0} {start}"
58 exit 1
59 ;;
60 esac
61
62 # End $rc_base/init.d/partresize