Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions data/data/agent/files/usr/local/bin/agent-gather
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ function gather_storage_data() {
cp /etc/mtab "${ARTIFACTS_DIR}/etc/mtab"
( >&2 echo -n ".")
lsblk > "${ARTIFACTS_DIR}/lsblk"
( >&2 echo -n ".")
df -h > "${ARTIFACTS_DIR}/df"
( >&2 echo " Done")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ if test -f /run/ostree-live; then
mkdir -p "${ostree_repo}"
echo "In live environment; creating temporary repo to pull node image"
ostree init --mode=bare --repo="${ostree_repo}"

echo "Resizing /run/ephemeral_base tmpfs to 10GiB for ostree operations..."
# Use systemd-run to avoid inheriting MountFlags
systemd-run --wait --service-type=oneshot /usr/local/bin/resize-ephemeral.sh 10G

# if there are layers, import all the content in the system repo for
# layer-level deduping
if [ -d /ostree/repo/refs/heads/ostree/container ]; then
Expand Down Expand Up @@ -85,6 +90,7 @@ ostree checkout --repo "${ostree_repo}" ${hardlink} coreos/node-image "${ostree_

# in the assisted-installer case, nuke the temporary repo to save RAM
if grep -q coreos.liveiso= /proc/cmdline; then
df -h /run/ephemeral
echo "Deleting temporary repo"
rm -rf "${ostree_repo}"
fi
33 changes: 33 additions & 0 deletions data/data/bootstrap/files/usr/local/bin/resize-ephemeral.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

set -eu

TARGET_SIZE="$1"
BASE_DIR="/run/ephemeral_base"
LOOPBACK_FILE="${BASE_DIR}/loopfs"

function get_size_bytes() {
printf "%d" "$(($(stat -f -c "%b * %s" "${BASE_DIR}")))"
}

TARGET_SIZE_BYTES="$(numfmt --from=iec "${TARGET_SIZE}")"
CURRENT_SIZE_BYTES="$(get_size_bytes)"
CURRENT_SIZE="$(numfmt --to=iec "${CURRENT_SIZE_BYTES}")"

if ((TARGET_SIZE_BYTES > CURRENT_SIZE_BYTES)); then
echo "Expanding ephemeral base dir from ${CURRENT_SIZE} to ${TARGET_SIZE}"
mount -o remount,size="${TARGET_SIZE}" "${BASE_DIR}"

echo "Expanding ephemeral loopback"
truncate -s "$(get_size_bytes)" "${LOOPBACK_FILE}"

LOOPBACK_DEVICE="$(losetup -j "${LOOPBACK_FILE}" -O NAME -n)"
losetup -c "${LOOPBACK_DEVICE}"

echo "Expanding ephemeral filesystem"
xfs_growfs -d "${LOOPBACK_DEVICE}"
else
echo "Ephemeral base dir size ${CURRENT_SIZE} is already larger than ${TARGET_SIZE}; not expanding"
fi

df -h