]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - src/initscripts/init.d/partresize
Merge branch 'kernel-test' into seventeen
[people/pmueller/ipfire-2.x.git] / src / initscripts / init.d / partresize
CommitLineData
a6d0d790
AF
1#!/bin/sh
2########################################################################
3# Begin $rc_base/init.d/partresize
4#
3e011c27 5# Description : Resize the root partition to the drivesize
a6d0d790
AF
6#
7# Authors : Arne Fitzenreiter - arne_f@ipfire.org
8#
b8101c50 9# Version : 1.04
a6d0d790
AF
10#
11# Notes :
12#
13########################################################################
14
15. /etc/sysconfig/rc
16. ${rc_functions}
17
18case "${1}" in
19 start)
a2454679
MT
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
a6d0d790 24
a2454679
MT
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}"
a6d0d790 32
a2454679
MT
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
6450609d 38
a2454679
MT
39 boot_mesg "Growing root partition to maximum size..."
40 echo -e ',+' | sfdisk --no-reread -f -N${part_num} "${root_dev}" 2>/dev/null
a6d0d790 41
a2454679
MT
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
a6d0d790 46
a2454679
MT
47 # The filesystem should be resized after
48 # this operation
49 touch /.resizefs
a6d0d790 50
a2454679
MT
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
a6d0d790
AF
62 ;;
63 *)
64 echo "Usage: ${0} {start}"
65 exit 1
66 ;;
67esac
68
69# End $rc_base/init.d/partresize