~ubuntu-branches/ubuntu/raring/mdadm/raring

1.1.4 by Scott James Remnant
Import upstream version 2.4.1
1
#!/bin/sh
2
3
# make sure we are being run in the right directory...
4
if [ -f mkinitramfs ]
5
then :
6
else
7
  echo >&2 mkinitramfs must be run from the mdadm source directory.
8
  exit 1
9
fi
10
if [ -f /bin/busybox ]
11
then : 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
17
else
18
  echo >&2 "mkinitramfs: /bin/busybox doesn't exist - please install it statically linked."
19
    exit 1
20
fi
21
22
rm -rf initramfs
23
mkdir initramfs
24
mkdir initramfs/bin
25
make mdadm.static
26
cp mdadm.static initramfs/bin/mdadm
27
cp /bin/busybox initramfs/bin/busybox
28
ln initramfs/bin/busybox initramfs/bin/sh
29
cat <<- 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
48
END
49
chmod +x initramfs/init
50
51
(cd initramfs
52
 find init bin | cpio -o -H newc | gzip --best
53
) > init.cpio.gz
54
rm -rf initramfs
55
ls -l init.cpio.gz
56
57