]> git.ipfire.org Git - ipfire-2.x.git/blob - src/initscripts/init.d/partresize
installer: Improve check for serial console option
[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 if [ -e "/.partresize" ]; then
21 boot_mesg "Mounting root file system in read/write mode ..."
22 mount -o remount,rw / > /dev/null
23 evaluate_retval
24
25 # Detect device
26 while read -r dev mountpoint fs options; do
27 [ "${dev}" = "rootfs" ] && continue
28
29 if [ "${mountpoint}" = "/" ]; then
30 # Find root partition number
31 part_num="${dev: -1}"
32
33 # Find path to the root device
34 root_dev="${dev::-1}"
35 if [ ! -b "${dev::-1}" -a "${root_dev: -1}" = "p" ]; then
36 root_dev="${dev::-2}"
37 fi
38
39 boot_mesg "Growing root partition to maximum size..."
40 echo -e ',+' | sfdisk --no-reread -f -N${part_num} "${root_dev}" 2>/dev/null
41
42 # Update c,h,s values of the boot partition...
43 if [ ${part_num} -ne 1 -a -b "${root_dev}1" ]; then
44 echo -e ',' | sfdisk --no-reread -f -N1 ${DRV} &> /dev/null
45 fi
46
47 # The filesystem should be resized after
48 # this operation
49 touch /.resizefs
50
51 # Remove marker
52 rm -f /.partresize
53
54 # Reboot
55 boot_mesg "Rebooting system..."
56 mount -o remount,ro / &>/dev/null
57 sleep 15
58 reboot -f
59 fi
60 done < /proc/mounts
61 fi
62 ;;
63 *)
64 echo "Usage: ${0} {start}"
65 exit 1
66 ;;
67 esac
68
69 # End $rc_base/init.d/partresize