Young Buck won't be a free man much longer -- TMZ has learned the rapper has agreed to serve 18 months in prison for gun possession, following a massive IRS raid on his Nashville home in 2010.
According to the deal, Buck agreed to plead guilty to possessing firearms and ammunition as a convicted felon.
According to legal docs filed in the case, federal agents recovered the firearms in Buck's house during a 2010 raid -- when feds busted into the house to repossess a bunch of the rapper's belongings to settle a $300,000 tax debt.
According to the docs, feds found a .40 caliber Glock 22 in Buck's home along with ammunition. As a convicted felon, Buck is prohibited from possessing ANY kinds of firearms.
As for the felony rap -- Buck was convicted of assault with a deadly weapon after stabbing some guy at the Vibe Awards in 2004.
The judge signed off on the plea deal already but won't formally sentence the rapper 'til July 13th.