4

I want to shrink a mdadm RAID1 from 2TB to 80GB. This is how the setup looks like before shrinking.

root@rescue ~ # lsblk
NAME    MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda       8:0    0   3.7T  0 disk  
├─sda1    8:1    0     4G  0 part  
│ └─md0   9:0    0     4G  0 raid1 
├─sda2    8:2    0   512M  0 part  
│ └─md1   9:1    0 511.4M  0 raid1 
├─sda3    8:3    0     2T  0 part  
│ └─md2   9:2    0     2T  0 raid1 
└─sda5    8:5    0     1M  0 part  
sdb       8:16   0   3.7T  0 disk  
├─sdb1    8:17   0     4G  0 part  
│ └─md0   9:0    0     4G  0 raid1 
├─sdb2    8:18   0   512M  0 part  
│ └─md1   9:1    0 511.4M  0 raid1 
├─sdb3    8:19   0     2T  0 part  
│ └─md2   9:2    0     2T  0 raid1 
└─sdb5    8:21   0     1M  0 part  
loop0     7:0    0     2G  1 loop 

I want to resize /dev/md2. Here are the steps I followed:

--resize filesystem / md2 raid
e2fsck -f /dev/md2
resize2fs /dev/md2 70G
e2fsck -f /dev/md2 # check
mdadm --grow /dev/md2 --size=83886080 #80GB
resize2fs /dev/md2 # expand size
e2fsck -f /dev/md2 # check

--stop md2 raid
mdadm --detail /dev/md2
mdadm --stop /dev/md2


# We checked with mdadm --examine --scan that /etc/mdadm/mdadm.conf was correct

--resize partition
parted /dev/sda
#p
#resizepart 3 80GB
#align-check optimal 3

parted /dev/sdb
#p
#resizepart 3 80GB
#align-check optimal 3


--assemble md2 raid
mdadm -A --scan

The md2 raid fails to assemble and shows the following output:

root@rescue ~ # mdadm -A --scan
mdadm: failed to add /dev/sdb3 to /dev/md/2: Invalid argument
mdadm: failed to add /dev/sda3 to /dev/md/2: Invalid argument
mdadm: failed to RUN_ARRAY /dev/md/2: Invalid argument

And the dmesg output is:

[Fri Jul  8 10:56:45 2016] md: sdb3 does not have a valid v1.2 superblock, not importing!
[Fri Jul  8 10:56:45 2016] md: md_import_device returned -22
[Fri Jul  8 10:56:45 2016] md: sda3 does not have a valid v1.2 superblock, not importing!
[Fri Jul  8 10:56:45 2016] md: md_import_device returned -22
1
  • @frostschutz So what are the steps I should follow? Fail and remove a disk, resize the partition and add the disk again, then do that for the remaining disk? Do I need to stop the mdadm RAID at some point?
    – sudokai
    Commented Jul 8, 2016 at 9:37

1 Answer 1

10

I managed to assemble my raid in the end. This is how you do it: mdadm --assemble --update=devicesize /dev/md2

2
  • 1
    Thanks..... This has solved my problem. I have waste one day for solution.
    – LOKESH
    Commented Jul 27, 2016 at 10:59
  • 1
    damn.. this should be default. thanks!
    – bhelm
    Commented May 15, 2021 at 11:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .