[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#537928: $NAMED_SPARES is miscounted (breaks auto-raid when using more than 1 spare)



Package: partman-auto-raid
Version: 14

I'm preseed installing using two spares. The auto-raidcfg script is
not properly counting spares resulting in mdadm error (fatal).

tty0: (in red)

  An unexpected error occurred while setting up a preseeded RAID
  configuration.

  Check /var/log/syslog or see virtual console 4 for the details.

syslog:

  partman-auto-raid: Selected spare count: 1
  partman-auto-raid: Spare devices count: 2
  partman-auto-raid: mdadm: You have listed more devices (5) than are in
    the array(4)!
  partman-auto-raid: Error creating array /dev/md0


my preseed.cfg partman-auto-raid rule looks as follows:
d-i partman-auto-raid/recipe string \
    1 2 2 ext3 /                    \
          /dev/sda1#/dev/sdb1       \
          /dev/sdc1#/dev/sdd1       \
    .

Basically spares are counted (with wc) before they are split on '#'.

Below is a patch (tested) to fix this behavior:

--- auto-raidcfg        2008-08-09 14:26:07.000000000 -0500
+++ auto-raidcfg.FIXED  2009-07-20 15:08:29.474764832 -0500
@@ -24,12 +24,14 @@
        DEVICES="$6"
        SPARE_DEVICES="$7"
 
-       NAMED_SPARES=$(echo $SPARE_DEVICES | wc -w)
-
        RAID_DEVICES=$(echo $DEVICES | sed -e "s/#/ /g")
 
        SPARE_DEVICES=$(echo $SPARE_DEVICES | sed -e "s/#/ /g")
 
+       # fixed - needs to run after splitting SPARE_DEVICES
+       NAMED_SPARES=$(echo $SPARE_DEVICES | wc -w)
+
+
        if [ "$RAID_TYPE" != "0" ]; then
                # Count them
                SELECTED=$(echo $RAID_DEVICES | wc -w)


To work around this problem without rebuilding installer packages,
I'm running following script from inittab to replace auto-raidcfg
(I placed it into initrd along with preseed.cfg and /bin/auto-raidcfg.fixed):

/bin/fix-auto-raidcfg:

  #!/bin/sh

  /bin/echo -n "waiting for /bin/auto-raidcfg to appear: ";
  while [ ! -e /bin/auto-raidcfg ]; do
    /bin/sleep 1;
    /bin/echo -n ".";
  done;

  /bin/echo "";

  /bin/mv /bin/auto-raidcfg.fixed /bin/auto-raidcfg
  /bin/echo "*** replaced /bin/auto-raidcfg with a fixed version"

  /bin/echo -n "sleeping: "
  while true; do
    /bin/echo -n '.';
    sleep 1;
  done;


my initrd's /etc/inittab looks as follows:

  # /etc/inittab
  # busybox init configuration for debian-installer

  # main rc script
  ::sysinit:/sbin/reopen-console /sbin/debian-installer-startup

  # main setup program
  ::respawn:/sbin/reopen-console /sbin/debian-installer

  # convenience shells
  tty2::askfirst:-/bin/sh
  tty3::askfirst:-/bin/sh

  # logging
  tty4::respawn:/usr/bin/tail -f /var/log/syslog

  # fix auto-raidcfg script
  tty5::respawn:/bin/fix-auto-raidcfg

  # Stuff to do before rebooting
  ::ctrlaltdel:/sbin/shutdown > /dev/null 2>&1

  # re-exec init on receipt of SIGHUP/SIGUSR1
  ::restart:/sbin/init


Please let me know if you accept my patch.

Thanks, Michal


ps. Since I'm already modifying auto-raidcfg, I'm using a non-default
    chunk size (not shown in above code). Ability to specify chunk
    size in partman-auto-raid/recipe would be nice... optimal chunk size
    increased sequential IO on my systems by 30%.

-- 
Michal Sabala                               | "There are 10 types of
Research Programmer / System Administrator  | people in the world. Those
LAC/NCDM: University of Illinois at Chicago | who understand binary and
tel. (312)-996-9546                         | those who don't."



Reply to: