6. Xiao Ming divided a cube with an edge length of 4 into 29 smaller cubes with integer edge lengths. Then the number of smaller cubes with an edge length of 1 is ( ).
(A) 22
(B) 23
(C) 24
(D) 25
6. C.

If a cube with an edge length of 3 is separated out, then there can only be 1 cube with an edge length of 3, and the remaining ones are all cubes with an edge length of 1, totaling 37, which does not meet the requirement.

Let the number of cubes with an edge length of 2 be $x$, and the number of cubes with an edge length of 1 be $y$. Then
$$
\left\{\begin{array} { l } 
{ x + y = 2 9 , } \\
{ 8 x + y = 6 4 }
\end{array} \Rightarrow \left\{\begin{array}{l}
x=5, \\
y=24 .
\end{array}\right.\right.
$$