Skip to content

Extend chroot mount helper to include cache directories #8186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 14, 2025
Merged
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
7 changes: 6 additions & 1 deletion lib/functions/general/chroot-helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ function mount_chroot() {
local target
target="$(realpath "$1")" # normalize, remove last slash if dir
display_alert "mount_chroot" "$target" "debug"

mkdir -p "${target}/run/user/0"
mkdir -p "${target}/armbian/cache"

# tmpfs size=50% is the Linux default, but we need more.
mount -t tmpfs -o "size=99%" tmpfs "${target}/tmp"
Expand All @@ -26,6 +28,8 @@ function mount_chroot() {
mount -t sysfs chsys "${target}"/sys
mount --bind /dev "${target}"/dev
mount -t devpts chpts "${target}"/dev/pts || mount --bind /dev/pts "${target}"/dev/pts

mount --bind /armbian/cache "${target}/armbian/cache"
}

# umount_chroot <target>
Expand All @@ -36,7 +40,7 @@ function umount_chroot() {
local target
target="$(realpath "$1")" # normalize, remove last slash if dir
display_alert "Unmounting" "$target" "info"
while grep -Eq "${target}\/(dev|proc|sys|tmp|var\/tmp|run\/user\/0)" /proc/mounts; do
while grep -Eq "${target}\/(dev|proc|sys|tmp|var\/tmp|run\/user\/0|armbian\/cache)" /proc/mounts; do
display_alert "Unmounting..." "target: ${target}" "debug"
umount "${target}"/dev/pts || true
umount --recursive "${target}"/dev || true
Expand All @@ -45,6 +49,7 @@ function umount_chroot() {
umount "${target}"/tmp || true
umount "${target}"/var/tmp || true
umount "${target}"/run/user/0 || true
umount "${target}"/armbian/cache || true
wait_for_disk_sync "after umount chroot"
run_host_command_logged grep -E "'${target}/(dev|proc|sys|tmp)'" /proc/mounts "||" true
done
Expand Down