2

I have a raid0 md disk made up of 2 equalized disks. I would like to remove & replace one of the disks (with a disk of the same capacity), without losing any data. Since the md filesystem is only 42% full, all the data should fit on one of the disks. Is is possible to "move" all the data to one of the disks, so I can remove one of them? I presume I'll have to shrink the filesystem, then replace the disk. How do I then add the new disk to the md disk, and re-distribute the data between the two disks?

Ubuntu 20.04 focal, Linux 5.4.0, mdadmn 4.1

Amandasaurus
  • 30,211
  • 62
  • 184
  • 246

2 Answers2

2

You cannot do this. RAID0 works by writing stripes alternating between drives. So, first x MB of your virtual drive is on drive 0, next x MB on drive 1 etc.

You need to set up the drives from scratch.

Tero Kilkanen
  • 34,499
  • 3
  • 38
  • 58
  • 1
    This answer is wrong, and I'm not sure why it was upvoted so much. You CAN do this. MDADM works at a partition level and allows you to shrink partitions. You can thus shrink the OS, then shrink partitions mdadm sits on to half or less, then create second partition on one drive, move (bitcopy) obsoleted partition to new drive. You can then remove drive. Reverse process to expand. – davidgo Aug 06 '20 at 19:57
  • This process is fraught, and cant be done online and it is likely easier, faster - and definitely less risky - to do a backup and restore, but it is possible. – davidgo Aug 06 '20 at 19:58
  • 2
    Please add an answer where the steps are described, I'd like to see how it is done. – Tero Kilkanen Aug 06 '20 at 21:10
  • 2
    @teroKikanen Apologies - it turns out I could not do it despite what the man page said. (I tried to undo my downvote, but it got locked in somehow :<). – davidgo Aug 07 '20 at 02:29
2

a) Backup your data b) Break the RAID leaving two individual disks left c) Format single disk with a local file system d) Get your data back from the backup done with (a) e) Unmount your unneeded disk

RiGiD5
  • 837
  • 1
  • 6
  • 10