Skip to content
Closed
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
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ jobs:
# uses: ublue-os/remove-unwanted-software@517622d6452028f266b7ba4cc9a123b5f58a6b53 # v7
# with:
# remove-codeql: true

- name: Mount BTRFS for podman storage
run: ${{ github.workspace }}/.github/workflows/mount_btrfs.sh

- name: Get current date
id: date
Expand Down
44 changes: 44 additions & 0 deletions .github/workflows/mount_btrfs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

set -eo pipefail

BTRFS_TARGET_DIR="${BTRFS_TARGET_DIR:-$(
dir=$(podman system info --format '{{.Store.GraphRoot}}' | sed 's|/storage$||')
mkdir -p "$dir"
echo "$dir"
)}"
# Options used to mount
BTRFS_MOUNT_OPTS=${BTRFS_MOUNT_OPTS:-"compress-force=zstd:2"}
# Location where the loopback file will be placed.
_BTRFS_LOOPBACK_FILE=${_BTRFS_LOOPBACK_FILE:-/mnt/btrfs_loopbacks/$(systemd-escape -p "$BTRFS_TARGET_DIR")}
# Percentage of the total space to use. Max: 1.0, Min: 0.0
_BTRFS_LOOPBACK_FREE=${_BTRFS_LOOPBACK_FREE:-"0.8"}

# Result of $(dirname "$_BTRFS_LOOPBACK_FILE")
btrfs_pdir="$(dirname "$_BTRFS_LOOPBACK_FILE")"

# Install btrfs-progs
sudo apt-get install -y btrfs-progs

# Create loopback file
sudo mkdir -p "$btrfs_pdir" && sudo chown "$(id -u)":"$(id -g)" "$btrfs_pdir"
_final_size=$(
findmnt --target "$btrfs_pdir" --bytes --df --json |
jq -r --arg freeperc "$_BTRFS_LOOPBACK_FREE" \
'.filesystems[0].avail * ($freeperc | tonumber) | round'
)
truncate -s "$_final_size" "$_BTRFS_LOOPBACK_FILE"
unset -v _final_size

# # Stop docker services
# sudo systemctl stop docker

# Format btrfs loopback
sudo mkfs.btrfs -r "$BTRFS_TARGET_DIR" "$_BTRFS_LOOPBACK_FILE"

# Mount
sudo systemd-mount "$_BTRFS_LOOPBACK_FILE" "$BTRFS_TARGET_DIR" \
${BTRFS_MOUNT_OPTS:+ --options="${BTRFS_MOUNT_OPTS}"}

# # Restart docker services
# sudo systemctl start docker