In the enforcement of a lien in the circuit court upon premises, including the homestead, if such right is not waived or released, as provided in Part 9 of Article XII of this Act, the court may set off the homestead and order the sale of the balance of the premises, or, if the value of the premises exceeds the exemption, and the premises cannot be divided, the court may order the sale of the whole and the payment of the amount of the exemption to the person entitled thereto.
735 ILCS 5/12-908