You can set the number of disks in a RAID-1 array to whatever you want (well, any positive integer), including 1. Simply remove all but the one component you want to keep with mdadm --remove
, then set the number of components to 1:
mdadm /dev/md999 --grow --force -n 1
By the way, conversely, if you think you might want to make a mirror of a disk or partition, it is a good idea to set it up as a single-component RAID-1 array from the start. (You can do it later by shrinking the filesystem by 128kB and creating a superblock, but it's a lot easier to create the array first and then put a filesystem on it.)
It's possible to turn the single remaining component into a standalone volume: stop the array with mdadm --stop
, then use mdadm --zero-superblock
on the component volume. Since the md superblock is at the end of the component volume, whatever filesystem that was on the RAID-1 volume is also directly accessible on each component volume. If you do this, you'll even be able to enlarge the filesystem by 64kB to 128kB (depending on alignment). All in all, it's possible, but hardly worth the trouble. I recommend keeping the mirror with a single component — who knows, maybe you'll want to replicate it again one day (if nothing else, RAID-1 reconstruction is a very fast way of copying the contents of a disk to another disk, and it doesn't mind that the disk is mounted at the time).
Note that with mdadm 1, the default location for the superblock is at the beginning of the device, so the filesystem doesn't start at the same location as the RAID device. Choose version 1.0 superblock instead of the default 1.2 (or 0.9 for backward compatibility) to put the superblock at the end of the device. If you have a 1.1 or 1.2 superblock, you can't easily convert the volume into a non-mdraid volume.
1"if you think you might want to make a mirror of a disk or partition, it is a good idea to set it up as a single-component RAID-1 array from the start." This is actually one intention, to be able to optionally add a disk to be mirrored at a later time. Thanks much! – andyortlieb – 2010-10-27T19:46:23.987
5I found this answer useful in a situation where I started with one RAID1 partition and later added another partition. This is how you create a single-component RAID1:
mdadm --create /dev/md0 --level=1 --force --raid-devices=1 --metadata 1.2 /dev/sdd1
– Antti Kissaniemi – 2011-03-01T06:45:38.820