40 HDD is a lot.
Check out 45 Drives. They have a homelab focused offering that has 15 bays https://45homelab.com/#product
To get 40 hard drives, you’d be looking at something like their Storinator S45 https://www.45drives.com/products/storinator-s45-configurations.php