McInerney was 14 when he shot his 15-year-old classmate Larry King twice in the head as he sat at a computer in E.O. Green Junior High School in Oxnard.
The 17-year-old now admits the murder charge, voluntary manslaughter, and the use of a firearm under a plea.
This follows a mistrial earlier in the year, where McInerney was tried as an adult, five jurors voted to convict him of murder while seven voted manslaughter.
The California district attorney’s office has said he will serve 11 years for voluntary manslaughter and 10 years for use of a firearm, but will not serve time for murder.
McInerney’s lawyer did not deny that his client committed the crime, and shot Larry King in the back of the head and once more as he lay on the floor, but he said his client was at emotional breaking point over unwanted sexual advances.
Larry King’s father, Greg King said he understood the plea deal.
Talking to KABC-TV Mr King said: “I don’t think that 21-year sentence is justice for my son, but I understand the reality that was facing the DA, of trying to convict a defendant who was 14 when he committed the murder.”
The prosecutor’s office said: “He will serve the entire 21 years without time off for good behaviour and will not receive time off his sentence for the three years and nine months he has spent in juvenile hall before sentencing.”
This means he will serve 25 years in total, the sentence will be handed down on December 19.