summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <koverstreet@google.com>2012-07-13 00:52:52 -0700
committerKent Overstreet <koverstreet@google.com>2012-07-13 00:52:52 -0700
commit739b971d77c23f438fc25e03142fb3fbd4b93c0c (patch)
tree92bb5a60030971b6cc46826aef669989cef4c95f
parenta3d0e5bafb42e42e16e00cd5e3d8522484d5d9de (diff)
Fix the initramfs script
-rw-r--r--Makefile9
-rw-r--r--initramfs9
-rwxr-xr-xinitramfs/hook20
-rwxr-xr-xinitramfs/script32
4 files changed, 57 insertions, 13 deletions
diff --git a/Makefile b/Makefile
index 8042c5d..ffb66d2 100644
--- a/Makefile
+++ b/Makefile
@@ -5,10 +5,11 @@ CFLAGS+=-O2 -Wall -g
all: make-bcache probe-bcache
install: make-bcache probe-bcache
- install -m0755 make-bcache $(DESTDIR)${PREFIX}/sbin/
- install -m0755 probe-bcache $(DESTDIR)/sbin/
- install -m0644 61-bcache.rules $(DESTDIR)/lib/udev/rules.d/
- install -m0755 initramfs $(DESTDIR)/etc/initramfs-tools/scripts/local-premount/bcache-probe
+ install -m0755 make-bcache $(DESTDIR)${PREFIX}/sbin/
+ install -m0755 probe-bcache $(DESTDIR)/sbin/
+ install -m0644 61-bcache.rules $(DESTDIR)/lib/udev/rules.d/
+ install -m0755 initramfs/script $(DESTDIR)/etc/initramfs-tools/scripts/init-premount/bcache
+ install -m0755 initramfs/hook $(DESTDIR)/etc/initramfs-tools/hooks/bcache
install -m0644 *.8 $(DESTDIR)${PREFIX}/share/man/man8
# install -m0755 bcache-test $(DESTDIR)${PREFIX}/sbin/
diff --git a/initramfs b/initramfs
deleted file mode 100644
index af191cd..0000000
--- a/initramfs
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh -e
-
-for i in `ls /sys/dev/block/`; do
- DEV=/tmp/bcache_dev
-
- mknod $DEV b `echo $i|sed -e 's/:/ /'`
- echo $DEV > /sys/fs/bcache/register_quiet
- rm $DEV
-done
diff --git a/initramfs/hook b/initramfs/hook
new file mode 100755
index 0000000..3c429d0
--- /dev/null
+++ b/initramfs/hook
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+PREREQ="udev"
+
+prereqs()
+{
+ echo "$PREREQ"
+}
+
+case $1 in
+prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+. /usr/share/initramfs-tools/hook-functions
+
+copy_exec /bin/mknod
+manual_add_modules bcache
diff --git a/initramfs/script b/initramfs/script
new file mode 100755
index 0000000..926d5d3
--- /dev/null
+++ b/initramfs/script
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+mountroot_fail()
+{
+ for i in `ls /dev/sd*`; do
+ echo $i > /sys/fs/bcache/register_quiet
+ done
+
+# for i in `ls /sys/dev/block/`; do
+# DEV=/bcache_dev
+#
+# mknod $DEV b `echo $i|sed -e 's/:/ /'`
+# echo $DEV > /sys/fs/bcache/register_quiet
+# rm $DEV
+# done
+}
+
+case $1 in
+prereqs)
+ exit 0
+ ;;
+mountfail)
+ mountroot_fail
+ exit 0
+ ;;
+esac
+
+. /scripts/functions
+
+add_mountroot_fail_hook "30-bcache"
+
+exit 0