The petitioner, Robert E. Stewart, appeals from the order of a single justice of this court denying his petition for a writ of habeas corpus. We affirm.
The procedural history of this case is long and repetitive. On November 18, 1974, the petitioner was convicted by a Superior Court jury on indictments for armed assault in a dwelling house (G. L. c. 265, § 18A [1990 ed.]) and murder in the second degree (G. L. c. 265, § 1 [1990 ed.]).1 The trial judge sentenced him to two consecutive life terms in prison, to run from and after the completion of a prison term which he was serving in New Hampshire. In Commonwealth v. Stewart, 375 Mass. 380, 392-393 (1978), we held that “the conviction of armed assault in a dwelling house did not re*567quire proof of any facts different from those necessary to prove the murder charge based on the commission of the felony.” Therefore, under the same evidence rule, see Morey v. Commonwealth, 108 Mass. 433, 434 (1871), the sentences could not run consecutively. Commonwealth v. Stewart, supra at 393. We affirmed the conviction of murder in the second degree, vacated the sentence on the armed assault charge, and ordered that a new sentencing hearing be held. Id. at 393-394.
On remand, a Superior Court judge, acting pursuant to our rescript, resentenced the petitioner on the armed assault charge to a life term running concurrently with the murder sentence. Apparently not realizing that the murder sentence would commence from and after the completion of the petitioner’s New Hampshire prison term, the judge (not the trial judge) ruled that the assault sentence would run from the original date of conviction, November 18, 1974. When the petitioner was released from the New Hampshire prison on November 23, 1979, and began serving his murder sentence, the armed assault sentence had been running for approximately five years.
Following the resentencing, in November, 1978, the petitioner mounted several attacks on his convictions. First, the petitioner moved for a new trial under Mass. R. Crim. P. 30 (b), 378 Mass. 900 (1979), citing evidence that the government’s chief witness had given false testimony. A Superior Court judge denied the motion, and we affirmed the denial. Commonwealth v. Stewart, 383 Mass. 253, 254 (1981).2 Later, the petitioner sought a declaration that his murder sentence ran from November 18, 1974, the date on which the assault sentence began. A Superior Court judge ruled that both sentences ran from 1979, not 1974, but the Appeals Court reversed this ruling and left the sentences as they were, with the assault sentence commencing in 1974 and the *568murder sentence commencing in 1979. Stewart v. Commissioner of Correction, 16 Mass. App. Ct. 57 (1983). The petitioner did not seek further appellate review of this decision. He then filed a petition for a writ of habeas corpus in the Superior Court, seeking again a change in the structure of his sentence. The Superior Court judge treated the petition as a motion for declaratory judgment, see Nelson v. Commissioner of Correction, 390 Mass. 379, 386-387 (1983), and denied the motion. In an unpublished memorandum and order under Appeals Court Rule 1:28, the Appeals Court affirmed. Stewart v. Superintendent, Southeastern Correctional Center, 24 Mass. App. Ct. 1113 (1987). We denied further appellate review. 401 Mass. 1102 (1987).
On November 17, 1989, the petitioner was denied parole on the armed assault conviction. He sought habeas corpus relief in the Superior Court on October 23, 1990, challenging his dual convictions and his sentence structure. A judge in the Superior Court denied the petition on December 18, 1990, and the petitioner appealed from this decision to the Appeals Court. The petitioner filed a nearly identical petition for habeas corpus relief with the Supreme Judicial Court for the county of Suffolk on March 25, 1991. A single justice denied the petition the same day. The petitioner appeals from the order of the single justice to the full court, and it is this order that we now review.
Although the petitioner characterizes his request as a petition for a writ of habeas corpus, he seeks relief obtainable by a motion under Mass. R. Crim. P. 30 (a), 378 Mass. 900 (1979). Rule 30 encompasses all motions for postconviction relief that challenge “the sentence, conviction, or confinement imposed.” See Averett, petitioner, 404 Mass. 28, 31 (1989). By contrast, a petition for a writ of habeas corpus may be brought by an individual who contends that “the term of a lawfully imposed sentence has expired,” see id., and who bases his arguments on “grounds distinct from the issues at the indictment, trial, conviction, or sentencing stage,” see id. at 30. The petitioner in this case attacks the legality of his dual convictions and the structure of his *569sentences. Since it appears, on the record before us, that even if the petitioner were to persuade us of the substantive merit of his claims, he would not be entitled to immediate release, a petition for habeas corpus relief does not lie. G. L. c. 248, § 1 (1990 ed.). See Nelson, supra at 386 (“A petition for a writ of habeas corpus is appropriate where the petitioner alleges that he is entitled to immediate release”). He must proceed under rule 30.3
A rule 30 “remedy lies not with a single justice of this court but with the trial judge.” McCastle, petitioner, 401 Mass. 105, 106 (1987). See Mass. R. Crim. P. 30 (a). The petitioner may not bring his rule 30 motion directly to this court, but rather must file it in the Superior Court.4 Indeed, he did file a nearly identical rule 30 motion with the Superior Court on October 23, 1990. His proper course now is to pursue his appeal from the denial of that motion in the Appeals Court.5 See Mass. R. Crim. P. 30 (c) (8), 378 Mass. 900 (1979).
We affirm the order of the single justice denying the petition.
So ordered.
The murder charge went to the jury on a felony-murder theory.
The petitioner sought Federal habeas corpus relief, pursuant to 28 U.S.C. § 2254 (1988), on the same theory. The petition was denied. Stewart v. Amaral, 626 F. Supp. 192 (D. Mass. 1985).
“[T]here is no constitutional impediment to restricting [the petitioner] to rule 30 relief.” McCastle, petitioner, 401 Mass. 105, 107 (1987).
Since the trial judge from the petitioner’s original case has retired, another Superior Court judge would have to hear the case. See Commonwealth v. Sullivan, 385 Mass. 497, 498 n.l (1982).
The petitioner was convicted of murder in the second degree, and therefore he is not required by G. L. c. 278, § 33E (1990 ed.), to seek leave from a single justice of this court before appealing from the denial of his rule 30 motion. See Commonwealth v. Adrey, 397 Mass. 751, 752 (1986).