NetBSD/distrib/utils/embedded/files/resize_gpt

38 lines
649 B
Bash

#!/bin/sh
#
# $NetBSD: resize_gpt,v 1.2 2020/05/24 18:43:39 jmcneill Exp $
#
# PROVIDE: resize_gpt
# REQUIRE: fsck_root
# BEFORE: resize_root
$_rc_subr_loaded . /etc/rc.subr
name="resize_gpt"
rcvar=$name
start_cmd="resize_gpt_start"
stop_cmd=":"
resize_gpt_start()
{
ROOT_DEVICE=$(sysctl -n kern.root_device)
case ${ROOT_DEVICE} in
dk*)
;;
*)
# Root device is not a wedge, bail out.
exit 0
;;
esac
BLOCK_DEVICE=$(dkctl ${ROOT_DEVICE} getwedgeinfo | head -1 | sed 's/://' | awk '{ print $3; }')
gpt -H resizedisk -q ${BLOCK_DEVICE}
gpt -H resize -a 4m -i 2 -q ${BLOCK_DEVICE}
return
}
load_rc_config $name
run_rc_command "$1"