Add option --min-tmpfs <size> to disk-image-create
In some scenarios, the required space in the tmpfs partition can be larger (or smaller) than the default one, producing errors due to the lack of enough space (or performance penalties for not using tmpfs). Using --min-tmpfs <size>, we can hint the working set size we'll need and let dib choose to avoid or use tmpfs. Change-Id: I7d5fe498302a100c8555ae542268e14b21f3a0c5
This commit is contained in:
parent
11df3a45f4
commit
fefc28a918
@ -48,6 +48,7 @@ function show_options () {
|
||||
echo " -x -- turn on tracing"
|
||||
echo " -u -- uncompressed; do not compress the image - larger but faster"
|
||||
echo " -c -- clear environment before starting work"
|
||||
echo " --min-tmpfs size -- minimum size in GB needed in tmpfs to build the image"
|
||||
echo " --no-tmpfs -- do not use tmpfs to speed image build"
|
||||
echo " --offline -- do not update cached resources"
|
||||
if [ "$IS_RAMDISK" == "0" ]; then
|
||||
@ -61,7 +62,7 @@ function show_options () {
|
||||
|
||||
INSTALL_PACKAGES=""
|
||||
COMPRESS_IMAGE="true"
|
||||
TEMP=`getopt -o a:ho:xucnp: -l no-tmpfs,offline -n $SCRIPTNAME -- "$@"`
|
||||
TEMP=`getopt -o a:ho:xucnp: -l no-tmpfs,offline,min-tmpfs: -n $SCRIPTNAME -- "$@"`
|
||||
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
|
||||
|
||||
# Note the quotes around `$TEMP': they are essential!
|
||||
@ -77,6 +78,7 @@ while true ; do
|
||||
-c) shift ; export CLEAR_ENV=1;;
|
||||
-n) shift; export SKIP_BASE="1";;
|
||||
-p) IFS="," read -a INSTALL_PACKAGES <<< "$2"; export INSTALL_PACKAGES ; shift 2 ;;
|
||||
--min-tmpfs) export DIB_MIN_TMPFS=$2; shift 2;;
|
||||
--no-tmpfs) shift; export DIB_NO_TMPFS=1;;
|
||||
--offline) shift; export DIB_OFFLINE=1;;
|
||||
--) shift ; break ;;
|
||||
|
@ -34,6 +34,7 @@ ARCH=${ARCH:-$_ARCH}
|
||||
export ARCH
|
||||
|
||||
export DIB_NO_TMPFS=${DIB_NO_TMPFS:-0}
|
||||
export DIB_MIN_TMPFS=${DIB_MIN_TMPFS:-2}
|
||||
# Set via the CLI normally.
|
||||
# IMAGE_ELEMENT=
|
||||
_BASE_ELEMENT_DIR=$_PREFIX/elements
|
||||
|
@ -18,8 +18,11 @@ function tmpfs_check() {
|
||||
[ "$DIB_NO_TMPFS" == "0" ] || return 1
|
||||
[ -r /proc/meminfo ] || return 1
|
||||
total_kB=$(awk '/^MemTotal/ { print $2 }' /proc/meminfo)
|
||||
[ $total_kB -lt $((4*1024*1024)) ] || return 0
|
||||
echo "Not enough RAM to use tmpfs for build. ($total_kB < 4G)"
|
||||
# tmpfs uses by default 50% of the available RAM, so the RAM should be at least
|
||||
# the double of the minimum tmpfs size required
|
||||
RAM_NEEDED=$[ $DIB_MIN_TMPFS * 2 ]
|
||||
[ $total_kB -lt $(($RAM_NEEDED*1024*1024)) ] || return 0
|
||||
echo "Not enough RAM to use tmpfs for build. ($total_kB < ${RAM_NEEDED}G)"
|
||||
return 1
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
# options for ramdisk-image-create
|
||||
export DIB_NO_TMPFS=${DIB_NO_TMPFS:-1}
|
||||
export DIB_MIN_TMPFS=${DIB_MIN_TMPFS:-1}
|
||||
source $_LIB/common-defaults
|
||||
MODULE_ROOT=${DIB_MODULE_ROOT:-""}
|
||||
LIB_UDEV_ROOT=${DIB_LIB_UDEV_ROOT:-""}
|
||||
|
Loading…
Reference in New Issue
Block a user