~ubuntu-branches/ubuntu/hardy/mdadm/hardy-updates

« back to all changes in this revision

Viewing changes to debian/initramfs/init-premount

  • Committer: Package Import Robot
  • Author(s): Dustin Kirkland
  • Date: 2008-11-06 22:15:08 UTC
  • Revision ID: package-import@ubuntu.com-20081106221508-arjst6xrcyfpco8x
Tags: 2.6.3+200709292116+4450e59-3ubuntu3.1
* Fixes for LP: #290885, backported from Intrepid to Hardy
* Backport functionality to enable booting degraded RAID from Intrepid to
  Hardy
* debian/control: these fixes require initramfs-tools >= 0.85eubuntu39.3
* debian/initramfs/init-premount: enhance the init handling to allow for
  booting a degraded RAID, and add the appropriate fail hook
* debian/mdadm-udeb.dirs, debian/mdadm.config, debian/mdadm.postinst,
  debian/po/*, debian/install-rc, debian/mdadm-udeb.templates:
  partman/install/debconf boot-degraded-raid configurability
* check.d/root_on_raid, check.d/_numbers: installer script to determine if /
  or /boot is on a RAID device

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
mountroot_fail()
13
13
{
14
 
        if ! mdadm --misc --scan --detail 2> /dev/null ; then
 
14
        if ! mdadm --misc --scan --detail >/dev/null 2>&1; then
15
15
                cat <<EOF
16
 
There appears to be one or more degraded RAID devices, and your root device
17
 
may depend on the RAID devices being online. One or more of the following RAID
18
 
devices are degraded:
 
16
** WARNING: There appears to be one or more degraded RAID devices **
 
17
 
 
18
The system may have suffered a hardware fault, such as a disk drive
 
19
failure.  The root device may depend on the RAID devices being online. One
 
20
or more of the following RAID devices are degraded:
19
21
EOF
20
22
                cat /proc/mdstat
21
23
 
22
 
                cat <<EOF
23
 
If you want to attempt to boot with the RAID in degraded mode, type:
24
 
  mdadm -R /dev/mdX
25
 
where X is the number of the md device listed above.
 
24
                BOOT_DEGRADED="false"
 
25
                # Read BOOT_DEGRADED from file
 
26
                if [ -r "/conf/conf.d/mdadm" ]; then
 
27
                        . /conf/conf.d/mdadm
 
28
                fi
 
29
                # But allow for overides on the kernel command line
 
30
                for x in $(cat /proc/cmdline); do
 
31
                        case $x in
 
32
                                bootdegraded)
 
33
                                        BOOT_DEGRADED="true"
 
34
                                ;;
 
35
                                bootdegraded=*)
 
36
                                        BOOT_DEGRADED=${x#bootdegraded=}
 
37
                                ;;
 
38
                        esac
 
39
                done
 
40
                # Allow for a couple of permutations, {true|1|yes|on}
 
41
                case "$BOOT_DEGRADED" in
 
42
                        1)    BOOT_DEGRADED="true";;
 
43
                        yes)  BOOT_DEGRADED="true";;
 
44
                        on)   BOOT_DEGRADED="true";;
 
45
                esac
 
46
                # Finally, prompt interactively if the user has not specified
 
47
                # to boot degraded either in a configuration file or as a
 
48
                # kernel boot parameter
 
49
                if [ "$BOOT_DEGRADED" != "true" ]; then
 
50
                        cat <<EOF
 
51
You may attempt to start the system anyway, or stop now and attempt
 
52
manual recovery operations.  To do this automatically in the future,
 
53
add "bootdegraded=true" to the kernel boot options.
 
54
 
 
55
If you choose to start the degraded RAID, the system may boot normally,
 
56
but performance may be degraded, and a further hardware fault could
 
57
result in permanent data loss.
 
58
 
 
59
If you abort now, you will be provided with a recovery shell.
 
60
 
26
61
EOF
27
 
                exit 1
 
62
                        # Set a 15-second timeout for this question
 
63
                        ANSWER="unanswered"
 
64
                        read -t 15 -p "Do you wish to start the degraded RAID? [y/N]: " -r ANSWER
 
65
                        case "$ANSWER" in
 
66
                                unanswered) echo "Timed out" ;;
 
67
                                y*|Y*)  BOOT_DEGRADED="true" ;;
 
68
                                *)      BOOT_DEGRADED="false";;
 
69
                        esac
 
70
                fi
 
71
                if [ "$BOOT_DEGRADED" = "true" ]; then
 
72
                        echo "Attempting to start the RAID in degraded mode..."
 
73
                        if mdadm --assemble --scan --run; then
 
74
                                echo "Started the RAID in degraded mode."
 
75
                                exit 0
 
76
                        else
 
77
                                echo "Could not start the RAID in degraded mode."
 
78
                        fi
 
79
                fi
28
80
        fi
 
81
        exit 1
29
82
}
30
83
 
31
84
case $1 in
42
95
 
43
96
. /scripts/functions
44
97
 
45
 
add_mountroot_fail_hook
 
98
add_mountroot_fail_hook_d "10-mdadm"
46
99
 
47
100
exit 0
48
101