mdraid: Wrong size of Raid 5, cannot correct, mdadm behaves strangely.
by hachti from LinuxQuestions.org on (#5FVKB)
Hi folks, I am having massive difficulties with a RAID 5 array: Every time it is assembled by mdadm, it has only 2TB of ca. 20TB.
I tried everything I could imagine. I could cry!
Any ideas? But before you reply, I give you some more information, walking through the path of madness. My data on the disks is good and in sync.
(And it survived all these little tries so far...!)
Let's start.
To show where we come from:
Code:root@ficus:~$ cat /proc/mdstat
Personalities : [raid0] [raid1] [raid6] [raid5] [raid4]
unused devices: <none>
root@ficus:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 10,9T 0 disk
sda1 8:1 0 10,9T 0 part
sdb 8:16 0 10,9T 0 disk
sdb1 8:17 0 10,9T 0 part
...Looks all good, so far. We have sda1 and sda2 in the right size.
The disks have a GPT.
No dm signatures present:
Code:root@ficus:~$ mdadm --zero-superblock /dev/sda1
mdadm: Unrecognised md component device - /dev/sda1
root@ficus:~$ mdadm --zero-superblock /dev/sdb1
mdadm: Unrecognised md component device - /dev/sdb1Now comes the incredibly awful part:
Code:root@ficus:~$ mdadm --create --verbose --metadata=1.2 --assume-clean --level=5 --raid-devices=3 --size=max /dev/md98 /dev/sda1 /dev/sdb1 missing
mdadm: layout defaults to left-symmetric
mdadm: chunk size defaults to 512K
mdadm: size set to 11718751744K
mdadm: automatically enabling write-intent bitmap on large array
mdadm: array /dev/md98 started.Look at the size, that looks all correct: 11718751744K.
But NOW:
Code:root@ficus:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 10,9T 0 disk
sda1 8:1 0 10,9T 0 part
md98 9:98 0 1,8T 0 raid5
...That's plain wrong! I don't understand what's going on.
My LVM on top complains massively, of course.
I can now resize the md device - et voila:
Code:root@ficus:~$ mdadm /dev/md98 --grow --size=max --assume-clean
mdadm: component size of /dev/md98 has been set to 11718751744K
root@ficus:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 10,9T 0 disk
sda1 8:1 0 10,9T 0 part
md98 9:98 0 21,8T 0 raid5
...Everything works now. My data is there, even LVM is happy.
But only until the next time the array is started.
It then goes back to 2TB. My mdadm.conf is empty.
I have exactly no idea where this 2TB thing might come from.
A last glimpse:
Code:root@ficus:~$ mdadm --detail /dev/md98
/dev/md98:
Version : 1.2
Creation Time : Thu Mar 25 18:47:05 2021
Raid Level : raid5
Array Size : 23437503488 (22351.75 GiB 24000.00 GB)
Used Dev Size : 11718751744 (11175.87 GiB 12000.00 GB)
Raid Devices : 3
Total Devices : 2
Persistence : Superblock is persistent
Intent Bitmap : Internal
Update Time : Thu Mar 25 18:51:29 2021
State : clean, degraded
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
Layout : left-symmetric
Chunk Size : 512K
Consistency Policy : bitmap
Name : ficus:98 (local to host ficus)
UUID : c2732e2b:b12ec8ef:29a2aaa2:53612712
Events : 2
Number Major Minor RaidDevice State
0 8 1 0 active sync /dev/sda1
1 8 17 1 active sync /dev/sdb1
- 0 0 2 removedThe reason for playing this through with only two devices: I needed the third drive to backup the most important stuff from the RAID5. But believe me, it behaves
exactly the same when I use all three disks.
A resync is triggered on any occasion. That's the reason to use --assume-clean whenever accepted by mdadm. Not really needed with two drives, but who knows :rolleyes:
Code:Perhaps mdadm itself is broken? Or my Kernel?
root@ficus:~$ mdadm --version
mdadm - v4.1 - 2018-10-01
root@ficus:~$ uname -a
Linux ficus 5.10.0 #6 SMP PREEMPT Fri Mar 19 11:03:17 CET 2021 x86_64 GNU/LinuxI tried to read every documentation and forum post that could be related. But I did not find anything.
Please share any wisdom! Thank you very much!


I tried everything I could imagine. I could cry!
Any ideas? But before you reply, I give you some more information, walking through the path of madness. My data on the disks is good and in sync.
(And it survived all these little tries so far...!)
Let's start.
To show where we come from:
Code:root@ficus:~$ cat /proc/mdstat
Personalities : [raid0] [raid1] [raid6] [raid5] [raid4]
unused devices: <none>
root@ficus:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 10,9T 0 disk
sda1 8:1 0 10,9T 0 part
sdb 8:16 0 10,9T 0 disk
sdb1 8:17 0 10,9T 0 part
...Looks all good, so far. We have sda1 and sda2 in the right size.
The disks have a GPT.
No dm signatures present:
Code:root@ficus:~$ mdadm --zero-superblock /dev/sda1
mdadm: Unrecognised md component device - /dev/sda1
root@ficus:~$ mdadm --zero-superblock /dev/sdb1
mdadm: Unrecognised md component device - /dev/sdb1Now comes the incredibly awful part:
Code:root@ficus:~$ mdadm --create --verbose --metadata=1.2 --assume-clean --level=5 --raid-devices=3 --size=max /dev/md98 /dev/sda1 /dev/sdb1 missing
mdadm: layout defaults to left-symmetric
mdadm: chunk size defaults to 512K
mdadm: size set to 11718751744K
mdadm: automatically enabling write-intent bitmap on large array
mdadm: array /dev/md98 started.Look at the size, that looks all correct: 11718751744K.
But NOW:
Code:root@ficus:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 10,9T 0 disk
sda1 8:1 0 10,9T 0 part
md98 9:98 0 1,8T 0 raid5
...That's plain wrong! I don't understand what's going on.
My LVM on top complains massively, of course.
I can now resize the md device - et voila:
Code:root@ficus:~$ mdadm /dev/md98 --grow --size=max --assume-clean
mdadm: component size of /dev/md98 has been set to 11718751744K
root@ficus:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 10,9T 0 disk
sda1 8:1 0 10,9T 0 part
md98 9:98 0 21,8T 0 raid5
...Everything works now. My data is there, even LVM is happy.
But only until the next time the array is started.
It then goes back to 2TB. My mdadm.conf is empty.
I have exactly no idea where this 2TB thing might come from.
A last glimpse:
Code:root@ficus:~$ mdadm --detail /dev/md98
/dev/md98:
Version : 1.2
Creation Time : Thu Mar 25 18:47:05 2021
Raid Level : raid5
Array Size : 23437503488 (22351.75 GiB 24000.00 GB)
Used Dev Size : 11718751744 (11175.87 GiB 12000.00 GB)
Raid Devices : 3
Total Devices : 2
Persistence : Superblock is persistent
Intent Bitmap : Internal
Update Time : Thu Mar 25 18:51:29 2021
State : clean, degraded
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
Layout : left-symmetric
Chunk Size : 512K
Consistency Policy : bitmap
Name : ficus:98 (local to host ficus)
UUID : c2732e2b:b12ec8ef:29a2aaa2:53612712
Events : 2
Number Major Minor RaidDevice State
0 8 1 0 active sync /dev/sda1
1 8 17 1 active sync /dev/sdb1
- 0 0 2 removedThe reason for playing this through with only two devices: I needed the third drive to backup the most important stuff from the RAID5. But believe me, it behaves
exactly the same when I use all three disks.
A resync is triggered on any occasion. That's the reason to use --assume-clean whenever accepted by mdadm. Not really needed with two drives, but who knows :rolleyes:
Code:Perhaps mdadm itself is broken? Or my Kernel?
root@ficus:~$ mdadm --version
mdadm - v4.1 - 2018-10-01
root@ficus:~$ uname -a
Linux ficus 5.10.0 #6 SMP PREEMPT Fri Mar 19 11:03:17 CET 2021 x86_64 GNU/LinuxI tried to read every documentation and forum post that could be related. But I did not find anything.
Please share any wisdom! Thank you very much!