merge of '375e23fc245ce8133b9f6b1700490e3ff83121e7'
[openembedded.git] / packages / openprotium-init / files / boot / disk
1 #!/bin/sh
2 # boot from the hard disk partition "$1" (which
3 # must be given) using options from the rest of
4 # the command line.
5 #
6 # Use the standard init path (see /etc/init.d/rcS)
7 export PATH=/sbin:/bin:/usr/sbin:/usr/bin
8 #
9 # Load the helper functions
10 . /etc/default/functions
11 . /etc/default/modulefunctions
12 #
13 #
14 if test -n "$1"
15 then
16         device="$1"
17         shift
18         # proc is needed for UUID mount and module load
19         mount -t proc proc /proc
20         # load USB & SCSI storage modules (/proc required!)
21         if [ "$(machine)" != "storcenter" ]; then
22                 echo "boot: loading modules required for disk boot"
23                 loaddiskmods
24                 # waiting for disk (FIXME)
25                 sleep=6
26                 test "$sleep" -gt 0 && sleep "$sleep"
27         else
28                 # make the device links so turnup can use short disk names.
29                 # probably only necessary on devfs based systems.
30                 /etc/init.d/devices start
31                 scc -l redflash -f auto
32         fi
33         #
34         # fire the boot
35         echo "boot: rootfs: mount $* $device [$UUID]"
36         #
37         # Mount read-write because before exec'ing init
38         # If a UUID is given (in the environment) this
39         # is used in preference to the device, but if
40         # the UUID mount fails a standard device mount
41         # is attempted.
42         if      test -n "$UUID" &&
43                 mount "$@" -U "$UUID" /mnt ||
44                 mount "$@" "$device" /mnt
45         then
46                 # checkmount checks for sh, chroot, init
47                 # and /mnt (i.e. /mnt/mnt in this case)
48                 if checkmount /mnt
49                 then
50                         # if mounted, then move /dev to the new root
51                         mount --bind /dev /mnt/dev
52                         # pivot to /initrd if available, else /mnt
53                         cd /
54                         if test -d /mnt/initrd
55                         then
56                                 swivel mnt initrd
57                         else
58                                 swivel mnt mnt
59                         fi
60                         # swivel failed
61                 fi
62                 # Failure: unmount the partition
63                 umount /mnt
64         fi
65 fi
66 # fallback - use the flash boot
67 exec /boot/flash