"Give the Israelites the following laws:
If you buy a Hebrew slave, he shall serve you for six years. In the seventh year he is to be set free without having to pay anything. 1
References for Exodus 21:2
21.2-6 Lv 25.39-46.
If he was unmarried when he became your slave, he is not to take a wife with him when he leaves; but if he was married when he became your slave, he may take his wife with him.
If his master gave him a wife and she bore him sons or daughters, the woman and her children belong to the master, and the man is to leave by himself.
But if the slave declares that he loves his master, his wife, and his children and does not want to be set free,
then his master shall take him to the place of worship. There he is to make him stand against the door or the doorpost and put a hole through his ear. Then he will be his slave for life.