]> git.ipfire.org Git - ipfire-2.x.git/blob - src/initscripts/system/partresize
partresize: add copy of broadcom firmware settings for nanopi-r1
[ipfire-2.x.git] / src / initscripts / system / partresize
1 #!/bin/sh
2 ########################################################################
3 # Begin $rc_base/init.d/partresize
4 #
5 # Description : Resize the root partition to the drivesize
6 # and setup some platform or hardware options in
7 # flashimage
8 #
9 # Authors : Arne Fitzenreiter - arne_f@ipfire.org
10 #
11 # Version : 1.04
12 #
13 # Notes :
14 #
15 ########################################################################
16
17 . /etc/sysconfig/rc
18 . ${rc_functions}
19
20 case "${1}" in
21 start)
22 if [ -e "/.partresize" ]; then
23
24 boot_mesg "Mounting root file system in read/write mode ..."
25 mount -o remount,rw / > /dev/null
26 evaluate_retval
27
28 boot_mesg "Create /etc/mtab..."
29 > /etc/mtab
30 mount -f / || failed=1
31 (exit ${failed})
32 evaluate_retval
33
34 # check if serial console enabled
35 scon="off";
36 if [ ! "$(grep "console=ttyS0" /proc/cmdline)" == "" ]; then
37 scon="on";
38 fi
39 IFS= read -r DMI_PRODUCT_NAME < /sys/class/dmi/id/product_name;
40 case ${DMI_PRODUCT_NAME} in
41 APU|apu[1-4]|PC\ Engines\ apu[1-4] )
42 scon="on";
43 ;;
44 esac
45
46 # Enable the serial console on all systems on Azure
47 if running_on_azure; then
48 scon="on"
49 fi
50
51 # Install AP6112 wlan config on NanoPi R1
52 case "$(< /proc/device-tree/model )" in
53 "FriendlyElec NanoPi-R1")
54 cp -f /lib/firmware/brcm/brcmfmac43430-sdio.AP6212.txt \
55 /lib/firmware/brcm/brcmfmac43430-sdio.txt
56 ;;
57 esac 2>/dev/null
58
59 mount /boot > /dev/null
60 if [ -e /boot/grub/grub.cfg ]; then
61 # swtich permanent to serial console if it was selected on first boot
62 if [ "${scon}" = "on" ]; then
63 # Enable also serial console on GRUB
64 echo "GRUB_TERMINAL=\"serial console\"" >> /etc/default/grub
65 echo "GRUB_SERIAL_COMMAND=\"serial --unit=0 --speed=115200\"" >> /etc/default/grub
66 sed -i -e "s|panic=10|& console=ttyS0,115200n8|g" /etc/default/grub
67 fi
68
69 # Re-generate GRUB configuration
70 /usr/sbin/grub-mkconfig -o /boot/grub/grub.cfg
71 fi
72 umount /boot > /dev/null
73
74 # Detect device
75 mount | while read -r dev tmp1 mountpoint tmp2; do
76 [ "${dev}" = "rootfs" ] && continue
77
78 if [ "${mountpoint}" = "/" ]; then
79 # Find root partition number
80 part_num="${dev: -1}"
81
82 # Find path to the root device
83 root_dev="${dev::-1}"
84 if [ ! -b "${dev::-1}" -a "${root_dev: -1}" = "p" ]; then
85 root_dev="${dev::-2}"
86 fi
87
88 boot_mesg "Growing root partition to maximum size..."
89 echo -e ',+' | sfdisk --no-reread -f -N${part_num} "${root_dev}" 2>/dev/null
90
91 # Update c,h,s values of the boot partition...
92 if [ ${part_num} -ne 1 -a -b "${root_dev}1" ]; then
93 echo -e ',' | sfdisk --no-reread -f -N1 ${DRV} &> /dev/null
94 fi
95
96 # The filesystem should be resized after
97 # this operation
98 touch /.resizefs
99
100 # Remove marker
101 rm -f /.partresize
102
103 # Reboot
104 boot_mesg "Rebooting system..."
105 mount -o remount,ro / &>/dev/null
106 sleep 15
107 reboot -f
108 fi
109 done
110 fi
111 ;;
112 *)
113 echo "Usage: ${0} {start}"
114 exit 1
115 ;;
116 esac
117
118 # End $rc_base/init.d/partresize