An open API service indexing awesome lists of open source software.

https://github.com/9001/asm

scriptable runtime-writable livecd / hardware wrangler
https://github.com/9001/asm

alpine livecd liveusb secureboot uki

Last synced: 5 months ago
JSON representation

scriptable runtime-writable livecd / hardware wrangler

Awesome Lists containing this project

README

        

# alpine-service-mode

* write this to a usb flashdrive and [`./sm/asm.sh`](./sm/asm.sh) will be executed on bootup
* good for fixing headless boxes or just general hardware wrangling
* based on [Alpine Linux](https://alpinelinux.org/), runs anywhere
* trivial: `i386/x86` // `x64` // `aarch64` // `ppc64le` // `s390x`
* possible: `armhf` // `armv7`

## what does it do

the example [`asm.sh`](./sm/asm.sh) shows a menu with some demo features:

* `1` shows a list of local HDDs and asks for a selection
* maybe for entering a chroot or something
* `i` collects a bunch of hardware info and saves it to `sm/infos` on the flashdrive
* `n` starts networking and `sshd` after asking for `s`tatic or `d`ynamic IP
* `z` exits to a shell with `exit 0`
* `x` does an `exit 1` which also gives a shell but with `vim` and `tmux` preinstalled
* `k` shutdown
* `r` reboot

it plays the [pc98 bootup bleep](https://www.youtube.com/watch?v=9qof0qye1ao#t=6m28s) to let you know it's at the menu in case you don't have a monitor

* you can mute SFX by creating a file named `sm/quiet` on the flashdrive
* or beep even more with `grub_beep` in [post-build-2.sh](https://github.com/9001/asm/blob/hovudstraum/p/big/sm/post-build-2.sh)
* or if the beeps don't work, add `tinyalsa` to recommended_apks in your post-build-2

see [profiles](./p/) for additional examples including a chatserver, a disk wiper and a webkiosk

see [logging](./doc/notes.md#logging) to log stdout to serial and/or a file on the flashdrive, and/or launch interactive shells on consoles

## secureboot

the [uki profile](./p/uki/) shows how to securely verify the integrity of all resources during boot, using secureboot and (a bespoke alternative to) measured boot

# build it

if you are on linux or macos,
* install qemu and run [`./build.sh`](./build.sh)
* you will get `asm.usb` which you can write to a usb flashdrive
* can additionally produce a hybrid ISO for burning to CD/DVD with `-oi`

optionally specify `-cb alpine:latest` to disable qemu and use podman/docker instead; about 12 sec faster but has too many drawbacks to be recommended (cannot crosscompile, not as reliable or predictable, requires root + access to /dev for losetup, a typo in postbuild can wipe your HDD, is less cool)

and, if all else fails, a very basic build can be made [manually](./doc/manual-build.md) instead of using [`./build.sh`](./build.sh) at all

## write it to a flashdrive

* on linux, `cat asm.usb >/dev/sdi`
* on windows, either use [rufus](https://github.com/pbatard/rufus/releases/) or [USBimager (Recommended)](https://bztsrc.gitlab.io/usbimager/)
* you want the `GDI wo` edition of USBimager -- the default choice when visiting that URL on windows
* usbimager v1.0.9 is 10x faster than rufus if you are repeatedly writing similar usb images to the same flashdrive
* rufus v3.15 permanently unmounts the flashdrive when done, so run [rufus-unhide.bat](./doc/rufus-unhide.bat) afterwards
* do not use balenaEtcher, it is spyware

**tip:** if the flashdrive is larger than the image, it is safe and recommended to add a "data" partition to the flashdrive after writing the image:
* on windows, use the win10 `Disk Management` utility, or better yet:
* on linux, `echo ,,07 | sfdisk -a /dev/sdi` (followed by `mkfs.ntfs -fL ASM2 /dev/sdi2` if there is no existing filesystem to keep)
* linux-only bonus: you can write a new asm image onto the flashdrive without losing anything on the data partition, as long as the new build is the same size or smaller -- just need to issue the sfdisk command again
* linux-only because windows is very persistent in blanking any filesystem headers it can find

## write it to a CD

* if you haven't made an `asm.iso` yet, convert an existing `asm.usb` with `./u2i.sh asm.usb asm.iso`
* optionally PGO the iso (runs 30% faster) by capturing the access pattern of a vm booting it
1. start the tracer: `./utils/isotrace.py asm.iso asm.wl`
2. start the vm: `qemu-system-x86_64 -enable-kvm -vga qxl -cpu host -m 1024 -audio pa,model=hda --drive file=nbd:127.0.0.1:2031`
3. do things you expect to do at runtime (install packages etc.) then alt-f4 the vm
4. build optimized iso: `./u2i.sh asm.usb asm.iso -wl asm.wl`
* burn it: `wodim -dao speed=0 -v -data asm.iso`
* `-dao` runs better than `-tao` but some drives from the 90s can only read `-tao`

## rapid prototyping

if you are working on `asm.sh` and you're testing your image by repeatedly making an iso and booting that in virtualbox/vmware/bare-metal, it would be much faster to instead mount asm.usb and make changes directly inside the image, and then use `u2i.sh` to build the iso from the mounted folder instead of doing a full build:

```bash
mkdir -p m; mount -o offset=1048576,uid=1000 asm.usb m
# make changes inside m, leave it mounted and
# do the following to make an iso whenever:
./u2i.sh m asm.iso
cat /dev/sdx
```

* `cat /dev/sdx` can be replaced with `revert /dev/sdx