5. If real numbers $x, y$ satisfy the equation $x y - x - y = 1$, then the minimum value of $x^{2} + y^{2}$ is ( ).
(A) $3 - 2 \sqrt{2}$
(B) $6 - 4 \sqrt{2}$
(C) 1
(D) $6 + 4 \sqrt{2}$
5. B.

Let $x+y=t$.
Then from the given, we have $xy=x+y+1=t+1$.
Thus, $x, y$ are the two real roots of the quadratic equation in $m$
$$
m^{2}-tm+t+1=0
$$

Therefore, $\Delta=t^{2}-4(t+1) \geqslant 0$
$$
\Rightarrow t \geqslant 2+2 \sqrt{2} \text{ or } t \leqslant 2-2 \sqrt{2}.
$$
Also, $x^{2}+y^{2}=(x+y)^{2}-2xy$
$$
=t^{2}-2(t+1)=(t-1)^{2}-3,
$$

Thus, when $t=2-2 \sqrt{2}$, i.e., $x=y=1-\sqrt{2}$, $x^{2}+y^{2}$ achieves its minimum value of $6-4 \sqrt{2}$.