OPINION OF THE COURT
SLOVITER, Circuit Judge.Before us is the appeal of Robert Burke from the decision of the District Court denying Burke’s petition for a writ of habeas corpus pursuant to 28 U.S.C. § 2241. Burke, a federal prisoner serving a life sentence, claims in his habeas petition that he was unfairly retaliated against by prison authorities for exercising his First Amendment rights. Specifically, Burke claims that he was sanctioned to fifteen days in disciplinary segregation and ultimately transferred from Lewisburg, Pennsylvania to a prison facility in South Carolina for making disparaging remarks about his prison unit manager in a letter to a friend outside the prison. He sought a transfer back to Lewisburg or to another prison within 100 miles of Philadelphia in order to be closer to his family members. A Magistrate Judge (“MJ”) issued a report finding that Burke failed to establish that the transfer was retaliatory in nature, and recommending dismissal of Burke’s petition. The District Court subsequently adopted the MJ’s report. Burke timely appealed.1
*275I.
Background
In the summer of 2000, while Burke was serving his sentence at the United States Penitentiary (“USP”) in Lewisburg, Pennsylvania, he wrote a letter to a non-prisoner friend that referred to his prison unit manager, Anthony Alexander, as a “little cunt” and one who “sucks dick in the worst way.” App. at 44. Burke had allegedly witnessed Alexander making inappropriate sexual overtures to a female prison staff member. Prison officials screened Burke’s letter, discovered the remarks, and issued an incident report charging Burke with “Insolence Towards a Staff Member.” App. at 41.
A Disciplinary Hearing Officer (“DHO”) held a hearing on July 11, 2000. During the hearing, Burke claimed that the incident report was issued in retaliation for having previously seen the unit manager in a compromising situation with another staff member. The DHO, however, found that Burke did commit the act charged in the report, and that “[t]here was no evidence to support the inmate’s allegation that the incident report was the product of retaliation on the part of the Unit Manager.” App. at 96. He therefore sanctioned Burke to fifteen days in disciplinary segregation as well as a change in living quarters. He also wrote a memorandum to Donald Romine, the warden at USP Lewisburg, recommending that Burke be considered for transfer from Lewisburg because “it is readily apparent that Burke is attempting to provoke his Unit Manager .... by first being insolent toward him [and] making allegations of inappropriate conduct ... and then by requesting his presence at a DHO hearing....” App. at 98.
On August 7, 2000, Burke appealed the DHO decision to the Federal Bureau of Prisons, Northeast Regional Office, arguing that the sanctions violated his First Amendment rights. After that office denied the appeal, Burke appealed the DHO decision to the Central Office of the Bureau of Prisons on November 14, 2000. During that period, Burke was informed that one of his sanctions-a change in living quarters-was changed to an administrative transfer to another institution outside the northeast region. Burke was concerned that the transfer would preclude future visits from his wife, two minor children, and elderly mother, and believed that the “transfer was approved and initiated solely for reasons of retaliation” for having witnessed the unit manager’s inappropriate behavior. App. at 46. Additionally, while Burke’s original fifteen-day disciplinary segregation period had expired, he was kept in administrative segregation for a total of 7 months by the prison authorities during his appeals. In a response dated January 11, 2001, the Central Office granted Burke’s appeal and expunged the incident report and sanctions from Burke’s record, but did not address the pending administrative transfer. On March 12, 2001, Burke was transferred from USP Lewisburg to a federal correctional facility in Edgefield, South Carolina.
Prior to the Central Office’s decision, Burke filed a habeas petition pro se in the United States District Court, alleging violation of his First Amendment rights as well as his Due Process right “to be in the general population and to be free from the imposition of arbitrary, capricious and whimsical action all imposed because ... a Unit Manager [ ] does not approve of what I think about him.” App. at 6-7. In response, Romine argued that Burke’s placement in administrative detention and transfer to Edgefield were “directly related to a legitimate penological interest.” App. at 93. Specifically, “[t]he transfer was recommended, not exclusively on the *276basis of the content of the letter ... but rather based on staffs perception that Burke would continue to attempt to provoke his Unit Manager and attempt to manipulate him using information which the inmate thought was of some value.” App. at 93.
On May 7, 2001, the MJ issued a report recommending that Burke’s petition be dismissed. The MJ analyzed Burke’s petition using the three-part test set forth in Rauser v. Horn, 241 F.3d 330 (3d Cir. 2001):(1) whether the prisoner-plaintiff proved that the conduct which led to the alleged retaliation was constitutionally protected, (2) whether the prisoner showed that he suffered some adverse action at the hands of the prison officials, and (3) whether the prisoner showed that his constitutionally protected activity was a “substantial or motivating factor” in the decision to discipline him. Id. at 333. Once the prisoner “demonstrates that his exercise of a constitutional right was a substantial or motivating factor in the challenged decision, the prison officials may still prevail by proving that they would have made the same decision absent the protected conduct for reasons reasonably related to a legitimate penological interest.” Id. at 334. The MJ concluded that Burke failed to “sufficiently allege a link between his Constitutional right to free speech and his transfer.” App. at 12. Moreover, even had Burke established such link, “[Burke’s] own pleadings demonstrate hostility and animosity towards his unit manager,” and “[s]ueh a bad relationship between an inmate and a staff member certainly establishes a legitimate penological interest supporting the transfer.” App. at 13.
Although Burke filed objections to the MJ’s report and recommendation, the District Court adopted the report and recommendation and denied Burke’s habeas petition. The Court found that “there exists sufficient evidence of a hostile relationship between [Burke] and his Unit Manager at Lewisburg, which poses a threat to prison safety and justifies such transfer.” Therefore the transfer “was entirely proper, within the discretion of prison officials, and will be given broad deference.” App. at 19. Burke timely appealed.2
II.
Discussion
Burke’s habeas petition makes two arguments: (1) the District Court’s use of material outside of Burke’s habeas petition in its decision violated Fed.R.Civ.P. 12(b), and (2) dismissal was improper because there was a genuine issue of material fact with respect to the causation prong of the Rauser analysis.
A.
The essence of Burke’s Rule 12(b) challenge is that the MJ (and the District Court) improperly transformed a motion to dismiss into a motion for summary judgment without having followed the formal conversion procedure set forth in Rule 12(b). Specifically, the MJ failed to provide notice of the conversion to the parties and an opportunity to present all materials relevant to a summary judgment motion. The MJ then improperly relied on materials outside of Burke’s petition-a declaration made by the DHO-in dismissing the case.
We reject Burke’s procedural argument. The MJ’s ruling recommending dismissal *277was based on Romine’s supplemental response to the Order to Show Cause, in which he argued that Burke’s petition should be dismissed. The MJ only found that Burke did not sufficiently allege a link between the disciplinary actions and the alleged retaliatory motives on the part of prison officials, and that the prison officials had legitimate peneological reasons for transferring Burke. The matter was properly decided by dismissal.
B.
The legal issue before us regarding the propriety of the transfer is controlled by Supreme Court precedent. In Meachum v. Fano, 427 U.S. 215, 216, 96 S.Ct. 2532, 49 L.Ed.2d 451 (1976), the Court rejected prisoners’ claim that their transfer from one prison to others that had substantially less favorable prison conditions violated their rights to due process because they had not been given notice or an adequate hearing. The Court stated, “The Constitution does not require that the State have more than one prison for convicted felons; nor does it guarantee that the convicted prisoner will be placed in any particular prison if, as is likely, the State has more than one correctional institution. The initial decision to assign the convict to a particular institution is not subject to audit under the Due Process Clause, although the degree of confinement in one prison may be quite different from that in another. The conviction has sufficiently extinguished the defendant’s liberty interest to empower the State to confine him in any of its prisons.” Id. at 224, 96 S.Ct. 2532 (emphasis in original). The Court further stated that “[wjhatever expectation the prisoner may have in remaining at a particular’ prison so long as he behaves himself, it is too ephemeral and insubstantial to trigger procedural due process protections as long as prison officials have discretion to transfer him for whatever reason or for no reason at all.” Id. at 228, 96 S.Ct. 2532; see also Montanye v. Haymes, 427 U.S. 236, 96 S.Ct. 2543, 49 L.Ed.2d 466 (1976).
Meachum and Montanye involved intrastate transfers. In Olim v. Wakinekona, 461 U.S. 238, 103 S.Ct. 1741, 75 L.Ed.2d 813 (1983), the Supreme Court applied the same reasoning to a prisoner who complained of a transfer from a Hawaii prison to a California prison. The Court stated, “Just as an inmate has no justifiable expectation that he will be incarcerated in any particular prison within a State, he has no justifiable expectation that he will be incarcerated in any particular State.” Id. at 245, 103 S.Ct. 1741.
There is no reason to apply a different rule to the transfer of a prisoner from one location to another within the federal system. Although we sympathize with Burke’s desire to be imprisoned where he can remain in contact with his family, the transfer of a prisoner for reasons related to a legitimate penological interest is a matter within the discretion of the prison authorities. Burke has no constitutional basis on which to ground his lawsuit.
III.
Conclusion
For the reasons set forth we will affirm the order of the District Court dismissing Burke’s petition for a writ of habeas corpus.
. Burke's counsel, Philip Irwin, is appealing in this case pro bono and we express our appreciation to him and his law firm.
. The District Court had jurisdiction under 28 U.S.C. § 1331, 2241. We have jurisdiction under 28 U.S.C. § 1291, 2253.