Skip to content

Instantly share code, notes, and snippets.

@hitorilabs
Last active July 12, 2024 17:03
Show Gist options
  • Save hitorilabs/dff5328a447450d649da0ee55d5228d4 to your computer and use it in GitHub Desktop.
Save hitorilabs/dff5328a447450d649da0ee55d5228d4 to your computer and use it in GitHub Desktop.

Notes on installing M.2 PCIe Expansion Card

  1. boot into BIOS
  2. change PCIe link width configuration to x4x4x4x4
  3. partition drives
  4. create and start raid0 array
  5. make configuration persistent between reboots
  6. double check before committing too much data into the array

Wipe any existing partitions

Wipe all partitions from the drives and create new ones

sudo gdisk

Create RAID0 configuration

Example for initial creation of a raid0 array (really you should have a 4 slot adapter here for a PCIe x16 slot)

sudo mdadm --create --verbose --level=0 --raid-devices=4 /dev/md0 /dev/nvme0n1p1 /dev/nvme1n1p1 /dev/nvme2n1p1 /dev/nvme3n1p1
sudo mkfs.ext4 -m 0 -E lazy_itable_init=0,lazy_journal_init=0 /dev/md0
sudo mkdir /mnt/md0 
sudo mount /dev/md0 /mnt/md0

/etc/fstab - you can pretty safely do this and it won't change

...
/dev/md0 /mnt/md0 ext4 defaults,nofail,discard 0 0

Persistence

Note: ORDER MATTERS... (check that there aren't duplicate array definitions - don't specify verbose, it only caused issues)

sudo mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.conf

(may or may not be necessary)

sudo update-initramfs -u

Recovering a raid array that wasn't persisted, you can run the same command (seems wrong but it worked)

sudo mdadm --create --verbose --level=0 --raid-devices=4 /dev/md0 /dev/nvme0n1p1 /dev/nvme1n1p1 /dev/nvme2n1p1 /dev/nvme3n1p1

https://www.jeffgeerling.com/blog/2021/htgwa-create-raid-array-linux-mdadm


No idea why it's not autoassembling, but I can just do sudo mdadm --assemble /dev/md0 by name and then mount it to /mnt/md0

EDIT: skill issue - i tee'd the config before mounting sudo mount /dev/md0 /mnt/md0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment