#!/bin/bash set -euo pipefail HUGEPAGES_PATH=/sys/kernel/mm/hugepages/hugepages-1048576kB/nr_hugepages init() { echo "$1" | $SUDO tee "$HUGEPAGES_PATH" >/dev/null d="$($SUDO mktemp -d)" $SUDO mount -t hugetlbfs -o pagesize=1024M hugetlbfs "$d" echo "$d" } restore() { $SUDO umount "$1" echo 0 | $SUDO tee "$HUGEPAGES_PATH" >/dev/null } "$@"