Skip to content

Commit f340571

Browse files
committed
docs: Postgres quickstart, optional helper config, install caveats
Document the Docker Postgres setup matching config.exs defaults, the now config-sourced (and optional) device-binary paths, and the sudo/tty caveat for mix suidhelper.install.
1 parent 4ddcd4d commit f340571

1 file changed

Lines changed: 65 additions & 7 deletions

File tree

docs/cookbook/intro.md

Lines changed: 65 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,70 @@ The absolute best way to get started with `Hyper` is to play with it.
2424
Hyper needs a **PostgreSQL** server reachable from every node - it is the image
2525
database and the only stateful external dependency.
2626

27+
For local development the quickest path is Docker. The connection details below
28+
match the defaults in `config/config.exs` (`Hyper.Img.Db.Repo`):
29+
30+
```sh
31+
docker run -d --name hyper-pg \
32+
-e POSTGRES_USER=postgres \
33+
-e POSTGRES_PASSWORD=postgres \
34+
-e POSTGRES_DB=hyper_dev \
35+
-p 5432:5432 \
36+
postgres:16
37+
```
38+
39+
Once it is up, create and migrate the schema (the repo is not in `ecto_repos`,
40+
so pass it with `-r`):
41+
42+
```sh
43+
mix ecto.create -r Hyper.Img.Db.Repo
44+
mix ecto.migrate -r Hyper.Img.Db.Repo
45+
```
46+
47+
The container is ephemeral; `docker start hyper-pg` brings it back after a
48+
reboot. To point Hyper at an existing server instead, override the
49+
`Hyper.Img.Db.Repo` block in your `config.exs`.
50+
2751
#### System binaries
2852

29-
The following must be on each node's `PATH` (the bracketed override is the
30-
`config :hyper` key you can set if the binary lives elsewhere):
53+
These are used by the unprivileged node directly; each must be on the node's
54+
`PATH` (the bracketed override is the `config :hyper` key you can set if the
55+
binary lives elsewhere):
3156

3257
- [`skopeo`](https://github.com/containers/skopeo) - pulls OCI images
3358
(`skopeo_path`)
3459
- [`e2fsprogs`](https://github.com/tytso/e2fsprogs) - provides `mke2fs`, which
3560
builds the ext4 rootfs (`mke2fs_path`)
36-
- `losetup`, `blockdev` (from **util-linux**) - loop-device setup
37-
(`losetup_path`, `blockdev_path`)
38-
- `dmsetup` (from **lvm2** / device-mapper) - dm-snapshot and thin-pool
39-
layering (`dmsetup_path`). Frequently *not* installed by default - check
40-
this one first.
4161
- `du`, `getent` (from **coreutils** and **glibc**) - rootfs sizing and user
4262
resolution. Present on essentially every distro.
4363

64+
The privileged device binaries - `losetup`, `blockdev` (from **util-linux**)
65+
and `dmsetup` (from **lvm2** / device-mapper) - are run only by the setuid
66+
helper, never named by the unprivileged caller. Their paths therefore live in
67+
the helper's own config, `/etc/hyper/config.toml`, and default to
68+
`/usr/sbin/{losetup,blockdev,dmsetup}`.
69+
70+
**The config file is optional.** If it is absent the helper uses the built-in
71+
defaults below (and `work_dir = "/srv/hyper"`, matching the node's own
72+
fallback). Create one only to override a default - and if you do, it must be
73+
root-owned and not group/other-writable, or the helper refuses to start (a
74+
present-but-untrusted file is treated as an attack signal, unlike a missing
75+
one):
76+
77+
```toml
78+
# /etc/hyper/config.toml (root-owned, mode 0644) - every line optional
79+
work_dir = "/srv/hyper"
80+
81+
# Each must be an absolute path to a root-owned, non-world-writable binary;
82+
# the helper validates this before it will exec the tool.
83+
dmsetup = "/usr/sbin/dmsetup"
84+
losetup = "/usr/sbin/losetup"
85+
blockdev = "/usr/sbin/blockdev"
86+
```
87+
88+
`dmsetup` (lvm2) is frequently *not* installed by default - check that one
89+
first.
90+
4491
#### Kernel features
4592

4693
The host kernel must provide:
@@ -61,6 +108,17 @@ The host kernel must provide:
61108
Run `mix suidhelper.install`, which builds, stamps, and places it
62109
setuid-root on `PATH`. Every privileged operation (losetup, dmsetup, mknod,
63110
chroot jails) routes through it; the BEAM itself runs unprivileged.
111+
112+
The final `sudo install` step runs without a controlling terminal (Mix
113+
captures the nested `cargo` output), so on a typical `tty_tickets` sudo
114+
setup it cannot prompt for a password. If it fails, the build has already
115+
stamped the binary -- just run the copy yourself:
116+
117+
```sh
118+
sudo install -o root -g root -m 4755 \
119+
native/suidhelper/target/release/hyper-suidhelper \
120+
/usr/local/bin/hyper-suidhelper
121+
```
64122
- A **parent cgroup** named by `cgroup_parent` (default `hyper`) must exist
65123
under `/sys/fs/cgroup`; Hyper creates each VM's cgroup beneath it.
66124
- The host UID/GID range given by `uid_gid_range` must be free for Hyper to

0 commit comments

Comments
 (0)