New hard drive setup

So about a month ago my hard drive stopped working for my xbox one s; so I went and bought a new one and I need help setting it up. It is a Toshiba 1 tb hard drive for my xbox one s. I just need help reinstalling the osu and other programs. cause i tried everything when it offline updates it gets to the second part of 3 then it normally restarts like it would but when it turns back on it has a e100 code that i cant get rid of.