Use an index loop as range loops over copies, not references

There have been a few issues opened on this (#1637, #1592, #1090) but the fix didn't work. Looping with range, a copy of each `BlockDevice` is edited so the changes don't end up in the `BlockDevices` struct. Using an indexed loop seems like a quick and easy fix.

Fixes #1637