Raspberry Pi NAS Kernel Panic with 2- 4TB WDHard Drives in Raid1 & Samba

Hello all,
Thank you in advance for opening this post.
I’m a long time desktop Linux (currently Ubuntu Studio, Linux Mint and Several Raspberry Pis (attached to TV,Retro-Pi)) & user of Open Source software.

I’m trying to create a NAS using a Raspberry Pi 4 (4GB) and 2- 4TB Western Digital Desktop (self-powered/brand new) hard drives. I have the latest “Raspberry Pi OS Lite” image (2021-05-07 raspios-buster-armhf-lite).
I want to mirror the drives in a Raid1 configuration using mdadm & Samba. I’m using this project as a learning vehicle to the process.
I’ve been using the following webpages as guides:

This is my first foray into the world of NAS. I’m using these items because I already have them, low power usage, I want to, I’m pretty sure someone has already done it, and if I mess up, it’s not too much of a loss. I’m not a total NOOB but pretty close. I did as much homework as possible. I set the up the lite image from Raspberry Pi on Virtual Box and used 2- 16GB flash drives. It took extra research because of the VirtualBox aspect but I successfully created the NAS.

I then installed the same image onto my RaspberryPi, used the the same drives (2 16GB USB Flash drives) (wiped them of course) and again, I was successful in creating my NAS.

The final step, with my set of instructions in hand (that worked before), I set out to recreate the process with my two WD 4TB USB Desktop hard drives(self-powered).

My first mistake was not knowing how long it would take for mdadm to finish this process:

(sudo mdadm --create --verbose /dev/md0 --level=mirror --raid-devices=2
/dev/sda1 /dev/sdb1) - 4TB in Raid1=540 minutes

And… that I could use `“cat/proc/mdstat” to monitor the progress.

Because I didn’t know those things, I immediately went to format and mount the device (md0)

“Now format your /dev/md0 device and mount it:
sudo mkdir -p /mnt/raid1
sudo mkfs.ext4 /dev/md0
sudo mount /dev/md0 /mnt/raid1/”

At this point, my system locks up in Kernel panic and I am forced to hard shutdown the Pi.

Somewhere along my trouble shooting I came across the following command and got the following results.:
"dmesg | grep sda1

anon@anon:~ $ dmesg | grep sda1
[ 2.944573] sda: sda1

dmesg | grep sdb1"

anon@anon:~ $ dmesg | grep sdb1
[ 3.450187] sdb: sdb1

It didn’t seem right that now one of my drives was reduced to 3TB, so research…

At this point I learned that I could monitor the sdadm --create process.
I wiped the drives (fdisk), cleaned up mdadm.conf as directed in various searches and re-initiated the mdadm --create process:
(sudo mdadm --create --verbose /dev/md0 --level=mirror --raid-devices=2
/dev/sda1 /dev/sdb1).

I monitored, waited and at the end of 5 hours & 40 minutes, the Pi was successful in this process. I went on to mkfs.ext4 and got the kernel panic.

Best to my knowledge, (over several days) that’s what happened (is happening).

I’m very frustrated. Before moving onto the final project (4TB NAS in Raid1), I practiced with VirtualBox and a smaller version of the NAS. I thought in doing so, I could smooth out the bumps along the way. Well, the bumps are massive pot holes, the vehicle has fallen apart from those potholes and the driver is pretty shaken up from the abuse. :frowning:

I apologize for the length of this post. I’m a longtime listener but don’t often use the forum. In the future, if there is abetter way to post a situation, then please let me know and I will do it that way the next time.

I’m going to copy and paste some of the diagnosis I’ve been getting and my bash history in the hopes that someone with real expertise in the matter will be able (and willing) to show me the error of my ways. Unfortunately, that is going to make the rest of this post ridiculously long.
In my defense, I’ve tried hard to make it easy on the eyes and fairly legible. I just don’t know how else to share them and I’m tired. In the words of the immortal Princess Leia, “Help me Obi Wan Kenobi. You’re my only hope.”

If you should decide to read on, then huge thanks!
P.S. I don’t know why there are now so many ram drives (fdisk) & sorry my bash history is so chaotic. It’s probably a reflection of my frustration.

fdisk -l
anona@anon:~ $ sudo fdisk -l
Disk /dev/ram0: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/ram1: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/ram2: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/ram3: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/ram4: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/ram5: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/ram6: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/ram7: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/ram8: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/ram9: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/ram10: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/ram11: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/ram12: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/ram13: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/ram14: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/ram15: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/mmcblk0: 29.8 GiB, 32010928128 bytes, 62521344 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x078479c6

Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 8192 532479 524288 256M c W95 FAT32 (LBA)
/dev/mmcblk0p2 532480 62521343 61988864 29.6G 83 Linux

Disk /dev/sda: 3.7 TiB, 4000786153472 bytes, 7814035456 sectors
Disk model: My Book 25EE
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: F18B9742-996B-7B46-BF69-E685DF35AF1B

Device Start End Sectors Size Type
/dev/sda1 2048 7814035422 7814033375 3.7T Linux filesystem

Disk /dev/sdb: 3.7 TiB, 4000786153472 bytes, 7814035456 sectors
Disk model: My Book 25EE
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 3C856A81-0D61-CE49-BB0A-261DD97906A0

Device Start End Sectors Size Type
/dev/sdb1 2048 7814035422 7814033375 3.7T Linux filesystem

Disk /dev/md0: 3.7 TiB, 4000649773056 bytes, 7813769088 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
anona@anon:~ $

lsblk & lsblk -a
anon@anon:~ $ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 3.7T 0 disk
└─sda1 8:1 0 3.7T 0 part
└─md0 9:0 0 3.7T 0 raid1
sdb 8:16 0 3.7T 0 disk
└─sdb1 8:17 0 3.7T 0 part
└─md0 9:0 0 3.7T 0 raid1
mmcblk0 179:0 0 29.8G 0 disk
├─mmcblk0p1 179:1 0 256M 0 part /boot
└─mmcblk0p2 179:2 0 29.6G 0 part /

anon@anon:~ $ lsblk -a
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
ram0 1:0 0 4M 0 disk
ram1 1:1 0 4M 0 disk
ram2 1:2 0 4M 0 disk
ram3 1:3 0 4M 0 disk
ram4 1:4 0 4M 0 disk
ram5 1:5 0 4M 0 disk
ram6 1:6 0 4M 0 disk
ram7 1:7 0 4M 0 disk
ram8 1:8 0 4M 0 disk
ram9 1:9 0 4M 0 disk
ram10 1:10 0 4M 0 disk
ram11 1:11 0 4M 0 disk
ram12 1:12 0 4M 0 disk
ram13 1:13 0 4M 0 disk
ram14 1:14 0 4M 0 disk
ram15 1:15 0 4M 0 disk
loop0 7:0 0 0 loop
loop1 7:1 0 0 loop
loop2 7:2 0 0 loop
loop3 7:3 0 0 loop
loop4 7:4 0 0 loop
loop5 7:5 0 0 loop
loop6 7:6 0 0 loop
loop7 7:7 0 0 loop
sda 8:0 0 3.7T 0 disk
└─sda1 8:1 0 3.7T 0 part
└─md0 9:0 0 3.7T 0 raid1
sdb 8:16 0 3.7T 0 disk
└─sdb1 8:17 0 3.7T 0 part
└─md0 9:0 0 3.7T 0 raid1
mmcblk0 179:0 0 29.8G 0 disk
├─mmcblk0p1 179:1 0 256M 0 part /boot
└─mmcblk0p2 179:2 0 29.6G 0 part /

df -h
anon@anon:~ $ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 30G 1.5G 27G 6% /
devtmpfs 1.7G 0 1.7G 0% /dev
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 1.9G 8.5M 1.9G 1% /run
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/mmcblk0p1 253M 49M 205M 20% /boot
tmpfs 389M 0 389M 0% /run/user/1001

lsusb
anon@anon:~ $ lsusb
Bus 002 Device 003: ID 1058:25ee Western Digital Technologies, Inc.
Bus 002 Device 002: ID 1058:25ee Western Digital Technologies, Inc.
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 413c:2105 Dell Computer Corp. Model L100 Keyboard
Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

dmesg | grep sda1 (& sdb1)
anon@anon:~ $ dmesg | grep sda1
[ 2.944573] sda: sda1
anon@anon:~ $ dmesg | grep sdb1
[ 3.450187] sdb: sdb1

nano mdadm.conf
“# mdadm.conf”
" !NB! Run update-initramfs -u after updating this file."
“!NB! This will ensure that initramfs has an uptodate copy.”
“# Please refer to mdadm.conf(5) for information about this file.”

“# by default (built-in), scan all partitions (/proc/partitions) and all”
“# containers for MD superblocks. alternatively, specify devices to scan, using”
“# wildcards if desired.”
'#DEVICE partitions containers"

“# automatically tag new arrays as belonging to the local system”
HOMEHOST

“# instruct the monitoring daemon where to send mail alerts”
MAILADDR root

“# definitions of existing MD arrays”

"# This configuration was auto-generated on Fri, 30 Jul 2021 01:53:39 +0100 by mkconf
ARRAY /dev/md/0 metadata=1.2 name=anon:0 UUID=7cf8c286:7f291275:b78b9ee4:b893c3d7

cat /proc/mdstat
anon@anon:/etc/mdadm $ cat /proc/mdstat
Personalities : [raid1]
md0 : active (auto-read-only) raid1 sda1[0] sdb1[1]
3906884544 blocks super 1.2 [2/2] [UU]
resync=PENDING
bitmap: 30/30 pages [120KB], 65536KB chunk

sudo mkfs.ext4 /dev/md0
When SSH in:
anon@anon:~ $ sudo mkfs.ext4 /dev/md0
mke2fs 1.44.5 (15-Dec-2018)
Discarding device blocks: done
Creating filesystem with 976721136 4k blocks and 244187136 inodes
Filesystem UUID: 4970c373-3276-46b2-8405-0e00be36af42
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000, 214990848, 512000000, 550731776, 644972544

Allocating group tables: done
Writing inode tables: done
Creating journal (262144 blocks): Connection to 192.168.1.xx closed by remote host.
Connection to 192.168.1.xx closed.

When done directly in pi using monitor & keyboard

I get the same but I can see the Kernel panic: “end Kernel panic - not syncing:System is deadlocked on memory”

Machine is locked, I have to cut power and restart.

Bash History
sudo userdel pi
sudo rm -rf /home/pi
raspi-config
sudo raspi-config
sudo apt-get update
ifconfig
sudo apt-get upgrade
sudo apt-get update
cd /etc/
ls -a
sudo less sudoers
less hosts
less hostname
exit
sudo shutdown now
sudo apt-get update
sudo apt-get upgrade
sudo apt-get autoremove python-colorzero
man apt-get
sudo apt-get autoclean
man apt-get
sudo apt-get autoclean
sudo apt-get update
sudo shutdown -r now
ifconfig
ls -a
less .bash_history
sudo apt-get autoremove
msblk
lsblk
df -h
lsblk
df -h
sudo mdadm --create --verbose /dev/md0 --level=mirror --raid-devices=2 /dev/sda1 /dev/sdb1
sudo apt-get install mdadm
sudo mdadm --create --verbose /dev/md0 --level=mirror --raid-devices=2 /dev/sda1 /dev/sdb1
lsblk
sudo fdisk /dev/sda1
lsblk
sudo fdisk /dev/sda1
df -h
lsblk
sudo fdisk /dev/sda1
sudo fdisk /dev/sdb1
lsblk
sudo fdisk /dev/sdb1
lsblk
sudo shutdown -r now
sudo mount /dev/md0 /mnt/raid1
sudo shutdown now
lusb
lsusb
raspi-config
sudo raspi-config
clear
dmesg | grep sda1
dmesg | grep sdb1
fdisk -l
sudo fdisk -l
sudo mdadm --create --verbose /dev/md0 --level=mirror --raid-devices=2 /dev/sda1 /dev/sdb1
mdadm device busy
mdadm --detail /dev/md2
sudo mdadm --detail /dev/md2
sudo mdadm --detail /dev/md0
pwd
cd …
ls
cd /
ls
cd mnt
ls
lsblk
sudo mkfs.ext4 /dev/mdo
fdisk sda1 -w always
lsblk
df -h
fdisk -l
sudo fdisk -l
cd /
sudo fdisk --wipe always /dev/sda
sudo fdisk --wipe always /dev/sdb
fdisk -l
sudo fdisk -l
sudo mdadm --stop /dev/md0
sudo mdadm --detail /dev/md0
sudo fdisk -l
lsblk
sudo fdisk --wipe always /dev/sda
sudo shutdown -r now
sudo fdisk -l
sudo fdisk --wipe always /dev/sda
sudo fdisk --wipe always /dev/sdb
sudo fdisk -l
sudo mdadm --stop /dev/md0
sudo mdadm --detail /dev/md0
cd /etc/mdadm
ls
sudo nano mdadm.conf
sudo umount /dev/md0
df -h
lsblk
cat /proc/mdstat
sudo mdadm --remove /dev/md0
cd /dev/
ls
mdadm --zero-superblock /dev/md0
sudo mdadm --zero-superblock /dev/md0
cat /proc/mdstat
cd /mnt/
ls
sudo umount /mnt/raid1
sudo fdisk /dev/sda
sudo shutdown -r now
fdisk -l
sudo fdisk -l
sudo fdisk /dev/sdb
sudo shutdown -r now
cat /proc/mdstat
sudo -i
cat /etc/mdadm/mdadm.conf
update-initramfs -u
sudo shutdown -r now
lsblk -l
cd mnt
cd /mnt
ls -a
cd raid1/
ls
ls -a
lsblk
cat/proc/mdstat
cat /proc/mdstat
sudo mke2fs -t ext4 /dev/md0
blkid
cat /etc/fstab
sudo mount /dev/md0 mnt/raid1
sudo mount /dev/md0 /mnt/raid1
sudo mount -a
df
sudo mount /dev/md0 /mnt/raid1
sudo mkfs.ext4 /dev/md0
sudo shutdown -r now
mdadm --examine
lsblk -f
sudo shutdown now

THE END

:

1 Like