~ubuntu-branches/ubuntu/precise/mdadm/precise-updates

« back to all changes in this revision

Viewing changes to debian/initramfs/hook

  • Committer: Package Import Robot
  • Author(s): Surbhi Palande
  • Date: 2010-09-13 18:59:03 UTC
  • Revision ID: package-import@ubuntu.com-20100913185903-13ww08c70g4gna90
Tags: 2.6.7.1-1ubuntu16
* debian/initramfs/hook: Added following code (invoked on update-initramfs)
  (LP: #617725):
  - create a mdadm.conf if it is not found in /etc and copy it in initramfs
  - update an existing mdadm.conf in the initramfs if it does'nt include
    a definition of any array
  - warn the user if the definition of an active array is not found in the
    initramfs/etc/mdadm.conf

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
    ;;
21
21
esac
22
22
 
 
23
is_true()
 
24
{
 
25
        case "${1:-}" in
 
26
                [Yy]es|[Yy]|1|[Tt]rue|[Tt]) return 0;;
 
27
                *) return 1;;
 
28
        esac    
 
29
}
 
30
 
 
31
write()
 
32
{
 
33
        local PREFIX; PREFIX=$1; shift
 
34
        echo "${PREFIX}: mdadm: $@" >&2
 
35
}
 
36
 
 
37
 
 
38
info()
 
39
{
 
40
        is_true ${VERBOSE:-false} && write I "$@" || :
 
41
}
 
42
 
 
43
 
 
44
warn()
 
45
{
 
46
        write W "$@"
 
47
}
23
48
 
24
49
. /usr/share/initramfs-tools/hook-functions
25
50
 
34
59
# copy the mdadm configuration
35
60
CONFIG=/etc/mdadm/mdadm.conf
36
61
ALTCONFIG=/etc/mdadm.conf
 
62
DESTMDADMCONF=$DESTDIR/etc/mdadm/mdadm.conf
37
63
[ ! -f $CONFIG ] && [ -f $ALTCONFIG ] && CONFIG=$ALTCONFIG || :
38
64
mkdir -p ${DESTDIR}/etc/mdadm
39
 
cp -p $CONFIG ${DESTDIR}/etc/mdadm
 
65
 
 
66
if [ ! -f $CONFIG ]; then
 
67
        # there is no configuration file, so let's create one
 
68
        if /usr/share/mdadm/mkconf generate $CONFIG; then
 
69
                # all is well
 
70
                cp -p $CONFIG $DESTMDADMCONF
 
71
                info "auto-generated the mdadm.conf configuration file."
 
72
        else
 
73
                # we failed to auto-generate, so let the emergency procedure take over
 
74
                warn "failed to auto-generate the mdadm.conf file."
 
75
                warn "please read /usr/share/doc/mdadm/README.upgrading-2.5.3.gz ."
 
76
        fi
 
77
else
 
78
        cp -p $CONFIG ${DESTDIR}/etc/mdadm
 
79
        if ! grep -q '^ARRAY' $CONFIG; then
 
80
                tmpfile="${DESTMDADMCONF}.tmp"
 
81
                warn "$CONFIG defines no arrays."
 
82
                if /usr/share/mdadm/mkconf > $tmpfile; then
 
83
                        cp -p $tmpfile $DESTMDADMCONF
 
84
                else
 
85
                        warn "failed to auto-generate temporary mdadm.conf file."
 
86
                fi
 
87
        else
 
88
                # make sure the configuration file knows about all running devices
 
89
                /sbin/mdadm --detail --scan | while read array device params; do
 
90
                        uuid=${params#*UUID=}; uuid=${uuid%% *}
 
91
                        if ! grep -q "UUID=$uuid" $DESTMDADMCONF; then
 
92
                                warn "the array $device with UUID $uuid"
 
93
                                warn "is currently active, but it is not listed in mdadm.conf. if"
 
94
                                warn "it is needed for boot, then YOUR SYSTEM IS NOW UNBOOTABLE!"
 
95
                                warn "please inspect the output of /usr/share/mdadm/mkconf, compare"
 
96
                                warn "it to $CONFIG, and make the necessary changes."
 
97
                        fi
 
98
                done
 
99
        fi
 
100
fi
40
101
 
41
102
# load raid modules in the initramfs
42
103
for module in linear multipath raid0 raid1 raid456 raid5 raid6 raid10; do