Instructions
Power on the console with only the USB flash drive connected. Wait for the Dashboard to load then press the center "Xbox Guide" button on the controller. Press "X" to sign out of your Gamertag profile. Turn off the console.
Remove the USB flash drive and attach your Xbox 360 hard drive to the side of the console. Power on the Xbox 360 and wait for the Dashboard to load. Press the center Xbox Guide button again then scroll down using the analog stick and select "Recover Gamertag" by pressing the "A" button.
Follow the steps on the Recover Gamertag screen (you will be asked to input your Gamertag credentials including your email address associated with the profile and the password). Press "A" to recover the Gamertag and wait for the console to download it from Microsoft's Xbox Live servers. Restart the console when the download is complete and your Gamertag will be accessible from your Xbox 360.