]>
Commit | Line | Data |
---|---|---|
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 | ||
18 | case "${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 | |
c0504c5c AF |
25 | boot_mesg "Create /etc/mtab..." |
26 | > /etc/mtab | |
27 | mount -f / || failed=1 | |
28 | (exit ${failed}) | |
29 | evaluate_retval | |
30 | ||
a2454679 | 31 | # Detect device |
c0504c5c | 32 | mount | while read -r dev tmp1 mountpoint tmp2; do |
a2454679 MT |
33 | [ "${dev}" = "rootfs" ] && continue |
34 | ||
35 | if [ "${mountpoint}" = "/" ]; then | |
36 | # Find root partition number | |
37 | part_num="${dev: -1}" | |
a6d0d790 | 38 | |
a2454679 MT |
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 | |
6450609d | 44 | |
a2454679 MT |
45 | boot_mesg "Growing root partition to maximum size..." |
46 | echo -e ',+' | sfdisk --no-reread -f -N${part_num} "${root_dev}" 2>/dev/null | |
a6d0d790 | 47 | |
a2454679 MT |
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 | |
a6d0d790 | 52 | |
a2454679 MT |
53 | # The filesystem should be resized after |
54 | # this operation | |
55 | touch /.resizefs | |
a6d0d790 | 56 | |
a2454679 MT |
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 | |
c0504c5c | 66 | done |
a2454679 | 67 | fi |
a6d0d790 AF |
68 | ;; |
69 | *) | |
70 | echo "Usage: ${0} {start}" | |
71 | exit 1 | |
72 | ;; | |
73 | esac | |
74 | ||
75 | # End $rc_base/init.d/partresize |