Skip to content

Commit 3c86f90

Browse files
authored
Improvements to podman storage driver checks
1 parent 67d54c7 commit 3c86f90

File tree

1 file changed

+57
-10
lines changed

1 file changed

+57
-10
lines changed

setup.sh

Lines changed: 57 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -581,16 +581,63 @@ function check_requirements() {
581581
fi
582582
print_success "subUID/subGID mappings verified."
583583

584-
# Check Podman storage configuration and whether overlay storage driver is used, as some users had problems here
585-
print_info "Checking Podman storage configuration"
586-
if ! podman info --format '{{.Store.GraphDriverName}}' 2>/dev/null | grep -q "overlay"; then
587-
exit_with_error "Podman is not using overlay storage driver or there's a configuration issue.
588-
589-
HOW TO FIX:
590-
1. Check Podman storage configuration: podman info
591-
2. Try resetting Podman: podman system reset (WARNING: This removes all containers and images)
592-
3. Check if /run/containers directory exists and is writable"
593-
fi
584+
# Check Podman storage configuration and whether overlay storage driver is used, as some users had problems here
585+
print_info "Checking Podman storage configuration"
586+
driver=$(podman info --format '{{.Store.GraphDriverName}}' 2>/dev/null)
587+
error_msg="Podman is not using overlay storage driver or there's a configuration issue.
588+
HOW TO FIX:
589+
590+
mkdir -p ~/.config/containers
591+
592+
cat > ~/.config/containers/storage.conf <<EOF
593+
[storage]
594+
driver = \"overlay\"
595+
runroot = \"/run/user/\$(id -u)/containers\"
596+
graphroot = \"\$HOME/.local/share/containers/storage\"
597+
EOF
598+
599+
podman system migrate
600+
601+
Then verify with:
602+
podman info --format '{{.Store.GraphDriverName}}'
603+
Expected: overlay"
604+
605+
if ! echo "$driver" | grep -qE "overlay|btrfs"; then
606+
if [ -z "$driver" ]; then
607+
print_info "Podman storage driver is not set. Setting up with overlay storage driver"
608+
mkdir -p ~/.config/containers
609+
cat > ~/.config/containers/storage.conf <<-EOF
610+
[storage]
611+
driver = "overlay"
612+
runroot = "/run/user/\$(id -u)/containers"
613+
graphroot = "\$HOME/.local/share/containers/storage"
614+
EOF
615+
616+
# Check running containers before migrate
617+
running_containers=$(podman ps --format '{{.Names}}' 2>/dev/null)
618+
if [ -n "$running_containers" ] && ! [[ "$running_containers" == "LinOffice" ]]; then
619+
# Multiple or non-LinOffice: Prompt user
620+
echo "PROMPT:PODMAN_MIGRATE"
621+
while true; do
622+
read -p "WARNING: podman system migrate will stop ALL running containers and reconfigure storage. This may disrupt other workloads. Continue? (y/n): " -n 1 -r
623+
echo
624+
if [[ $REPLY =~ ^[Yy]$ ]]; then
625+
break
626+
elif [[ $REPLY =~ ^[Nn]$ ]] || [ -z "$REPLY" ]; then
627+
exit_with_error "Setup aborted by user. Please run the script again when ready to migrate."
628+
fi
629+
done
630+
fi
631+
632+
podman system migrate
633+
new_driver=$(podman info --format '{{.Store.GraphDriverName}}' 2>/dev/null)
634+
if ! echo "$new_driver" | grep -qE "overlay|btrfs"; then
635+
exit_with_error "$error_msg"
636+
fi
637+
else
638+
exit_with_error "$error_msg"
639+
fi
640+
fi
594641
595642
# Determine if running rootless or rootful
596643
if podman info --format '{{.Host.Security.Rootless}}' | grep -q true; then

0 commit comments

Comments
 (0)