resize_root revision 1.1
11.1Schopps#!/bin/sh 21.1Schopps# 31.1Schopps# $NetBSD: resize_root,v 1.1 2015/03/30 10:58:37 chopps Exp $ 41.1Schopps# 51.1Schopps 61.1Schopps# PROVIDE: resize_root 71.1Schopps# REQUIRE: fsck_root 81.1Schopps 91.1Schopps$_rc_subr_loaded . /etc/rc.subr 101.1Schopps 111.1Schoppsname="resize_root" 121.1Schoppsrcvar=$name 131.1Schoppsstart_cmd="resize_root_start" 141.1Schoppsstop_cmd=":" 151.1Schoppsfstab_file=/etc/fstab 161.1Schoppsrootmp="/" 171.1Schopps 181.1Schoppssplit_options() 191.1Schopps{ 201.1Schopps local IFS 211.1Schopps IFS=, 221.1Schopps OPTS=$1 231.1Schopps for i in $OPTS; do 241.1Schopps echo $i 251.1Schopps done 261.1Schopps} 271.1Schopps 281.1Schoppsresize_root_start() 291.1Schopps{ 301.1Schopps # if ! checkyesno $rcvar; then 311.1Schopps # echo "Not resizing $rootmp: resize_root must be set to YES/yes/..." 321.1Schopps # return 331.1Schopps # fi 341.1Schopps 351.1Schopps trap : 2 # Ignore SIGINT, SIGQUIT, so we 361.1Schopps trap : 3 # enter single-user mode on failure. 371.1Schopps 381.1Schopps # Do nothing if root file system is not mentioned in /etc/fstab, or if 391.1Schopps # root file system seems to be a network mount, or if root file system 401.1Schopps # is not ffs or if logging is enabled. 411.1Schopps rootdev="" 421.1Schopps while read fs_spec fs_file fs_vfstype fs_mntops fs_freq fs_passno 431.1Schopps do 441.1Schopps # skip comment or blank line 451.1Schopps case "${fs_spec}" in 461.1Schopps \#*|'') continue ;; 471.1Schopps esac 481.1Schopps 491.1Schopps # skip non-root 501.1Schopps if [ "${fs_file}" != "$rootmp" ]; then 511.1Schopps continue 521.1Schopps fi 531.1Schopps 541.1Schopps if [ "${fs_vfstype}" != "ffs" ]; then 551.1Schopps echo "Not resizing $rootmp: not an ffs file system" 561.1Schopps return 571.1Schopps fi 581.1Schopps 591.1Schopps case "${fs_spec}" in 601.1Schopps *:*) 611.1Schopps echo "Not resizing $rootmp: network mount" 621.1Schopps return 631.1Schopps ;; 641.1Schopps esac 651.1Schopps 661.1Schopps for opt in $(split_options "${fs_mntops}"); do 671.1Schopps if [ "$opt" = "log" ]; then 681.1Schopps echo "Not resizing $rootmp: logging unsupported" 691.1Schopps return 701.1Schopps fi 711.1Schopps done 721.1Schopps 731.1Schopps rootdev=${fs_spec%/*}/r${fs_spec##*/} 741.1Schopps break 751.1Schopps done < "${fstab_file}" 761.1Schopps 771.1Schopps if [ -z "$rootdev" ]; then 781.1Schopps echo "Not resizing $rootmp: not listed in ${fstab_file}" 791.1Schopps return 801.1Schopps fi 811.1Schopps 821.1Schopps if resize_ffs -c $rootdev; then 831.1Schopps echo "Resizing $rootmp" 841.1Schopps if ! resize_ffs -y $rootdev; then 851.1Schopps echo "Error resizing root." 861.1Schopps stop_boot 871.1Schopps fi 881.1Schopps else 891.1Schopps echo "Not resizing $rootmp: already correct size" 901.1Schopps fi 911.1Schopps return 921.1Schopps} 931.1Schopps 941.1Schoppsload_rc_config $name 951.1Schoppsrun_rc_command "$1" 96