"to scrape, rub," late 14c. (implied in grated), from Old French grater "to scrape, scratch (out or off); erase; destroy, pull down" (Modern French gratter), from Frankish *kratton, from Proto-Germanic *krattojan (source also of Old High German krazzon "to scratch, scrape," German kratzen "to scratch," Swedish kratta, Danish kratte "to rake, scrape"), probably of imitative origin. Senses of "sound harshly," and "annoy" are mid-16c. Italian grattare also is from Germanic. Related: Grated; grating.
late 14c., "grill for cooking;" early 15c., "iron bars or cagework across a door or window," from Anglo-Latin (mid-14c.), from Old French grate or directly from Medieval Latin grata "a grating, lattice," from Latin cratis "wickerwork, hurdle" (see hurdle (n.)). As a verb meaning "to fit with a grate," from mid-15c. Related: Grated; grating.
<a href="https://www.etymonline.com/word/grating">Etymology of grating by etymonline</a>
Harper, D. (n.d.). Etymology of grating. Online Etymology Dictionary. Retrieved $(datetime), from https://www.etymonline.com/word/grating