1

I have a server which has two 256GB SSDs. They were partitioned as following:

/dev/sda1 100GB linux-raid-autodetect
/dev/sda2 100GB linux-raid-autodetect
/dev/sda3 23,6GB linux-raid-autodetect

/dev/sdb1 100GB linux-raid-autodetect
/dev/sdb2 100GB linux-raid-autodetect
/dev/sdb3 23,6GB linux-raid-autodetect

There were 2 raid1 - devices build and running (using mdadm):

/dev/md1 (built of /dev/sda2 and /dev/sdb2) containing an ext4 filesystem mounted on /
/dev/md2 (built of /dev/sda3 and /dev/sdb3) containing swap filesystem

/dev/sda1 and /dev/sdb1 were used in former times and now are unused.

So I want to remove both unused partition /dev/sdx1 and grow /dev/sdx2 to double size (200GB).

I have proceeded as following:

mdadm --manage /dev/md1 --fail /dev/sda2
mdadm --manage /dev/md1 --remove /dev/sda2

Then I entered fdisk, deleted /dev/sda1 and /dev/sda2 and created one new partition /dev/sda2 which now uses the complete free spave of former /dev/sda1 and /dev/sda2. I set partition identifier to linux-raid-autodetect (fd) and wrote partition table to disk. After doing so I readded /dev/sda2 to /dev/md1 with

mdadm --manage /dev/md1 --add /dev/sda2

and waited for raid syncing finishes. Everything worked as expected. The result is a new /dev/md1 which consists of /dev/sda2 (200GB) and /dev/sdb2 (100GB). Now I proceeded as before with /dev/sdb. After the complete procedure I got partitioning of SSDs as following: /dev/sda2 200GB linux-raid-autodetect /dev/sda3 23,6GB linux-raid-autodetect

/dev/sdb2 200GB linux-raid-autodetect
/dev/sdb3 23,6GB linux-raid-autodetect

and these are part of the same RAID1 /dev/md1 and /dev/md2) as before. Both RAID are running fine. The untouched /dev/md2 is perfectly, but the new /dev/md1 is showing only 100GB (half the space which is in theory available). Of course: raid device needs resized to maximum capacity and filesystem (ext4) must be resized after doing that. So I started

mdadm --grow --array-size=max /dev/md1

...but this has absolutely no effect. The following

resize2fs /dev/md1

results in "Filesystem is already 26198016 (4k) blocks long. Nothing to do!"

What is the problem? I have worked with the system on /dev/md1 so it is mounted. Must I resize raid and filesystem with a rescue system (/dev/md1 not mounted)? Or is there a mistake I am doing?

1
  • 1
    Did the kernel actually re-read partition table and accept the new partition size? Otherwise it's possible the sda2 you re-added was the same old 100GB one. If you didn't reboot, check lsblk, cat /proc/partitions, ... Also check mdadm --examine for these partitions, it should show device size, offsets, etc. Aug 28, 2023 at 6:10

1 Answer 1

1

I have fixed it in the meantime. Syntax for mdadm grow was wrong. It must be

mdadm --grow /dev/md1 --size=max

If I do so I can resize array and after that resize filesystem. This all works without reboot and at mounted filesystem.

You must log in to answer this question.

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