In place migration to Linux software RAID
February 28, 2012
Suppose that you have an existing system that is operating without mirrored disks and you want to change that; you want to add a second physical disk to the system and then wind up with software RAID mirroring of appropriate filesystems. This generally goes by the name of 'in-place migration'. Knowledge of how to do this used to be more common because back in the old days, distribution installers couldn't set up mirrored system disks during installation; these days installers can and so needing to do this by hand is much rarer.
(In place migration is easy with software RAID implementations that store the metadata 'out of band', outside of the disk space being mirrored. Solaris DiskSuite can more or less trivially do in-place migration to mirrors, with only a minor pause to remount most filesystems. Unfortunately for us, Linux software RAID is not such a thing; it stores its metadata 'in-band', at either the start or the end of the partition being mirrored.)
When this question came up here recently, I said that there are two ways to do in place migration: the traditional, well tested approach that everyone used to use and a theoretically possible approach that I at least have never tested. The well tested approach is not quite literally in-place; the theoretical one is, but is trickier and untested.
The traditional approach goes like this:
Back in the days of Ubuntu 6.06 and similar systems we did this a lot and we never had problems (at least if we weren't shuffling filesystems around at the same time). This is not quite in-place because it involves copying the filesystem, and on a sufficiently busy filesystem it may be troublesome to get a complete and accurate copy (eg, you may need an extended downtime to halt all other activity on the filesystem).
The theoretical way that is fully in-place is to set up your new partition on your new disk and then do something like this:
Depending on how long it takes to shrink the filesystem and whether or not it can be done live, this may require less downtime than the other approach.
I doubt I'll ever use the theoretical way. While it's vaguely neat,
it'll clearly take a bunch of work and testing to develop into something
that can be used for real and it has only marginal advantages over the
tried and true way (especially on extN filesystems, where
Written on 28 February 2012.
* * *
Atom feeds are available; see the bottom of most pages.