mirror of
https://github.com/blazblue547-afk/nova-os.git
synced 2026-12-02 14:54:17 -05:00
fix: universal storage detection (USB/SD) via PARTUUID, dynamic firstboot
This commit is contained in:
1 parent
724c66cc19
commit
43e140d5a0
1 file changed
+34
-10
+34
-10
@@ -15,18 +15,42 @@ echo " ║ Nova OS — First Boot Setup ║"
|
||||
echo " ╚══════════════════════════════════════════╝"
|
||||
echo ""
|
||||
|
||||
# ── 1. Expand root partition to fill SD card ──────────────────
|
||||
PART=/dev/mmcblk0p2
|
||||
DISK=/dev/mmcblk0
|
||||
# ── 1. Expand root partition to fill storage ──────────────────
|
||||
echo "==> Expanding root partition to fill storage..."
|
||||
|
||||
echo "==> Expanding root partition to fill SD card..."
|
||||
printf "d\n2\nn\np\n2\n\n\nw\n" | fdisk "$DISK" > /dev/null 2>&1
|
||||
blockdev --rereadpt "$DISK" 2>/dev/null || true
|
||||
sleep 1
|
||||
# Auto-detect root device from kernel cmdline
|
||||
ROOT_SPEC=$(cat /proc/cmdline | tr ' ' '\n' | grep '^root=' | cut -d= -f2-)
|
||||
case "$ROOT_SPEC" in
|
||||
PARTUUID=*)
|
||||
UUID="${ROOT_SPEC#PARTUUID=}"
|
||||
ROOT_PART=$(blkid -U "$UUID" -o device 2>/dev/null)
|
||||
;;
|
||||
UUID=*)
|
||||
UUID="${ROOT_SPEC#UUID=}"
|
||||
ROOT_PART=$(blkid -U "$UUID" -o device 2>/dev/null)
|
||||
;;
|
||||
*)
|
||||
ROOT_PART="$ROOT_SPEC"
|
||||
;;
|
||||
esac
|
||||
|
||||
# ── 2. Grow ext4 filesystem ───────────────────────────────────
|
||||
echo "==> Resizing root filesystem..."
|
||||
resize2fs "$PART"
|
||||
if [ -z "$ROOT_PART" ] || [ ! -b "$ROOT_PART" ]; then
|
||||
echo "WARNING: Could not detect root device, skipping partition expansion."
|
||||
else
|
||||
# Get parent disk by stripping partition number from end
|
||||
DISK=$(echo "$ROOT_PART" | sed 's/[0-9]*$//')
|
||||
PART_NUM=$(echo "$ROOT_PART" | sed 's/.*[^0-9]\([0-9]*\)$/\1/')
|
||||
|
||||
echo " Root: $ROOT_PART -> Disk: $DISK (partition $PART_NUM)"
|
||||
|
||||
printf "d\n%s\nn\np\n%s\n\n\nw\n" "$PART_NUM" "$PART_NUM" | fdisk "$DISK" > /dev/null 2>&1 || true
|
||||
blockdev --rereadpt "$DISK" 2>/dev/null || true
|
||||
sleep 1
|
||||
|
||||
# ── 2. Grow ext4 filesystem ───────────────────────────────────
|
||||
echo "==> Resizing root filesystem..."
|
||||
resize2fs "$ROOT_PART" || true
|
||||
fi
|
||||
|
||||
# ── 3. Regenerate SSH host keys ───────────────────────────────
|
||||
echo "==> Generating fresh SSH host keys..."
|
||||
|
||||
Reference in new issue
Block a user