Shrinking Raid 5 Array from 4 to 3 drives [Help]

  • Hi,


    I currently have a OMV 6 Setup with a Raid 5 array. As I want to change some stuff about the drive setup and I will not need the same amout of space on my raid array anymore, I want to remove one of the four drives from the array and shrink the array accordingly. (I currently have four 1.8TB drives and use the btrfs file system)


    What I figured out I have to do:

    0. Create a backup of all the data on the array. Did this one.
    1. Remove the drive from the array. I did this with the Web interface under software raid -> remove -> I then selected the correct drive.

    2. Shrink the BTRFS file system. I did this as well, the file system is now the size it will be at the end (acctually a bit smaler to make sure everything ends up working).

    3. With my 3 * 1.8TB drives the raid array still reports a capacity of 5.4TB and the status of the array is clean, degraded. There was never a rebuilding process.


    Even after some googling I am a bit lost on how to continue from here.

    For some additional info I will paste the status of the raid array into the post.

  • KM0201

    Hat das Thema freigeschaltet.
    • Offizieller Beitrag

    This is doable, but I would go down the route of recreating the array, I've never done this before but have found a couple links;


    link 1


    link 2


    I'm afraid you're on your own if you attempt this

    Raid is not a backup! Would you go skydiving without a parachute?


    OMV 6x amd64 running on an HP N54L Microserver

  • Hey, thanks for the links. While they didn't provide the exact commands I needed they gave me the idea of what I had to do.


    Shrinking the RAID array actually turns out to be rather straight forward once you know the steps. It's just that there isn't much documentation online as I guess it's quite rare that people do it.


    Anyways,

    I will be giving a detailed description of what I did to shrink my array in case anyone else stumbles across this post at a later time.


    1st step; remove the drive from the raid array.

    To do this I used the OMV web interface.

    Storage -> Software RAID -> select your array -> on the top hit remove -> select the correct drive -> confirm

    I think the equivalent on the CLI would be

    • mdadm --manage /dev/mdX --fail /dev/sdX
    • mdadm --manage /dev/mdX --remove /dev/sdX

    2nd step; shrink the file system

    To shrink the array the file system is on we first have to shrink the file system itself. As I wasn't sure what exact size the array will end up I made the file system about 100Gb smaller than the array would be at the end. This way I would just be able to grow it again afterward with the max keyword.


    With btrfs the command for me was: btrfs filesystem resize [your size] [path to mountpoint]

    If you don't use btrfs as a filesystem just use the appropriate command for your filesystem.


    3rd and 4th step; remove 1 raid device and shrink array.

    At this point I wasn't quite sure what to but the status on OMV showed me that there were still four raid devices so I tried: mdadm --grow /dev/md0 --raid-devices=3. (previously there were 4 RAID devices)


    Now, this doesn't actually work at this stage and gave the output:

    "this change will reduce the size of the array. use --grow --array-size first to truncate array. e.g. mdadm --grow /dev/md0 --array-size 3906767872"


    This came in really handy because the suggestion of the error message actually doesn't only contain the command I need to run first but also the exact size that the array could be with 3 drives left. Unfortunately I don't know how you would get this number otherwise, but this worked just fine.


    So I ran the commands:

    • mdadm --grow /dev/md0 --array-size 3906767872

    and then:

    • mdadm --grow /dev/md0 --raid-devices=3

    5th step; reshaping


    After this, the reshaping process started automatically. With 3 x 2Tb drives it took just over 12! hours.


    6th step; fitting the filesystem size to the RAID array.


    As I made the filesystem a bit smaler than necessary to make sure everything works fine, now was the time to grow the file system to fill the entire array. To do this I used the command:

    • btrfs filesystem resize max /path/to/mountpoint

    And with this it's all done.


    Note that you don't actually need to unmount the the filesystem for any of the steps and that the filesystem was accessable throughout the process. I still avoided using it to make sure the reshape completed as fast as possible, but if necessary you could totaly use the array during the time.

  • elio_

    Hat das Label gelöst hinzugefügt.

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!