Index: uspace/srv/bd/hr/raid1.c
===================================================================
--- uspace/srv/bd/hr/raid1.c	(revision f6590c438a05eef50987733a9f05063ef031c2f8)
+++ uspace/srv/bd/hr/raid1.c	(revision 09c195e8b9cf55320cf91b7cc57d99fd9542e356)
@@ -62,6 +62,4 @@
     void *, const void *, size_t);
 static errno_t hr_raid1_rebuild(void *);
-static errno_t init_rebuild(hr_volume_t *, size_t *);
-static errno_t swap_hs(hr_volume_t *, size_t, size_t);
 
 /* bdops */
@@ -459,5 +457,5 @@
 	errno_t rc;
 
-	rc = init_rebuild(vol, &rebuild_idx);
+	rc = hr_init_rebuild(vol, &rebuild_idx);
 	if (rc != EOK)
 		return rc;
@@ -550,102 +548,4 @@
 }
 
-static errno_t init_rebuild(hr_volume_t *vol, size_t *rebuild_idx)
-{
-	errno_t rc = EOK;
-
-	fibril_rwlock_write_lock(&vol->extents_lock);
-	fibril_rwlock_write_lock(&vol->states_lock);
-	fibril_mutex_lock(&vol->hotspare_lock);
-
-	size_t bad = vol->extent_no;
-	for (size_t i = 0; i < vol->extent_no; i++) {
-		if (vol->extents[i].state != HR_EXT_ONLINE) {
-			bad = i;
-			break;
-		}
-	}
-
-	if (bad == vol->extent_no)
-		rc = EINVAL;
-	else if (vol->state != HR_VOL_DEGRADED)
-		rc = EINVAL;
-
-	size_t invalid = vol->extent_no;
-	for (size_t i = 0; i < vol->extent_no; i++) {
-		if (vol->extents[i].state == HR_EXT_INVALID) {
-			invalid = i;
-			break;
-		}
-	}
-
-	if (invalid < vol->extent_no)
-		bad = invalid;
-
-	if (bad != invalid && vol->hotspare_no == 0)
-		rc = EINVAL;
-
-	if (rc != EOK)
-		goto error;
-
-	if (bad != invalid) {
-		size_t hotspare_idx = vol->hotspare_no - 1;
-
-		hr_ext_state_t hs_state = vol->hotspares[hotspare_idx].state;
-		if (hs_state != HR_EXT_HOTSPARE) {
-			HR_ERROR("hr_raid1_rebuild(): invalid hotspare"
-			    "state \"%s\", aborting rebuild\n",
-			    hr_get_ext_state_str(hs_state));
-			rc = EINVAL;
-			goto error;
-		}
-
-		rc = swap_hs(vol, bad, hotspare_idx);
-		if (rc != EOK) {
-			HR_ERROR("hr_raid1_rebuild(): swapping "
-			    "hotspare failed, aborting rebuild\n");
-			goto error;
-		}
-	}
-
-	hr_extent_t *rebuild_ext = &vol->extents[bad];
-
-	HR_DEBUG("hr_raid1_rebuild(): starting REBUILD on extent no. %zu "
-	    "(%"  PRIun  ")\n", bad, rebuild_ext->svc_id);
-
-	atomic_store_explicit(&vol->rebuild_blk, 0, memory_order_relaxed);
-
-	hr_update_ext_state(vol, bad, HR_EXT_REBUILD);
-	hr_update_vol_state(vol, HR_VOL_REBUILD);
-
-	*rebuild_idx = bad;
-error:
-	fibril_mutex_unlock(&vol->hotspare_lock);
-	fibril_rwlock_write_unlock(&vol->states_lock);
-	fibril_rwlock_write_unlock(&vol->extents_lock);
-
-	return rc;
-}
-
-static errno_t swap_hs(hr_volume_t *vol, size_t bad, size_t hs)
-{
-	HR_DEBUG("%s()", __func__);
-
-	service_id_t faulty_svc_id = vol->extents[bad].svc_id;
-	service_id_t hs_svc_id = vol->hotspares[hs].svc_id;
-
-	hr_update_ext_svc_id(vol, bad, hs_svc_id);
-	hr_update_ext_state(vol, bad, HR_EXT_HOTSPARE);
-
-	hr_update_hotspare_svc_id(vol, hs, 0);
-	hr_update_hotspare_state(vol, hs, HR_EXT_MISSING);
-
-	vol->hotspare_no--;
-
-	if (faulty_svc_id != 0)
-		block_fini(faulty_svc_id);
-
-	return EOK;
-}
-
 /** @}
  */
Index: uspace/srv/bd/hr/util.c
===================================================================
--- uspace/srv/bd/hr/util.c	(revision f6590c438a05eef50987733a9f05063ef031c2f8)
+++ uspace/srv/bd/hr/util.c	(revision 09c195e8b9cf55320cf91b7cc57d99fd9542e356)
@@ -69,4 +69,5 @@
     hr_metadata_type_t);
 static errno_t hr_fill_svcs_list_from_cfg(hr_config_t *, list_t *);
+static errno_t hr_swap_hs(hr_volume_t *, size_t, size_t);
 
 #define HR_RL_LIST_LOCK(vol) (fibril_mutex_lock(&(vol)->range_lock_list_lock))
@@ -1128,4 +1129,105 @@
 }
 
+errno_t hr_init_rebuild(hr_volume_t *vol, size_t *rebuild_idx)
+{
+	errno_t rc = EOK;
+
+	if (vol->level == HR_LVL_0)
+		return EINVAL;
+
+	fibril_rwlock_write_lock(&vol->extents_lock);
+	fibril_rwlock_write_lock(&vol->states_lock);
+	fibril_mutex_lock(&vol->hotspare_lock);
+
+	size_t bad = vol->extent_no;
+	for (size_t i = 0; i < vol->extent_no; i++) {
+		if (vol->extents[i].state != HR_EXT_ONLINE) {
+			bad = i;
+			break;
+		}
+	}
+
+	if (bad == vol->extent_no)
+		rc = EINVAL;
+	else if (vol->state != HR_VOL_DEGRADED)
+		rc = EINVAL;
+
+	size_t invalid = vol->extent_no;
+	for (size_t i = 0; i < vol->extent_no; i++) {
+		if (vol->extents[i].state == HR_EXT_INVALID) {
+			invalid = i;
+			break;
+		}
+	}
+
+	if (invalid < vol->extent_no)
+		bad = invalid;
+
+	if (bad != invalid && vol->hotspare_no == 0)
+		rc = EINVAL;
+
+	if (rc != EOK)
+		goto error;
+
+	if (bad != invalid) {
+		size_t hotspare_idx = vol->hotspare_no - 1;
+
+		hr_ext_state_t hs_state = vol->hotspares[hotspare_idx].state;
+		if (hs_state != HR_EXT_HOTSPARE) {
+			HR_ERROR("hr_raid1_rebuild(): invalid hotspare"
+			    "state \"%s\", aborting rebuild\n",
+			    hr_get_ext_state_str(hs_state));
+			rc = EINVAL;
+			goto error;
+		}
+
+		rc = hr_swap_hs(vol, bad, hotspare_idx);
+		if (rc != EOK) {
+			HR_ERROR("hr_raid1_rebuild(): swapping "
+			    "hotspare failed, aborting rebuild\n");
+			goto error;
+		}
+	}
+
+	hr_extent_t *rebuild_ext = &vol->extents[bad];
+
+	HR_DEBUG("hr_raid1_rebuild(): starting REBUILD on extent no. %zu "
+	    "(%"  PRIun  ")\n", bad, rebuild_ext->svc_id);
+
+	atomic_store_explicit(&vol->rebuild_blk, 0, memory_order_relaxed);
+
+	hr_update_ext_state(vol, bad, HR_EXT_REBUILD);
+	hr_update_vol_state(vol, HR_VOL_REBUILD);
+
+	*rebuild_idx = bad;
+error:
+	fibril_mutex_unlock(&vol->hotspare_lock);
+	fibril_rwlock_write_unlock(&vol->states_lock);
+	fibril_rwlock_write_unlock(&vol->extents_lock);
+
+	return rc;
+}
+
+static errno_t hr_swap_hs(hr_volume_t *vol, size_t bad, size_t hs)
+{
+	HR_DEBUG("%s()", __func__);
+
+	service_id_t faulty_svc_id = vol->extents[bad].svc_id;
+	service_id_t hs_svc_id = vol->hotspares[hs].svc_id;
+
+	hr_update_ext_svc_id(vol, bad, hs_svc_id);
+	hr_update_ext_state(vol, bad, HR_EXT_HOTSPARE);
+
+	hr_update_hotspare_svc_id(vol, hs, 0);
+	hr_update_hotspare_state(vol, hs, HR_EXT_MISSING);
+
+	vol->hotspare_no--;
+
+	if (faulty_svc_id != 0)
+		block_fini(faulty_svc_id);
+
+	return EOK;
+}
+
 /** @}
  */
Index: uspace/srv/bd/hr/util.h
===================================================================
--- uspace/srv/bd/hr/util.h	(revision f6590c438a05eef50987733a9f05063ef031c2f8)
+++ uspace/srv/bd/hr/util.h	(revision 09c195e8b9cf55320cf91b7cc57d99fd9542e356)
@@ -112,4 +112,5 @@
 extern void hr_raid5_xor(void *, const void *, size_t);
 extern errno_t hr_sync_extents(hr_volume_t *);
+extern errno_t hr_init_rebuild(hr_volume_t *, size_t *);
 
 #endif
