{"id":20041483,"url":"https://github.com/kcxt/pinch","last_synced_at":"2025-05-05T08:32:17.379Z","repository":{"id":227741304,"uuid":"772287189","full_name":"kcxt/pinch","owner":"kcxt","description":"An initramfs PID-1 for those in a pinch","archived":false,"fork":false,"pushed_at":"2024-03-18T16:46:55.000Z","size":20,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-08T10:40:43.330Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kcxt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-14T22:29:28.000Z","updated_at":"2025-02-24T17:07:56.000Z","dependencies_parsed_at":"2024-11-13T10:46:52.342Z","dependency_job_id":null,"html_url":"https://github.com/kcxt/pinch","commit_stats":null,"previous_names":["calebccff/pinch","kcxt/pinch"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kcxt%2Fpinch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kcxt%2Fpinch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kcxt%2Fpinch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kcxt%2Fpinch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kcxt","download_url":"https://codeload.github.com/kcxt/pinch/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252466800,"owners_count":21752437,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T10:46:45.584Z","updated_at":"2025-05-05T08:32:17.108Z","avatar_url":"https://github.com/kcxt.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pinch\n\nA fast initramfs PID-1 written in Rust and driven by Lua.\n\n```\n[    0.440249] Run /init as init process\n[Starting Pinch]\n-- Initializing Lua environment\n-- Running script: init.env.lua\n-- Running script: /usr/share/pinch/device-qemu-amd64-init.lua\n-- Running script: init.lua\n[LUA] Pinch starting up on QEMU amd64 (Sun Mar 17 02:23:56 2024)\n[LUA] Framebuffer disabled: false\n[LUA] Kernel modules: \n[RUST]: probing modules: {\"libcomposite\", \"vfat\", \"virtio-gpu\", \"virtio_input\", \"virtio_pci\", \"virtio_blk\", \"evdev\"}\n$ modprobe libcomposite\n$ modprobe vfat\n$ modprobe virtio-gpu\n[    0.478948] ACPI: bus type drm_connector registered\n$ modprobe virtio_input\n$ modprobe virtio_pci\n[    0.506230] ACPI: \\_SB_.LNKB: Enabled at IRQ 10\n[    0.508777] input: QEMU Virtio Mouse as /devices/pci0000:00/0000:00:02.0/virtio0/input/input2\n[    0.519092] ACPI: \\_SB_.LNKC: Enabled at IRQ 11\n[    0.521646] input: QEMU Virtio Keyboard as /devices/pci0000:00/0000:00:03.0/virtio1/input/input3\n[    0.530380] ACPI: \\_SB_.LNKD: Enabled at IRQ 11\n[    0.540925] ACPI: \\_SB_.LNKA: Enabled at IRQ 10\n[    0.546178] [drm] pci: virtio-vga detected at 0000:00:05.0\n[    0.547478] Console: switching to colour dummy device 80x25\n[    0.548359] virtio-pci 0000:00:05.0: vgaarb: deactivate vga console\n[    0.550564] [drm] features: +virgl +edid -resource_blob -host_visible\n[    0.550565] [drm] features: -context_init\n[    0.553883] [drm] number of scanouts: 1\n[    0.554524] [drm] number of cap sets: 2\n[    0.566724] [drm] cap set 0: id 1, max-version 1, max-size 308\n[    0.568695] [drm] cap set 1: id 2, max-version 2, max-size 1384\n[    0.570799] [drm] Initialized virtio_gpu 0.1.0 0 for 0000:00:05.0 on minor 0\n[    0.572532] fbcon: virtio_gpudrmfb (fb0) is primary device\n[    0.574948] Console: switching to colour frame buffer device 80x30\n[    0.581496] virtio-pci 0000:00:05.0: [drm] fb0: virtio_gpudrmfb frame buffer device\n$ modprobe virtio_blk\n[    0.601218] virtio_blk virtio4: 32/0/0 default/read/poll queues\n[    0.609238] virtio_blk virtio4: [vda] 8388608 512-byte logical blocks (4.29 GB/4.00 GiB)\n[    0.615545] GPT:Primary header thinks Alt. header is not at the end of the disk.\n[    0.617434] GPT:3692543 != 8388607\n[    0.618935] GPT:Alternate GPT header not at the end of the disk.\n[    0.621391] GPT:3692543 != 8388607\n[    0.622624] GPT: Use GNU Parted to correct GPT errors.\n[    0.624082]  vda: vda1 vda2\n$ modprobe evdev\n$ /sbin/udevd -d --resolve-names=never\n[    0.629269] udevd[805]: starting version 3.2.14\n[    0.631439] udevd[806]: starting eudev-3.2.14\n-- /sys/module/firmware_class/parameters/path \u003e /lib/firmware/postmarketos\n[RUST]: udev: matching subsystem: block\n[RUST]: udev: matching subsystem: input\n[RUST]: udev: matching subsystem: graphics\n[RUST]: udev: scanning devices\n[LUA] found device: /dev/input/event1\n[LUA] found device: /dev/input/event2\n[LUA] found device: /dev/fb0\n[LUA] found device: /dev/vda\n[LUA] found device: /dev/vda1\n[LUA] found device: /dev/vda2\n[LUA] found device: /dev/input/event0\n```\n\n## Building\n\nSmall release builds:\n\n```sh\nRUSTFLAGS=\"-Zlocation-detail=none -C strip=symbols\" \\\n    cargo +nightly build --release \\\n    -Z build-std=std,panic_abort \\\n    -Z build-std-features=panic_immediate_abort \\\n    --target x86_64-unknown-linux-gnu\n```\n\n## Size analysis\n\nWith following modules: `756k`\n\n```toml\nanyhow = { version = \"1.0.81\", features = [] }\nmlua = { version = \"0.9.6\", features = [\"luau\", \"vendored\"] }\n```\n\nRemoving `anyhow` brings us down to `716k` (saves `40k`), so not a worthwhile\ntradeoff.\n\nSwitching from `luau` to `lua54` brings it down to `384k` (saves `382k`). Bah!\n\n## pmOS ramdisk stats\n\nIgnoring kernel modules which vary per kernel package/arch/device.\n\nInitramfs for qemu-amd64 is `2.6M`\n\n```sh\n/tmp/extract # ls -lh lib/\ntotal 1M\n-rwxr-xr-x    1 root     root      634.6K Mar 14 22:02 ld-musl-x86_64.so.1\nlrwxrwxrwx    1 root     root          17 Mar 14 22:02 libblkid.so.1 -\u003e libblkid.so.1.1.0\n-rwxr-xr-x    1 root     root      186.8K Mar 14 22:02 libblkid.so.1.1.0\nlrwxrwxrwx    1 root     root          19 Mar 14 22:02 libc.musl-x86_64.so.1 -\u003e ld-musl-x86_64.so.1\n-r-xr-xr-x    1 root     root      287.4K Mar 14 22:02 libdevmapper.so.1.02\n/tmp/extract # ls -lah bin\ntotal 904K\ndrwxr-xr-x    2 root     root        4.0K Mar 14 22:02 .\ndrwxr-xr-x   14 root     root        4.0K Mar 14 22:02 ..\n-rwxr-xr-x    1 root     root      789.8K Mar 14 22:02 busybox\n-rwxr-xr-x    1 root     root      101.7K Mar 14 22:02 busybox-extras\nlrwxrwxrwx    1 root     root          12 Mar 14 22:02 sh -\u003e /bin/busybox\n/tmp/extract # ls -lh usr/bin/\ntotal 116K\n-rwxr-xr-x    1 root     root       98.2K Mar 14 22:02 pbsplash\n-rwxr-xr-x    1 root     root       13.9K Mar 14 22:02 unudhcpd\n/tmp/extract # ls -lh usr/sbin\ntotal 44K\n-rwxr-xr-x    1 root     root       42.1K Mar 14 22:02 kpartx\n/tmp/extract # ls -lh sbin\ntotal 48K\n-rwxr-xr-x    1 root     root       46.1K Mar 14 22:02 blkid\n```\n\nReplacing busybox would obviously be awesome, and maybe even feasible. We would\nlose debug shell capabilities, but on devices that have the ability to choose\nbetween ramdisks we could just have a debug variant.\n\nNext biggest things are `libblkid` and `libdevmapper`. Given that `libblkid` was\njust used to let `mdev` properly configure `/dev/disk/by-partlabel` we can\nprobably get rid of it.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkcxt%2Fpinch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkcxt%2Fpinch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkcxt%2Fpinch/lists"}