]> git.ipfire.org Git - thirdparty/mdadm.git/blame - mkinitramfs
imsm: fix spare promotion
[thirdparty/mdadm.git] / mkinitramfs
CommitLineData
0ff1a185
NB
1#!/bin/sh
2
3# make sure we are being run in the right directory...
4if [ -f mkinitramfs ]
5then :
6else
7 echo >&2 mkinitramfs must be run from the mdadm source directory.
8 exit 1
9fi
10if [ -f /bin/busybox ]
11then : good, it exists
12 case `file /bin/busybox` in
13 *statically* ) : good ;;
14 * ) echo >&2 mkinitramfs: /bin/busybox is not statically linked: cannot proceed.
15 exit 1
16 esac
17else
18 echo >&2 "mkinitramfs: /bin/busybox doesn't exist - please install it statically linked."
19 exit 1
20fi
21
22rm -rf initramfs
23mkdir initramfs
24mkdir initramfs/bin
25make mdadm.static
26cp mdadm.static initramfs/bin/mdadm
27cp /bin/busybox initramfs/bin/busybox
28ln initramfs/bin/busybox initramfs/bin/sh
29cat <<- END > initramfs/init
30 #!/bin/sh
31
32 echo 'Auto-assembling boot md array'
33 mkdir /proc
34 mount -t proc proc /proc
35 if [ -n "$rootuuid" ]
36 then arg=--uuid=$rootuuid
37 elif [ -n "$mdminor" ]
38 then arg=--super-minor=$mdminor
39 else arg=--super-minor=0
40 fi
41 echo "Using $arg"
42 mdadm -Acpartitions $arg --auto=part /dev/mda
43 cd /
44 mount /dev/mda1 /root || mount /dev/mda /root
45 umount /proc
46 cd /root
47 exec chroot . /sbin/init < /dev/console > /dev/console 2>&1
48END
49chmod +x initramfs/init
50
51(cd initramfs
52 find init bin | cpio -o -H newc | gzip --best
53) > init.cpio.gz
54rm -rf initramfs
55ls -l init.cpio.gz
56
57