]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
installer: Try harder to stop pre-existing software raids.
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 13 Aug 2014 10:04:08 +0000 (12:04 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 13 Aug 2014 10:04:08 +0000 (12:04 +0200)
src/installer/hw.c

index 0025e7d7562680f0f3e5dfbda69640c0b85c180c..9e8e13eb27c185e71be8d4b0513f494176ab0b48 100644 (file)
@@ -809,12 +809,36 @@ int hw_umount_filesystems(struct hw_destination* dest, const char* prefix) {
        return 0;
 }
 
+static int hw_destroy_raid_superblocks(const struct hw_destination* dest) {
+       char cmd[STRING_SIZE];
+
+       hw_stop_all_raid_arrays();
+       hw_stop_all_raid_arrays();
+
+       if (dest->disk1) {
+               snprintf(cmd, sizeof(cmd), "/sbin/mdadm --zero-superblock %s", dest->disk1);
+               mysystem(cmd);
+       }
+
+       if (dest->disk2) {
+               snprintf(cmd, sizeof(cmd), "/sbin/mdadm --zero-superblock %s", dest->disk2);
+               mysystem(cmd);
+       }
+
+       return 0;
+}
+
 int hw_setup_raid(struct hw_destination* dest) {
        char* cmd = NULL;
        int r;
 
        assert(dest->is_raid);
 
+       // Stop all RAID arrays that might be around (again).
+       // It seems that there is some sort of race-condition with udev re-enabling
+       // the raid arrays and therefore locking the disks.
+       r = hw_destroy_raid_superblocks(dest);
+
        asprintf(&cmd, "echo \"y\" | /sbin/mdadm --create --verbose --metadata=%s --auto=mdp %s",
                RAID_METADATA, dest->path);
 
@@ -869,7 +893,7 @@ int hw_setup_raid(struct hw_destination* dest) {
 }
 
 int hw_stop_all_raid_arrays() {
-       return mysystem("/sbin/mdadm --stop --scan");
+       return mysystem("/sbin/mdadm --stop --scan --verbose");
 }
 
 int hw_install_bootloader(struct hw_destination* dest) {