This patch is based on the md.c that shipped with the 2.2.11 kernel; it
calls md_stop() on all RAID partitions still around at shutdown/reboot
time, which allows one to have a small (non-RAID) /boot partition with
a kernel on it and a larger (RAID1) partition that's /. 

I'm a bit paranoid, so I've got the following setup:
                    raidboot      safeboot
/dev/sda1 : 128MB:  /safefs          /
/dev/sdb1 : 128MB:    swap          swap
/dev/sda2 : 8.5GB:  (RAID1) /        -
/dev/sdb2 : 8.5GB:  (RAID1) /        -

and a lilo.conf that looks like:

map=/boot/map
vga=normal
delay=20
image=/boot/bzImage.safe
        label=Linux-safe
        read-only
        root=/dev/sda1
image=/boot/bzImage.md
        label=Linux-md
        append="panic=60 md=0,1,4k,0,/dev/sda2,/dev/sdb2"
        read-only
        root=/dev/md0

As part of its rc scripts, the raidboot config runs lilo -R Linux-md.
As part of its rc scripts, the safeboot config runs ckraid on the md
device (and sends email saying it had a problem). 

Hope someone else finds this useful...

 --pj



*** /usr/src/linux-2.2.11/drivers/block/md.c    Sat Oct 31 12:37:14 1998
--- /usr/src/pjz-2.2.11/drivers/block/md.c      Wed Sep  8 00:36:33 1999
***************
*** 64,69 ****
--- 64,74 ----
  #include <asm/atomic.h>
  #ifdef CONFIG_MD_BOOT
+ #include <linux/notifier.h>
+ #include <linux/reboot.h>
+ static int md_halt(struct notifier_block *nb, ulong event, void *buf);
+ struct notifier_block md_notifier_block = { md_halt, NULL, 0 };
+
  extern kdev_t name_to_kdev_t(char *line) __init;
  #endif
***************
*** 1267,1277 ****
                        "Recompile the kernel with striped mode enabled!\n");
  #endif
                break;
! /*      not supported yet
        case 1:
                pers = RAID1;
                printk ("md: Setting up md%d as a raid1 device.\n",minor);
                break;
        case 5:
                pers = RAID5;
                printk ("md: Setting up md%d as a raid5 device.\n",minor);
--- 1272,1288 ----
                        "Recompile the kernel with striped mode enabled!\n");
  #endif
                break;
!
        case 1:
                pers = RAID1;
+ #ifdef CONFIG_MD_MIRRORING
                printk ("md: Setting up md%d as a raid1 device.\n",minor);
+ #else
+               printk ("md: Mirroring mode not configured."
+                       "Recompile the kernel with mirroring (raid1) mode enabled!\n");
+ #endif
                break;
+ /*      not supported yet
        case 5:
                pers = RAID5;
                printk ("md: Setting up md%d as a raid5 device.\n",minor);
***************
*** 1348,1356 ****
--- 1359,1390 ----
  }
  #ifdef CONFIG_MD_BOOT
+
+ static int md_halt(struct notifier_block *nb, ulong event, void *buf)
+ {
+   int i;
+
+   if (!(event == SYS_RESTART || event == SYS_HALT || event == SYS_POWER_OFF))
+     return NOTIFY_DONE;
+
+   /* stop all the RAID devices */
+
+   for (i=0; i<MAX_MD_DEV; i++)
+   {
+      if (md_dev[i].pers) {
+         do_md_stop(i, md_dev[i].devices[0].inode);
+      }
+   }
+
+   unregister_reboot_notifier(&md_notifier_block);
+   return NOTIFY_OK;
+ }
+ 
  __initfunc(void md_setup_drive(void))
  {
        if(md_setup_args.set)
                do_md_setup(md_setup_args.str, md_setup_args.ints);
+
+         register_reboot_notifier(&md_notifier_block);
  }
  #endif

Reply via email to