Run a virtual iPhone on an Apple Silicon Mac.
Guest layout, ssh and the bootstrap
A fresh guest has vphoned and the system changes the project ships, and
nothing else: no package manager, no sshd, no shell tools. Everything in this
file is about adding that environment (the "bootstrap") and then finding your
way around it. Until it is installed, work only through guest send and
guest rpc — including script.eval, which runs JavaScript with vphoned's
identity and needs nothing installed at all (see
rpc-methods).
Contents
- Two layouts: roothide and rootless
- Installing the bootstrap
- First package install
- Inspecting and removing it
- ssh: the shell is not in the real root
- Handing a file to vphoned
- Installing a
.deb - What vphoned maintains for you
Two layouts: roothide and rootless
| roothide (recommended) | rootless (deprecated) | |
|---|---|---|
| Root of the environment | /var/containers/Bundle/Application/.jbroot-<16 hex> |
/var/jb, a symlink to a physical directory under /private/preboot |
| Default directory name | .jbroot-000114514191980C when none exists (the last byte is a checksum) |
none |
| Apps go in | <jbroot>/Applications |
/var/jb/Applications |
Package Architecture |
whatever the bootstrap's dpkg --print-architecture says; do not assume |
iphoneos-arm64 |
| After installing an app | register it: system.uicache or apps.refresh |
uicache -p in the postinst |
The directory names /var/jb and .jbroot-<hex> are fixed by those two
bootstraps. Always find the real root with bootstrap.inspect; do not
hard-code it.
vphone-launchpad-cli guest rpc myphone bootstrap.inspect
vphone-launchpad-cli guest rpc myphone device.info # see the layout fields below
device.info reports jailbreak.layout (roothide, rootless, rootful or
null), jailbreak.jbroot and jailbreak.source. These key names belong to
the host-guest protocol; read them as they are. Both null means there is no
bootstrap yet (a read-only / is not evidence of a rootful one).
Prefer roothide for new work. Rootless is kept for older setups.
Installing the bootstrap
The bootstrap is the Irisin app plus the base directories and links a package manager needs. Two equivalent ways:
In the VM window: menu Apps > Install Bootstrap…, pick the layout in the sheet. Holding Option shows Install Bootstrap from File… (a local Irisin
.deb). The item is enabled only when vphoned advertisesbootstrap_install.Over RPC:
vphone-launchpad-cli guest rpc myphone bootstrap.install '{"layout":"roothide"}' vphone-launchpad-cli guest rpc myphone bootstrap.status
What bootstrap.install does, in order, and what to look at when a step fails:
- preparing: selects the layout. Refuses with an error if
/private/var/db/vphoned/bootstrap.jsonsays a bootstrap is already installed. (An uninstall writes a tombstone so this check is accurate.) - downloading: fetches the latest
Lakr233/Irisinrelease for the guest's architecture and checks the GitHub SHA-256 digest and the Debian control fields. The guest needs network.bootstrap.statusreportsdownloaded_bytesandtotal_byteswhen the server gives a length. - extracting / installing: unpacks the
.deb, copies the payload into the environment, creates Irisin's mobile-owned data directory, registers the app and loads its daemon. No maintainer script runs. - firmware: writes the
firmwarerecord (the guest iOS version) into the environment'sLibrary/dpkg/status, so Irisin's resolver sees it. - completed or failed (with
error). A launchd start error comes back asservice_start_warningwhile the install still stands; the daemon starts on demand when Irisin opens, or after a reboot.
For a local package: upload the .deb to exactly
/var/root/Library/Caches/vphoned-irisin-<UUID>.deb (regular file, at most
64 MiB, no symlinks) and pass it as package_path. vphoned validates name,
architecture, version, executables and the launchd plist.
For roothide, vphoned also builds what a bootstrap installer would: tmp,
var, etc, the dev and rootfs links, copies of the passwd files, the
user databases, and the .jbroot loader links. Do not recreate these by hand;
they are repaired at every vphoned start.
First package install
This step is done in the guest UI, in Irisin; there is no RPC for it.
- Open Irisin and the OwnGoal Packages repository
(
https://apt.owngoal.dev/). Find OwnGoal Bootstrap for vphone (owngoal-bootstrap-vphone). - Install it with Bootstrap Install.
That one meta package depends on everything a guest needs: apt, dpkg,
bash, zsh, sudo, the core command-line tools, openssh-server, curl,
git, uikittools, launchctl and the OwnGoal apps (Irisin, Fila, iGhostVT,
Xrash, Inspector). Do not install those packages one by one: they depend on each
other, and openssh-server declares some dependencies circularly, so separate
installs can fail partway. After the first pass, install further packages
normally. If the first pass fails, do not repair it in place:
Apps > Uninstall Bootstrap…, then start over.
Because this needs someone at the screen, drive it with ui.tree,
ui.tap_element and screenshots, or ask the user to do it.
Inspecting and removing it
vphone-launchpad-cli guest rpc myphone bootstrap.inspect # every root found
vphone-launchpad-cli guest rpc myphone bootstrap.uninstall '{"roots":["<path from inspect>"],"force":true}'
Uninstall removes every listed root, unloads their daemons, unregisters
their apps, marks the record uninstalled and reboots the guest (add
"reboot":false to skip). The paths must match the current inspection
exactly. Rootless Irisin keeps its data in the system's
/var/mobile/Documents, which is kept; RootHide Irisin keeps it in the
jbroot's var/mobile, which goes with the root. It destroys the
user's installed packages, so run it only when asked or as the stated recovery
for a failed first install.
ssh: the shell is not in the real root
ssh exists only after openssh-server is installed (see above); a fresh guest
refuses port 22. iproxy, idevice_id and ideviceinstaller are third-party
libimobiledevice tools; ask the user before installing them. Reach the guest
through the host's usbmuxd with iproxy:
UDID=$(idevice_id -l | head -1) # or xcrun devicectl list devices: Reality "virtual"
iproxy 2222 22 -u "$UDID" &
ssh -p 2222 [email protected] # the credentials are not documented in the repo; ask the user
On roothide the session lands inside the jbroot, not the real root:
/in the shell is the environment's root./tmp,/var/mobileand/etcthere are the bootstrap's copies, not the guest's.- The real filesystem is at
/rootfs./rootfs/private/var/...is the guest's/private/var/.... Logs, app data and preferences are found there. - vphoned's
files.*,apps.*and other RPCs use the real paths. A path you see in the ssh shell is not valid for RPC until it is translated. - There is no
sudoin a bare jbroot. Installsudoas a package first, log in as root if the user has set that up, or do root work over RPC.
Rule of thumb: when ssh and RPC disagree about whether a file exists, the
difference is the /rootfs prefix.
Handing a file to vphoned
guest push copies a Mac file to a real-root guest path, streamed, any size,
with no ssh and no --api-listen. guest pull brings one back:
vphone-launchpad-cli guest push myphone App.ipa /private/var/tmp/
vphone-launchpad-cli guest rpc myphone apps.install '{"path":"/private/var/tmp/App.ipa"}'
vphone-launchpad-cli guest pull myphone /private/var/mobile/Library/Logs/x.log .
The mode follows the Mac file (--mode 755 to set it), so an executable
stays executable. Paths are real-root paths, so a roothide file goes under the
absolute .jbroot-<hex> path from bootstrap.inspect, not /var/jb. It needs
a Core Bundle that has push on vphone.sock; an older one says it cannot
copy files. There, files.write takes only small files (one 1 MiB JSON line,
no append), and larger ones go through ssh: scp -P 2222 into the jbroot's
/tmp, then mv to /rootfs/private/var/tmp/.
Installing a .deb
With a bootstrap present, dpkg and apt work from an ssh shell as the
environment's tools:
scp -P 2222 pkg.deb [email protected]:/tmp/
ssh -p 2222 [email protected] 'sudo dpkg -i /tmp/pkg.deb' # needs sudo installed, or a root login
A package that ships an app must register it afterwards (uicache -p in the
postinst for rootless, or system.uicache over RPC). Do not install a package
over a half-built bootstrap.
What vphoned maintains for you
You do not need to run these; knowing they exist explains odd behavior:
.jbrootloader links in every directory holding a Mach-O file, re-walked one second afterLibrary/dpkgchanges. Adyld ... @loader_path/.jbroot/...crash means a link is missing there.- sshd host keys and user databases, deferred until the packages exist, then created within about a second of the next package operation or at the next vphoned start.
- The
firmwarerecord indpkg/status, updated after an iOS version change.
When something here misbehaves, read the notes listed in
finding-docs, especially Research/Guest/roothide_bootstrap_base.md
and Research/roothide_loader_links.md.