Fix auto-installer disk size calculation arithmetic error

- Fixed lsblk output parsing that was causing syntax error at line 138
- Added head -1 and tr -d to handle multiple lines or whitespace in lsblk output
- Added numeric validation to prevent arithmetic errors
- Applied same fix to both disk detection functions (lines 138 and 244)

Auto-installer now runs without syntax errors and properly detects disk sizes.
Autologin system fully operational - console passwordless, SSH requires password.
parent 0da085e0
......@@ -134,7 +134,11 @@ detect_target_disk() {
fi
# Skip if disk is too small (less than 4GB)
local size_bytes=$(lsblk -rbno SIZE "$disk" 2>/dev/null || echo 0)
local size_bytes=$(lsblk -rbno SIZE "$disk" 2>/dev/null | head -1 | tr -d ' ' || echo 0)
# Ensure size_bytes is a valid number
if ! [[ "$size_bytes" =~ ^[0-9]+$ ]]; then
size_bytes=0
fi
local size_gb=$((size_bytes / 1024 / 1024 / 1024))
if [ "$size_gb" -lt 4 ]; then
......@@ -241,7 +245,11 @@ confirm_installation() {
print_status " Target: $TARGET_DISK (will be completely erased)"
# Get disk size for display
local size_bytes=$(lsblk -rbno SIZE "$TARGET_DISK" 2>/dev/null || echo 0)
local size_bytes=$(lsblk -rbno SIZE "$TARGET_DISK" 2>/dev/null | head -1 | tr -d ' ' || echo 0)
# Ensure size_bytes is a valid number
if ! [[ "$size_bytes" =~ ^[0-9]+$ ]]; then
size_bytes=0
fi
local size_gb=$((size_bytes / 1024 / 1024 / 1024))
print_status " Target size: ${size_gb} GB"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment