After you’ve drilled the lag bolts into the stud, drill holes where they’ll hit the back of the shelf with a 3/8-inch drill bit.