mirror of
https://github.com/blazblue547-afk/nova-os.git
synced 2026-12-02 14:54:17 -05:00
fix: QEMU-aware firstboot (skip exp+reboot), fstab fix, cgroup dir
This commit is contained in:
1 parent
61e672193a
commit
6141ccb172
2 files changed
+54
-42
No files matched your search
+53
-41
@@ -15,53 +15,59 @@ echo " ║ Nova OS — First Boot Setup ║"
|
|||||||
echo " ╚══════════════════════════════════════════╝"
|
echo " ╚══════════════════════════════════════════╝"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# ── 1. Expand root partition to fill storage ──────────────────
|
# Detect if running under QEMU (virtio block)
|
||||||
echo "==> Expanding root partition to fill storage..."
|
IS_QEMU=0
|
||||||
|
if [ -b /dev/vda ] || [ -b /dev/vda1 ] || [ -b /dev/vda2 ]; then
|
||||||
# Auto-detect root device from kernel cmdline
|
IS_QEMU=1
|
||||||
ROOT_SPEC=$(cat /proc/cmdline | tr ' ' '\n' | grep '^root=' | cut -d= -f2-)
|
echo "==> QEMU virtual machine detected"
|
||||||
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
|
|
||||||
|
|
||||||
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
|
fi
|
||||||
|
|
||||||
# ── 3. Regenerate SSH host keys ───────────────────────────────
|
# ── 1. Expand root partition to fill storage ──────────────────
|
||||||
|
if [ "$IS_QEMU" -eq 1 ]; then
|
||||||
|
echo "==> Skipping partition expansion (QEMU virtio)"
|
||||||
|
else
|
||||||
|
echo "==> Expanding root partition to fill storage..."
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
if [ -z "$ROOT_PART" ] || [ ! -b "$ROOT_PART" ]; then
|
||||||
|
echo "WARNING: Could not detect root device, skipping partition expansion."
|
||||||
|
else
|
||||||
|
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
|
||||||
|
echo "==> Resizing root filesystem..."
|
||||||
|
resize2fs "$ROOT_PART" || true
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ── 2. Regenerate SSH host keys ───────────────────────────────
|
||||||
echo "==> Generating fresh SSH host keys..."
|
echo "==> Generating fresh SSH host keys..."
|
||||||
rm -f /etc/ssh/ssh_host_*_key /etc/ssh/ssh_host_*_key.pub
|
rm -f /etc/ssh/ssh_host_*_key /etc/ssh/ssh_host_*_key.pub
|
||||||
ssh-keygen -A
|
ssh-keygen -A
|
||||||
|
|
||||||
# ── 4. Force root password change on first login ──────────────
|
# ── 3. Force root password change on first login ──────────────
|
||||||
echo "==> Securing root account..."
|
echo "==> Securing root account..."
|
||||||
passwd -e root 2>/dev/null || true
|
passwd -e root 2>/dev/null || true
|
||||||
|
|
||||||
# ── 5. Mark first-boot complete ───────────────────────────────
|
# ── 4. Mark first-boot complete ───────────────────────────────
|
||||||
touch "$FLAG"
|
touch "$FLAG"
|
||||||
sync
|
sync
|
||||||
|
|
||||||
@@ -69,9 +75,15 @@ echo ""
|
|||||||
echo " ╔══════════════════════════════════════════╗"
|
echo " ╔══════════════════════════════════════════╗"
|
||||||
echo " ║ First-boot setup complete. ║"
|
echo " ║ First-boot setup complete. ║"
|
||||||
echo " ║ Root password must be changed. ║"
|
echo " ║ Root password must be changed. ║"
|
||||||
echo " ║ Rebooting in 5 seconds... ║"
|
if [ "$IS_QEMU" -eq 1 ]; then
|
||||||
|
echo " ║ QEMU mode — no reboot. ║"
|
||||||
|
else
|
||||||
|
echo " ║ Rebooting in 5 seconds... ║"
|
||||||
|
fi
|
||||||
echo " ╚══════════════════════════════════════════╝"
|
echo " ╚══════════════════════════════════════════╝"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
sleep 5
|
if [ "$IS_QEMU" -eq 0 ]; then
|
||||||
reboot
|
sleep 5
|
||||||
|
/sbin/reboot
|
||||||
|
fi
|
||||||
+1
-1
@@ -70,7 +70,7 @@ exec qemu-system-aarch64 \
|
|||||||
-m "$MEM" \
|
-m "$MEM" \
|
||||||
\
|
\
|
||||||
-kernel "$KERNEL" \
|
-kernel "$KERNEL" \
|
||||||
-append "console=ttyAMA0 root=/dev/vda2 rootwait rw quiet loglevel=5" \
|
-append "console=ttyAMA0 root=/dev/vda2 rootwait rw quiet loglevel=4" \
|
||||||
\
|
\
|
||||||
-drive file="$IMAGE",format=raw,if=virtio \
|
-drive file="$IMAGE",format=raw,if=virtio \
|
||||||
\
|
\
|
||||||
|
|||||||
Reference in new issue
Block a user