wok-next rev 4469
busybox/init: add raid support
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Mon Nov 09 17:17:30 2009 +0100 (2009-11-09) |
parents | 77991ef5de06 |
children | facb3e18dff4 |
files | busybox/stuff/init |
line diff
1.1 --- a/busybox/stuff/init Mon Nov 09 10:26:03 2009 +0000 1.2 +++ b/busybox/stuff/init Mon Nov 09 17:17:30 2009 +0100 1.3 @@ -1,7 +1,52 @@ 1.4 #!/bin/sh 1.5 1.6 +mount_mapper() 1.7 +{ 1.8 + mount $root /mnt 1.9 + if [ -d /mnt/etc ]; then 1.10 + umount /sys 1.11 + for i in /dev/mapper $@ ; do 1.12 + cp -a $i /mnt$i 1.13 + done 1.14 + umount /proc 1.15 + echo -e "\\033[70G[ \\033[1;33mOK\\033[0;39m ]" 1.16 + exec /sbin/switch_root mnt /sbin/init 1.17 + fi 1.18 + echo -e "\\033[70G[ \\033[1;31mFailed\\033[0;39m ]" 1.19 +} 1.20 + 1.21 +mount -t proc proc /proc 1.22 +mount -t sysfs sysfs /sys 1.23 +if grep -q dmraid= /proc/cmdline; then 1.24 + root="$(sed 's/.*dmraid=\([^ ]*\).*/\1/' < /proc/cmdline)" 1.25 + echo -n "Switching / to dmraid $root..." 1.26 + case "$(dmraid -s | grep ^type | awk '{ print $3 }')" in 1.27 + mirror) modprobe dm-mirror;; 1.28 + raid[456]*) modprobe raid456;; 1.29 + esac 1.30 + name=$(dmraid -s | grep ^name | awk '{ print $3 }') 1.31 + case "$root" in 1.32 + /dev/*);; 1.33 + p*) root=/dev/mapper/${name}$root ;; 1.34 + *) root=/dev/mapper/${name}p$root ;; 1.35 + esac 1.36 + dmraid -ay 1.37 + mount_mapper 1.38 +elif grep -q softraid= /proc/cmdline; then 1.39 + root="$(sed 's/.*softraid=\([^ ]*\).*/\1/' < /proc/cmdline)" 1.40 + echo -n "Switching / to softraid $root..." 1.41 + mdadm --examine --scan --config=partitions > /etc/mdadm.conf 1.42 + grep level=raid /etc/mdadm.conf | while read line; do 1.43 + case "$line" in 1.44 + *=raid1\ *) modprobe dm-mirror ;; 1.45 + *=raid[456]\ *) modprobe raid456 ;; 1.46 + esac 1.47 + done 1.48 + mdadm --assemble --scan 1.49 + mount_mapper /etc/mdadm.conf 1.50 +fi 1.51 +umount /sys 1.52 echo -n "Switching / to tmpfs..." 1.53 -mount -t proc proc /proc 1.54 size="$(grep rootfssize= < /proc/cmdline | \ 1.55 sed 's/.*rootfssize=\([0-9]*[kmg%]\).*/-o size=\1/')" 1.56 free=$(busybox free | busybox awk '/Mem:/ { print int(($4*100)/$3) }')