diff options
Diffstat (limited to '')
-rw-r--r-- | .gitignore | 4 | ||||
-rw-r--r-- | Makefile | 62 | ||||
l--------- | bin/sh | 1 | ||||
l--------- | dev/vc/0 | 1 | ||||
-rw-r--r-- | etc/kmap-de | bin | 0 -> 2823 bytes | |||
-rwxr-xr-x | init | 47 | ||||
-rw-r--r-- | root/.keep | 0 |
7 files changed, 115 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c19e1c --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.root-done +initramfs +initramfs.cpio +root/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b17e9a7 --- /dev/null +++ b/Makefile @@ -0,0 +1,62 @@ +CONTENT=/sbin/lvm /sbin/vgchange /sbin/vgscan /bin/busybox init /dev/console etc/kmap-de +CONTENT-LINKS=bin/sh +CONTENT-MARKER=$(addprefix .root-done/,$(CONTENT)) +DATE=$(shell date +%F_%T) + +all: initramfs + +initramfs: initramfs.cpio + gzip > initramfs < initramfs.cpio + +initramfs.cpio: .root-done/.complete + cd root ;\ + find . | cpio -H newc -o > ../initramfs.cpio + +.root-done/.complete: $(CONTENT-MARKER) .root-done/.links + touch .root-done/.complete + +$(CONTENT-MARKER): .root-done/%: % + -ldd $* | cut -d" " -f 3 | while read i ; do \ + if [ -n "$$i" ]; then \ + mkdir -p $$(dirname $$i) ;\ + cp --parents $$i root/ ;\ + fi ;\ + done + + -ldd $* | grep -v "=>" | cut -f1 -d" " | while read i ; do \ + if [ -n "$$i" ]; then \ + mkdir -p $$(dirname $$i) ;\ + cp --parents $$i root/ ;\ + fi ;\ + done + + mkdir -p $(shell dirname $*) + cp -a --parents $* root/ + + mkdir -p $(dir .root-done/$*) + touch .root-done/$* + +.root-done/.links: Makefile + for i in $(CONTENT-LINKS) ; do \ + mkdir -p $$(dirname $$i) ;\ + cp -a --parents $$i root/ ;\ + done + + touch .root-done/.static + +$(CONTENT-MARKER): Makefile + +clean: + ${RM} initramfs initramfs.cpio + ${RM} -r root/* + ${RM} -r .root-done/ + +install: + if [ ! -d "/boot/grub" ]; then \ + mount /boot ;\ + fi + + if [ -r /boot/initramfs ]; then \ + mv /boot/initramfs /boot/initramfs-$(DATE) ;\ + fi + cp initramfs /boot/initramfs @@ -0,0 +1 @@ +busybox
\ No newline at end of file diff --git a/dev/vc/0 b/dev/vc/0 new file mode 120000 index 0000000..bea71cc --- /dev/null +++ b/dev/vc/0 @@ -0,0 +1 @@ +../console
\ No newline at end of file diff --git a/etc/kmap-de b/etc/kmap-de Binary files differnew file mode 100644 index 0000000..bdef348 --- /dev/null +++ b/etc/kmap-de @@ -0,0 +1,47 @@ +#!/bin/sh + +# make dirs +/bin/busybox mkdir -p /dev /proc /sys /newroot + +# mount needed filesystems +mount -t proc none /proc +mount -t sysfs none /sys + +busybox --install -s +mdev -s + +# lvm stuff +vgscan +vgchange -a y lvm + +# process command line options +init="/sbin/init" +root="/dev/lvm/root" + +CMDLINE=$(cat /proc/cmdline) + +for i in ${CMDLINE}; do + case $i in + root\=*) + root=$(echo "$i" | cut -d "=" -f 2) + ;; + init\=*) + init=$(echo "$i" | cut -d "=" -f 2) + ;; + esac +done + +# switch to new root or fallback to sh +mount -r ${root} /newroot +if [ -x "/newroot/${init}" ]; then + umount /sys + umount /proc + exec /bin/busybox switch_root /newroot ${init} ${CMDLINE} +else + echo "Something went wrong..." + echo "After fixing it you may want to execute:" + echo "exec /bin/busybox switch_root /newroot ${init} ${CMDLINE}" + + loadkmap < /etc/kmap-de + exec /bin/sh +fi diff --git a/root/.keep b/root/.keep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/root/.keep |