]>
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 | 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 | ||
8f49959d AF |
32 | # check if serial console enabled |
33 | scon="off"; | |
34 | if [ ! "$(grep "console=ttyS0" /proc/cmdline)" == "" ]; then | |
35 | scon="on"; | |
36 | fi | |
37 | IFS= read -r DMI_PRODUCT_NAME < /sys/class/dmi/id/product_name; | |
38 | case ${DMI_PRODUCT_NAME} in | |
710153a8 | 39 | APU|apu[1-4]|PC\ Engines\ apu[1-4] ) |
8f49959d AF |
40 | scon="on"; |
41 | ;; | |
42 | esac | |
43 | ||
bc503715 MT |
44 | # Enable the serial console on all systems on Azure |
45 | if running_on_azure; then | |
46 | scon="on" | |
47 | fi | |
48 | ||
6b566244 AF |
49 | mount /boot > /dev/null |
50 | if [ -e /boot/grub/grub.cfg ]; then | |
51 | # swtich permanent to serial console if it was selected on first boot | |
8f49959d | 52 | if [ "${scon}" = "on" ]; then |
6b566244 AF |
53 | # Enable also serial console on GRUB |
54 | echo "GRUB_TERMINAL=\"serial console\"" >> /etc/default/grub | |
55 | echo "GRUB_SERIAL_COMMAND=\"serial --unit=0 --speed=115200\"" >> /etc/default/grub | |
56 | sed -i -e "s|panic=10|& console=ttyS0,115200n8|g" /etc/default/grub | |
57 | fi | |
43829df3 MT |
58 | |
59 | # Re-generate GRUB configuration | |
60 | /usr/sbin/grub-mkconfig -o /boot/grub/grub.cfg | |
6b566244 AF |
61 | fi |
62 | umount /boot > /dev/null | |
63 | ||
a2454679 | 64 | # Detect device |
c0504c5c | 65 | mount | while read -r dev tmp1 mountpoint tmp2; do |
a2454679 MT |
66 | [ "${dev}" = "rootfs" ] && continue |
67 | ||
68 | if [ "${mountpoint}" = "/" ]; then | |
69 | # Find root partition number | |
70 | part_num="${dev: -1}" | |
a6d0d790 | 71 | |
a2454679 MT |
72 | # Find path to the root device |
73 | root_dev="${dev::-1}" | |
74 | if [ ! -b "${dev::-1}" -a "${root_dev: -1}" = "p" ]; then | |
75 | root_dev="${dev::-2}" | |
76 | fi | |
6450609d | 77 | |
a2454679 MT |
78 | boot_mesg "Growing root partition to maximum size..." |
79 | echo -e ',+' | sfdisk --no-reread -f -N${part_num} "${root_dev}" 2>/dev/null | |
a6d0d790 | 80 | |
a2454679 MT |
81 | # Update c,h,s values of the boot partition... |
82 | if [ ${part_num} -ne 1 -a -b "${root_dev}1" ]; then | |
83 | echo -e ',' | sfdisk --no-reread -f -N1 ${DRV} &> /dev/null | |
84 | fi | |
a6d0d790 | 85 | |
a2454679 MT |
86 | # The filesystem should be resized after |
87 | # this operation | |
88 | touch /.resizefs | |
a6d0d790 | 89 | |
a2454679 MT |
90 | # Remove marker |
91 | rm -f /.partresize | |
92 | ||
93 | # Reboot | |
94 | boot_mesg "Rebooting system..." | |
95 | mount -o remount,ro / &>/dev/null | |
96 | sleep 15 | |
97 | reboot -f | |
98 | fi | |
c0504c5c | 99 | done |
a2454679 | 100 | fi |
a6d0d790 AF |
101 | ;; |
102 | *) | |
103 | echo "Usage: ${0} {start}" | |
104 | exit 1 | |
105 | ;; | |
106 | esac | |
107 | ||
108 | # End $rc_base/init.d/partresize |