Skip to content

Instantly share code, notes, and snippets.

@luckycyang
Created July 24, 2025 11:30
Show Gist options
  • Select an option

  • Save luckycyang/18939017209f480bc8e72c36a3a4a87f to your computer and use it in GitHub Desktop.

Select an option

Save luckycyang/18939017209f480bc8e72c36a3a4a87f to your computer and use it in GitHub Desktop.
A ramdiskfs init script for debug in alpine rootfs
#!/bin/sh
echo "Loading, please wait..."
[ -d /dev ] || mkdir -m 0755 /dev
[ -d /root ] || mkdir --mode=0700 /root
[ -d /sys ] || mkdir /sys
[ -d /proc ] || mkdir /proc
[ -d /tmp ] || mkdir /tmp
[ -d /mnt ] || mkdir /mnt
# Mount /proc and /sys:
mount -n proc /proc -t proc
mount -n sysfs /sys -t sysfs
# Note that this only becomes /dev on the real filesystem if udev's scripts
# are used; which they will be, but it's worth pointing out
#mount -t tmpfs -o mode=0755 udev /dev
[ -e /dev/console ] || mknod /dev/console c 5 1
[ -e /dev/null ] || mknod /dev/null c 1 3
# this will scan device update /dev list
mdev -s
/bin/sh -i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment