Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/command/execlineb -S0
- # Skeleton /init for minimal initramfs.
- # (C) 2016-2017 Laurent Bercot, wtfpl license.
- /command/export PATH /command
- /command/cd /
- if { s6-echo "\n initramfs (minimal)\n" }
- if { s6-mount -wt sysfs sys /sys }
- if { s6-mount -wt proc proc /proc }
- # Just in case the kernel config says not to mount devtmpfs at boot
- foreground { redirfd -w 2 /dev/null s6-mount -wt devtmpfs dev /dev }
- # If you need to manually load modules, do it here, but in some cases the
- # coldplug will initiate request_module() actions, so depending on the
- # hardware you're expecting, you could have a /sbin/modprobe and a
- # /etc/mdev.conf with a MODALIAS definition instead.
- # If you have hardware with weird /sys definitions, or expect
- # specific /dev devices, you should definitely have an appropriate
- # /etc/mdev.conf anyway.
- if { redirfd -w 1 /proc/sys/kernel/hotplug s6-echo /sbin/mdev }
- if { /sbin/mdev -s } # coldplug
- if { redirfd -w 1 /proc/sys/kernel/hotplug s6-echo }
- # Coldplug done, you have a snapshot of your hardware in /dev.
- # Now you need to name your rootfs and its type; you can hardcode them
- # like it's done here, or substitute ROOTFS and ROOTFSTYPE with the
- # result of your rootfs detection.
- define ROOTFS sda1 # Replace with your own
- define ROOTFSTYPE ext4 # detection routines!
- if { s6-mount -rt ${ROOTFSTYPE} /dev/${ROOTFS} /rootfs }
- if { s6-mount -o move /sys /rootfs/sys }
- if { s6-mount -o move /proc /rootfs/proc }
- if { s6-mount -o move /dev /rootfs/dev }
- cd /rootfs
- # OK, all done. Now we're going to delete everything in the initramfs,
- # so we're relying on binaries existing in the rootfs to do our job
- # in order to avoid sweeping the rug off our own feet.
- # You could use busybox's switch_root instead, but you'll still
- # have to rely on binaries existing on the rootfs after you
- # chroot into it.
- ./command/if
- {
- ./command/pipeline { ./command/s6-ls -a -x rootfs / }
- ./command/forstdin -p -d"\n" i
- ./command/importas -u i i
- ./command/s6-rmrf /${i}
- }
- ./command/if { ./command/s6-mount -o move . / }
- ./command/s6-chroot .
- /command/unexport ?
- /command/unexport PATH
- /command/tryexec { /sbin/init $@ }
- /command/tryexec { /bin/init $@ }
- /etc/init $@
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement