Skip to content

Add iOS 16.1+ support on Linux#317

Open
hiylx wants to merge 5 commits intoverygenericname:mainfrom
hiylx:upstream
Open

Add iOS 16.1+ support on Linux#317
hiylx wants to merge 5 commits intoverygenericname:mainfrom
hiylx:upstream

Conversation

@hiylx
Copy link
Copy Markdown

@hiylx hiylx commented Apr 22, 2026

Overview

I added iOS 16.1+ support on Linux by using apfs-fuse to process APFS DMGs.
I used an alternative iBoot64Patcher binary from my repo as the one included did not work

Technical Details

Building a statically linked standalone apfs driver for linux which does not have dependencies

iOS 16.1 support was added to linux by first compiling a statically linked apfs-fuse with the following steps

Spin up a docker container for alpine linux
sudo docker run -it -v $(pwd):/workspace alpine:latest /bin/sh

Install dependencies for building

apk update
apk add build-base cmake git zlib-dev zlib-static bzip2-dev bzip2-static attr-dev linux-headers fuse3-dev fuse3-static

Clone repo

git clone https://github.com/sgan81/apfs-fuse.git
cd apfs-fuse
git submodule update --init

Prepare build folder
mkdir build && cd build

Patch to support static linking

sed -i 's/struct stat64/struct stat/g' ../ApfsLib/DeviceLinux.cpp
sed -i 's/fstat64/fstat/g' ../ApfsLib/DeviceLinux.cpp
sed -i 's/pread64/pread/g' ../ApfsLib/DeviceLinux.cpp
find .. -type f \( -name "*.cpp" -o -name "*.h" \) -exec sed -i '1i #include <cstdint>' {} +
find ../3rdparty -type f -name "*.h" -exec sed -i 's/<cstdint>/<stdint.h>/g' {} +

Create statically linked build files
cmake -DCMAKE_EXE_LINKER_FLAGS="-static" -DCMAKE_POLICY_VERSION_MINIMUM=3.5 ..

Build the executable
make

Building a statically linked standalone HFS driver for linux which does not have dependencies

Spin up a docker container for Ubuntu 20.04
sudo docker run -it -v $(pwd):/workspace ubuntu:20.04 /bin/bash

Install dependencies for building
apt-get update && apt-get install -y build-essential clang wget uuid-dev libssl-dev libbsd-dev libblocksruntime-dev

Download fedora HFS tools

wget https://src.fedoraproject.org/repo/pkgs/hfsplus-tools/diskdev_cmds-540.1.linux3.tar.gz/0435afc389b919027b69616ad1b05709/diskdev_cmds-540.1.linux3.tar.gz
tar -xzf diskdev_cmds-540.1.linux3.tar.gz
cd diskdev_cmds-540.1.linux3

Compile

export CFLAGS="-static"
export LDFLAGS="-static"
make CC="clang -static" LDFLAGS="-static"

Note: It might give an error about fsck, we do not care as the only file we need is newfs_hfs

Logic when APFS ramdisk is used

Create mount points

	mkdir -p /tmp/SSHRD_APFS
	mkdir -p /tmp/SSHRD_HFS

Mount APFS ramdisk

	"$oscheck"/apfs-fuse -o allow_other work/ramdisk.dmg /tmp/SSHRD_APFS

Create empty image file of 400 MB for a new HFS ramdisk

	dd if=/dev/zero of=work/ramdisk1.dmg bs=1M count=400

Format the image as HFS+

	"$oscheck"/newfs_hfs -v SSHRD work/ramdisk1.dmg

Mount the newly created HFS image

	mount -o loop work/ramdisk1.dmg /tmp/SSHRD_HFS

Copy over files from the original ramdisk to the new HFS ramdisk

	rsync -a /tmp/SSHRD_APFS/root/ /tmp/SSHRD_HFS/

Extract sshtars to the newly created image

	tar -xf sshtars/ssh.tar -C /tmp/SSHRD_HFS/

Unmounnt both the ramdisks

	umount /tmp/SSHRD_HFS
	umount /tmp/SSHRD_APFS

Delete mount points

	rm -rf /temp/SSHRD_HFS
	rm -rf /temp/SSHRD_APFS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant