Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Add resize_root boot operation. If resize_root=YES in rc.con...
details: https://anonhg.NetBSD.org/src/rev/abc880799866
branches: trunk
changeset: 337017:abc880799866
user: chopps <chopps%NetBSD.org@localhost>
date: Mon Mar 30 10:58:37 2015 +0000
description:
Add resize_root boot operation. If resize_root=YES in rc.conf then
the system attempts to resize the root file system to fill it's
partition prior to mounting read-write. Useful for things like AMI
file system images. May eventually be used by arm images after
coming up with similar solution for increasing the parition size.
diffstat:
distrib/sets/lists/etc/mi | 3 +-
etc/defaults/rc.conf | 3 +-
etc/rc.d/Makefile | 6 +-
etc/rc.d/resize_root | 95 +++++++++++++++++++++++++++++++++++++++++++++++
etc/rc.d/root | 4 +-
share/man/man5/rc.conf.5 | 9 +++-
6 files changed, 112 insertions(+), 8 deletions(-)
diffs (192 lines):
diff -r 0f25ff13ae9c -r abc880799866 distrib/sets/lists/etc/mi
--- a/distrib/sets/lists/etc/mi Mon Mar 30 05:43:55 2015 +0000
+++ b/distrib/sets/lists/etc/mi Mon Mar 30 10:58:37 2015 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.236 2015/03/21 19:10:43 jmcneill Exp $
+# $NetBSD: mi,v 1.237 2015/03/30 10:58:37 chopps Exp $
#
# Note: end-user configuration files that are moved to another location
# should not be marked "obsolete"; they should just be removed from
@@ -266,6 +266,7 @@
./etc/rc.d/random_seed etc-sys-rc
./etc/rc.d/rarpd etc-bootserver-rc
./etc/rc.d/rbootd etc-bootserver-rc
+./etc/rc.d/resize_root etc-sys-rc
./etc/rc.d/rndctl etc-sys-rc
./etc/rc.d/root etc-sys-rc
./etc/rc.d/route6d etc-router-rc
diff -r 0f25ff13ae9c -r abc880799866 etc/defaults/rc.conf
--- a/etc/defaults/rc.conf Mon Mar 30 05:43:55 2015 +0000
+++ b/etc/defaults/rc.conf Mon Mar 30 10:58:37 2015 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: rc.conf,v 1.132 2015/03/21 19:10:43 jmcneill Exp $
+# $NetBSD: rc.conf,v 1.133 2015/03/30 10:58:37 chopps Exp $
#
# /etc/defaults/rc.conf --
# default configuration of /etc/rc.conf
@@ -120,6 +120,7 @@
#
savecore=YES savecore_flags="-z"
savecore_dir="/var/crash"
+resize_root=NO # resize root to fill partition
per_user_tmp=NO # per-user /tmp directories
per_user_tmp_dir="/private/tmp" # real storage for /tmp
clear_tmp=YES # clear /tmp after reboot
diff -r 0f25ff13ae9c -r abc880799866 etc/rc.d/Makefile
--- a/etc/rc.d/Makefile Mon Mar 30 05:43:55 2015 +0000
+++ b/etc/rc.d/Makefile Mon Mar 30 10:58:37 2015 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.92 2015/03/21 19:10:43 jmcneill Exp $
+# $NetBSD: Makefile,v 1.93 2015/03/30 10:58:37 chopps Exp $
.include <bsd.own.mk>
@@ -33,8 +33,8 @@
perusertmp pf pf_boot pflogd postfix powerd ppp pwcheck \
quota \
racoon rpcbind raidframe raidframeparity random_seed rarpd \
- rbootd rndctl root route6d routed rtadvd rtclocaltime \
- rwho \
+ rbootd resize_root rndctl root route6d routed rtadvd \
+ rtclocaltime rwho \
savecore screenblank securelevel sshd \
staticroute swap1 swap2 sysctl sysdb syslogd \
timed tpctl ttys \
diff -r 0f25ff13ae9c -r abc880799866 etc/rc.d/resize_root
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/etc/rc.d/resize_root Mon Mar 30 10:58:37 2015 +0000
@@ -0,0 +1,95 @@
+#!/bin/sh
+#
+# $NetBSD: resize_root,v 1.1 2015/03/30 10:58:37 chopps Exp $
+#
+
+# PROVIDE: resize_root
+# REQUIRE: fsck_root
+
+$_rc_subr_loaded . /etc/rc.subr
+
+name="resize_root"
+rcvar=$name
+start_cmd="resize_root_start"
+stop_cmd=":"
+fstab_file=/etc/fstab
+rootmp="/"
+
+split_options()
+{
+ local IFS
+ IFS=,
+ OPTS=$1
+ for i in $OPTS; do
+ echo $i
+ done
+}
+
+resize_root_start()
+{
+ # if ! checkyesno $rcvar; then
+ # echo "Not resizing $rootmp: resize_root must be set to YES/yes/..."
+ # return
+ # fi
+
+ trap : 2 # Ignore SIGINT, SIGQUIT, so we
+ trap : 3 # enter single-user mode on failure.
+
+ # Do nothing if root file system is not mentioned in /etc/fstab, or if
+ # root file system seems to be a network mount, or if root file system
+ # is not ffs or if logging is enabled.
+ rootdev=""
+ while read fs_spec fs_file fs_vfstype fs_mntops fs_freq fs_passno
+ do
+ # skip comment or blank line
+ case "${fs_spec}" in
+ \#*|'') continue ;;
+ esac
+
+ # skip non-root
+ if [ "${fs_file}" != "$rootmp" ]; then
+ continue
+ fi
+
+ if [ "${fs_vfstype}" != "ffs" ]; then
+ echo "Not resizing $rootmp: not an ffs file system"
+ return
+ fi
+
+ case "${fs_spec}" in
+ *:*)
+ echo "Not resizing $rootmp: network mount"
+ return
+ ;;
+ esac
+
+ for opt in $(split_options "${fs_mntops}"); do
+ if [ "$opt" = "log" ]; then
+ echo "Not resizing $rootmp: logging unsupported"
+ return
+ fi
+ done
+
+ rootdev=${fs_spec%/*}/r${fs_spec##*/}
+ break
+ done < "${fstab_file}"
+
+ if [ -z "$rootdev" ]; then
+ echo "Not resizing $rootmp: not listed in ${fstab_file}"
+ return
+ fi
+
+ if resize_ffs -c $rootdev; then
+ echo "Resizing $rootmp"
+ if ! resize_ffs -y $rootdev; then
+ echo "Error resizing root."
+ stop_boot
+ fi
+ else
+ echo "Not resizing $rootmp: already correct size"
+ fi
+ return
+}
+
+load_rc_config $name
+run_rc_command "$1"
diff -r 0f25ff13ae9c -r abc880799866 etc/rc.d/root
--- a/etc/rc.d/root Mon Mar 30 05:43:55 2015 +0000
+++ b/etc/rc.d/root Mon Mar 30 10:58:37 2015 +0000
@@ -1,10 +1,10 @@
#!/bin/sh
#
-# $NetBSD: root,v 1.4 2009/04/21 16:08:57 joerg Exp $
+# $NetBSD: root,v 1.5 2015/03/30 10:58:37 chopps Exp $
#
# PROVIDE: root
-# REQUIRE: fsck_root
+# REQUIRE: fsck_root resize_root
$_rc_subr_loaded . /etc/rc.subr
diff -r 0f25ff13ae9c -r abc880799866 share/man/man5/rc.conf.5
--- a/share/man/man5/rc.conf.5 Mon Mar 30 05:43:55 2015 +0000
+++ b/share/man/man5/rc.conf.5 Mon Mar 30 10:58:37 2015 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: rc.conf.5,v 1.157 2014/01/15 11:42:43 apb Exp $
+.\" $NetBSD: rc.conf.5,v 1.158 2015/03/30 10:58:37 chopps Exp $
.\"
.\" Copyright (c) 1996 Matthew R. Green
.\" All rights reserved.
@@ -320,6 +320,13 @@
Boolean value.
Should be true if you have deliberately configured your system with no swap.
If false and no swap devices are configured, the system will warn you.
+.It Sy resize_root
+Boolean value.
+Set to true to have the system resize the root file system to fill it's
+partition.
+Will only attempt to resize the root file system if it is of type ffs and does
+not have logging enabled.
+Defaults to false.
.It Sy swapoff
Boolean value.
Remove block-type swap devices at shutdown time.
Home |
Main Index |
Thread Index |
Old Index