]> git.ipfire.org Git - ipfire-2.x.git/blame - src/initscripts/system/partresize
flash-images: merge normal and scon to one image.
[ipfire-2.x.git] / src / initscripts / system / 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 20 if [ -e "/.partresize" ]; then
6b566244 21
a2454679
MT
22 boot_mesg "Mounting root file system in read/write mode ..."
23 mount -o remount,rw / > /dev/null
24 evaluate_retval
a6d0d790 25
c0504c5c
AF
26 boot_mesg "Create /etc/mtab..."
27 > /etc/mtab
28 mount -f / || failed=1
29 (exit ${failed})
30 evaluate_retval
31
6b566244
AF
32 mount /boot > /dev/null
33 if [ -e /boot/grub/grub.cfg ]; then
34 # swtich permanent to serial console if it was selected on first boot
35 if [ ! "$(grep "console=ttyS0" /proc/cmdline)" == "" ]; then
36 # Enable also serial console on GRUB
37 echo "GRUB_TERMINAL=\"serial console\"" >> /etc/default/grub
38 echo "GRUB_SERIAL_COMMAND=\"serial --unit=0 --speed=115200\"" >> /etc/default/grub
39 sed -i -e "s|panic=10|& console=ttyS0,115200n8|g" /etc/default/grub
40 fi
41 /usr/local/bin/update-bootloader
42 fi
43 umount /boot > /dev/null
44
45 sleep 30
46
a2454679 47 # Detect device
c0504c5c 48 mount | while read -r dev tmp1 mountpoint tmp2; do
a2454679
MT
49 [ "${dev}" = "rootfs" ] && continue
50
51 if [ "${mountpoint}" = "/" ]; then
52 # Find root partition number
53 part_num="${dev: -1}"
a6d0d790 54
a2454679
MT
55 # Find path to the root device
56 root_dev="${dev::-1}"
57 if [ ! -b "${dev::-1}" -a "${root_dev: -1}" = "p" ]; then
58 root_dev="${dev::-2}"
59 fi
6450609d 60
a2454679
MT
61 boot_mesg "Growing root partition to maximum size..."
62 echo -e ',+' | sfdisk --no-reread -f -N${part_num} "${root_dev}" 2>/dev/null
a6d0d790 63
a2454679
MT
64 # Update c,h,s values of the boot partition...
65 if [ ${part_num} -ne 1 -a -b "${root_dev}1" ]; then
66 echo -e ',' | sfdisk --no-reread -f -N1 ${DRV} &> /dev/null
67 fi
a6d0d790 68
a2454679
MT
69 # The filesystem should be resized after
70 # this operation
71 touch /.resizefs
a6d0d790 72
a2454679
MT
73 # Remove marker
74 rm -f /.partresize
75
76 # Reboot
77 boot_mesg "Rebooting system..."
78 mount -o remount,ro / &>/dev/null
79 sleep 15
80 reboot -f
81 fi
c0504c5c 82 done
a2454679 83 fi
a6d0d790
AF
84 ;;
85 *)
86 echo "Usage: ${0} {start}"
87 exit 1
88 ;;
89esac
90
91# End $rc_base/init.d/partresize