From d2fafe03168085ba6782d8d6c45b4a51d940169f Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Wed, 13 Aug 2014 12:04:08 +0200 Subject: [PATCH] installer: Try harder to stop pre-existing software raids. --- src/installer/hw.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/installer/hw.c b/src/installer/hw.c index 0025e7d756..9e8e13eb27 100644 --- a/src/installer/hw.c +++ b/src/installer/hw.c @@ -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) { -- 2.39.2