Booting from raid-1 on USB-attached SSDs as / (root) disables TRIM support

Open
#5,259 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
c, linux

Research direction

Start by reproducing the issue with the provided lsblk -D output, comparing boot from the SD card with boot from the RAID root. Trace how RAID is assembled in the initramfs and how discard/TRIM capability is propagated; done means the RAID exposes the SSDs' supported TRIM capability when used as the root device.

Written by the indexing model from the issue text.

Description

Describe the bug

TRIM support is disabled if system boots from a raid-1 based on USB-attached SSDs. /boot is still on a SD-card. RAID is build on RAW, unpartitioned disks as you can see from the device name md127p1.

When I boot from a SD-card normally, and attach both SSDs via USB TRIM is working, after also providing the unmap udev rule.
The same is true when these SSDs are attached before booting from the SD-card.
But when I boot from the RAID(1), lsblk -D shows following output where you can see that the SSDs actually support TRIM but the RAID does not:

lsblk -D
NAME        DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
sda                0      512B       4G         0
└─md127            0        0B       0B         0
  └─md127p1        0        0B       0B         0
sdb                0      512B       4G         0
└─md127            0        0B       0B         0
  └─md127p1        0        0B       0B         0
mmcblk0            0        4M     584M         0
└─mmcblk0p1  3145728        4M     584M         0
zram0              0        4K       2T         0
/dev/md127p1   246059232 32765012 203262700   14% /
/dev/mmcblk0p1    468456    57224    411232   13% /boot

It seems to me that the RAID-support backed into initramfs on my /boot-only-SD-card does something different than if the RAID is assembled later during the booting from a normal SD-Card.

Issue happens on any RPI I tested on, including RPI3+ and RPI400

Steps to reproduce the behaviour

see above.

Device (s)

Raspberry Pi 3 Mod. B+

System

vcgencmd version
Oct 11 2022 17:50:10
Copyright (c) 2012 Broadcom
version 5da7b38ef2434a6d18a3f6054ba239f1e4a52594 (clean) (release) (start)

uname -a
Linux homeserver 5.15.78-1-MANJARO-ARM-RPI #1 SMP PREEMPT Sat Nov 12 17:13:38 UTC 2022 aarch64 GNU/Linux

Logs

No response

Additional context

No response

Dominant language
C
Stars
13.2k
Forks
5.5k
Avg merge
2d 18h
Merged PRs (30d)
22

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from raspberrypi/linux

All issues in raspberrypi/linux

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.