Support safe installation into existing GPT partitions and Btrfs layouts

This commit is contained in:
Codex
2026-10-13 21:41:23 +03:00
parent ae0d9cf08d
commit 653388f0d7
6 changed files with 798 additions and 44 deletions
+64 -4
View File
@@ -6,7 +6,67 @@ Boot the ISO and enter `:shell` in the terminal VM menu. The live session uses a
volatile. The image provides no default SSH login or universal installed password.
`hydra-install` lists disks without selecting one. Inspect the devices, then ask
for a plan using the whole disk you intend to erase:
for a plan using either the explicitly chosen existing partitions or a whole disk.
The commands below use placeholders; the installer never chooses devices automatically.
## Preserve existing partitions
Choose a root partition whose contents you intend to replace and an existing FAT
GPT EFI System Partition (ESP). Inspect their identities and sizes with `lsblk`.
Both selected partitions must be unmounted; unrelated mounted siblings are allowed.
```sh
sudo hydra-install --root-partition /dev/CHOSEN_ROOT \
--esp-partition /dev/CHOSEN_ESP --user YOUR_USER --root-fs btrfs
```
This dry-run describes the operation. To execute the same choice:
```sh
sudo hydra-install --root-partition /dev/CHOSEN_ROOT \
--esp-partition /dev/CHOSEN_ESP --user YOUR_USER --root-fs btrfs \
--execute --confirm-format /dev/CHOSEN_ROOT
```
`--confirm-format` must name the canonical resolved root path exactly, even if an
input path is an alias. This mode formats **only the selected root partition**.
It never recreates GPT, changes partition boundaries, or formats the ESP. Before
formatting, it checks uncompressed payload capacity, mounts the ESP read-only,
refuses any existing `EFI/HydraOS` collision, and requires at least 64 MiB free.
It fingerprints foreign ESP files and verifies their hashes after installation.
GRUB writes `EFI/HydraOS/grubx64.efi` using `--no-nvram` without `--removable`.
Existing EFI loaders, `EFI/BOOT/BOOTX64.EFI`, and firmware BootOrder are preserved.
By default, select that Hydra EFI file manually in your firmware boot interface.
`--register-boot-entry` opts into `efibootmgr --create-only`: it creates a new
HydraOS entry without adding it to BootOrder. Firmware support for selecting EFI
files and managing entries varies.
Only plain, nonoverlapping GPT partitions on physical disks are supported. Root
and ESP may reside on different disks. Device mapper, encrypted/LVM/RAID targets,
nested partition devices, missing identities/bounds, active holders, and ambiguous
backing information are rejected. Mounted Btrfs filesystems must report every
backing member; an incomplete or missing-device report is rejected. ZFS backing
anatomy is unsupported and causes a conservative refusal. The checks are
repeated just before formatting; do not change mounts or storage topology during
installation. They cannot replace your inspection and backups.
`--root-fs ext4` is the default. Btrfs creates `@root`, `@home`, and `@snapshots`.
The kernel, `/boot`, and Portage database stay inside `@root`; `/home` (including
guest disks) uses `@home`, and `/.snapshots` uses `@snapshots`. fstab and boot
arguments use filesystem UUIDs and named subvolumes, without a fixed root
subvolume ID. The layout alone does not implement system rollback; full Gentoo
and kernel recovery requires separate bootable verification.
An installed, root-owned mode-0600 `/etc/hydra/storage.json` records format 1, a
random install UUID, root/ESP filesystem UUIDs and GPT PARTUUIDs, filesystem type,
and owned EFI path `EFI/HydraOS`. Btrfs additionally records
`root_subvolume: "@root"`. Treat this identity record as installation metadata,
not an update payload.
## Erase a whole disk
Use this mode only when every partition on the explicitly chosen disk may be erased:
```sh
hydra-install
@@ -26,7 +86,7 @@ sudo hydra-install --disk /dev/CHOSEN_DISK --user YOUR_USER \
--execute --confirm-erase /dev/CHOSEN_DISK
```
Execution erases the disk, creates a 1 GiB FAT32 EFI partition and an ext4 root,
Execution erases the disk, creates a 1 GiB FAT32 EFI partition and an ext4 root (or Btrfs with `--root-fs btrfs`),
extracts the prepared payload, and prompts twice on the local terminal for your
installed account password. Passwords have no command-line or configuration
option. The installed root account stays locked. Defaults are Europe/Moscow and
@@ -34,8 +94,8 @@ English UTF-8, with Russian UTF-8 also available; `--timezone` accepts an IANA
zone present in the payload.
The installer removes the live account, local password-free sudo rule, and
live autologin overrides, then builds a normal disk initramfs and fallback UEFI
loader. Wait for `Installation completed`, power off, remove the ISO, and boot
live autologin overrides, then builds a normal disk initramfs, its owned HydraOS UEFI loader, and a fallback
UEFI loader on the newly created ESP. Both installation modes keep os-prober disabled. Wait for `Installation completed`, power off, remove the ISO, and boot
the installed disk. Log in with the account and password you supplied. On
failure, read the printed live diagnostic path; when a target root was mounted,
a nonsecret snapshot is also saved at `/var/log/hydra-install.log` on that disk.