]>
Commit | Line | Data |
---|---|---|
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 | boot_mesg "Create /etc/mtab..." | |
26 | > /etc/mtab | |
27 | mount -f / || failed=1 | |
28 | (exit ${failed}) | |
29 | evaluate_retval | |
30 | ||
31 | # Detect device | |
32 | mount | while read -r dev tmp1 mountpoint tmp2; do | |
33 | [ "${dev}" = "rootfs" ] && continue | |
34 | ||
35 | if [ "${mountpoint}" = "/" ]; then | |
36 | # Find root partition number | |
37 | part_num="${dev: -1}" | |
38 | ||
39 | # Find path to the root device | |
40 | root_dev="${dev::-1}" | |
41 | if [ ! -b "${dev::-1}" -a "${root_dev: -1}" = "p" ]; then | |
42 | root_dev="${dev::-2}" | |
43 | fi | |
44 | ||
45 | boot_mesg "Growing root partition to maximum size..." | |
46 | echo -e ',+' | sfdisk --no-reread -f -N${part_num} "${root_dev}" 2>/dev/null | |
47 | ||
48 | # Update c,h,s values of the boot partition... | |
49 | if [ ${part_num} -ne 1 -a -b "${root_dev}1" ]; then | |
50 | echo -e ',' | sfdisk --no-reread -f -N1 ${DRV} &> /dev/null | |
51 | fi | |
52 | ||
53 | # The filesystem should be resized after | |
54 | # this operation | |
55 | touch /.resizefs | |
56 | ||
57 | # Remove marker | |
58 | rm -f /.partresize | |
59 | ||
60 | # Reboot | |
61 | boot_mesg "Rebooting system..." | |
62 | mount -o remount,ro / &>/dev/null | |
63 | sleep 15 | |
64 | reboot -f | |
65 | fi | |
66 | done | |
67 | fi | |
68 | ;; | |
69 | *) | |
70 | echo "Usage: ${0} {start}" | |
71 | exit 1 | |
72 | ;; | |
73 | esac | |
74 | ||
75 | # End $rc_base/init.d/partresize |