24 cubes, each 8 cubic inches, meaning each 2 inches on a side. So the dimensions must be even to fit cubes exactly. Our box with 9 inches is really only effectively 8 inches because that extra inch doesn't help us fit another cube.
So our total volume:
[tex]24 \times 8 = (8)(4)h[/tex]
[tex]h=6[/tex] inches minimum