3

New to RAID and Linux. I grew my RAID5 array from 3 to 4 devices. For other reasons, I had to fail and remove one of the 4 drives - sda1. I'd like to shrink it now back to 3 devices, but when trying to do so, I'm getting a new_offset error:

# mdadm --grow --raid-devices=3  /dev/md127
mdadm: Cannot set new_offset for /dev/sdb1

Some notes:

  • The array is mounted at /, so I'd like to avoid having to unmount it.

  • There is data on the array, so I'd like to preserve it.

RAID details:

/dev/md127:
        Version : 1.1
  Creation Time : Mon Oct 22 16:20:37 2012
     Raid Level : raid5
     Array Size : 1953518592 (1863.02 GiB 2000.40 GB)
  Used Dev Size : 976759296 (931.51 GiB 1000.20 GB)
   Raid Devices : 4
  Total Devices : 3
    Persistence : Superblock is persistent

  Intent Bitmap : Internal

    Update Time : Tue Nov  8 17:09:28 2016
          State : active, degraded
 Active Devices : 3
Working Devices : 3
 Failed Devices : 0
  Spare Devices : 0

         Layout : left-symmetric
     Chunk Size : 512K

  Delta Devices : 1, (3->4)

           Name : xxx
           UUID : xxx
         Events : 275192

    Number   Major   Minor   RaidDevice State
       3       8       49        0      active sync   /dev/sdd1
       2       0        0        2      removed
       4       8       33        2      active sync   /dev/sdc1
       6       8       17        3      active sync   /dev/sdb1

Can I fail and remove /dev/sdb1 from the array? I imagine that would solve the error message, but I worry that in growing the array to 4 devices, failing 2 of them will render it irreparable. If that can't be done, what can be?

Update

Worked around the headache. rsynced the contents of the degraded array to a backup drive, replaced the RAID with fresh-baked drives, then rsynced back.

  • hmm... I never knew that you can shrink the number of disks in a RAID with a command line in Linux. In a Windows world, taking an image of the data to an external location, rearranging the RAID and then copy back the image would do it. – Noor Khaldi Nov 8 '16 at 22:24
  • 1
    @NoorKhaldi: You're right. There is no way in Linux. – Ipor Sircer Nov 8 '16 at 22:26
  • @NoorKhaldi I'm growing more convinced that that's the way to do it. But it'd be nice if there was a way that didn't involve shutting things off while the array was being set up – Andrei Khramtsov Nov 8 '16 at 22:27
  • It seems you forgot to use resize2fs first – kay27 Nov 8 '16 at 23:12
1

You can do it but you need to specify a backup file in the command line. In your case something like

mdadm --grow --raid-devices=3  /dev/md127 --backup-file /root/md127.backup 

should work.

If you have a usb stick or some other storage that isn't in the array, use it for backup file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.