Sunday, November 17, 2013

Transfer Ubuntu OS installation to a larger Hard Drive (2TB or smaller)

Skip to "Let the tutorial begin" if you don't want to read any back story.

First I'd like to say sorry to those that follow this Blog, I have not posted in a very long time. I've been really hip deep in my YouTube Channel and gaming (both in Linux and on Xbox 360) so I haven't had much to blog about in terms of technology goes. I am hoping to get a post up about SteamOS and other technology related stuff very soon but let's start with this post for now.

I was debating what to title this post exactly since theoretically it could be used to transfer other Linux distributions as well and heck, it may even work to transfer a Windows OS or even OS X installation to another hard drive but I figured I would only cover exactly what I did since I know it works. This post will go over the steps I took in order to successfully change from a small IDE 40GB hard drive to a larger SATA 160GB hard drive AND at the same time changing ALL my computer hardware as well.

A little backstory first. I built my 4th computer in 2007 and believe it or not I have been using that ever since. With my recent YouTube adventures and getting into more PC gaming the computer started to really show it's age as I couldn't play certain games and rendering videos for YouTube took forever and a day. So I finally decided I needed to upgrade everything. I was planning on saving my money for Black Friday or Cyber Monday but a deal for a used computer sprang up out of no where and for a really good price I might add. For a mere $200 I could get a completely new tower. The main specs of the tower are as follows:

Sentey Modtower case with 7 fans
AsRock Extreme6 FM1
AMD A8-3870k 3.00Ghz
G-Skill Sniper 2133Mhz DDR3 RAM (2x4GB totalling 8GB)
XFX HD5750 1GB DDR5
OCZ Synapse Cache SSD 64GB
400w PSU that powers the motherboard and GPU
380w PSU that powers everything else

My current Xubuntu 12.04.3 was currently on a 40GB IDE hard drive and since the new motherboard didn't have any IDE's ports I would need to figure out what to do to transfer my operating installation to my new used hardware. I found a 160GB SATA hard drive in another computer of mine, moved all the data of it onto my Western Digital My Book World Edition (a NAS basically) and I was ready to move my Xubuntu installation from the small 40GB drive to the larger 160GB drive.

Let the tutorial begin
Things needed
-A computer to create the live usb sticks
-You'll need a minimum of (2) 1GB flash drives (to run live usb versions of clonezilla and linux-secure-remix from) OR an optical disc such as cd-rom or a dvd....assuming your computer has an optical drive. You could use the same 1GB stick for both clonezilla and linux-secure-remix BUT it will take more time since you have to use linux-secure-remix in between using clonezilla.
-A storage location large enough to backup the images of your partitions (network storage OR local external hard drive)
-Clonezilla (I choose amd64 because the computer I was running the live usb stick from had a 64bit chip. If you aren't sure it's ok to choose the i686pae version)
-Linux-Secure-Remix (choose linux-secure-13.04-64bit if the OS you're moving is a 64bit OS or choose linux-secure-13.04-32bit if the OS you're moving is a 32bit OS)

Alright, so I trust you downloaded the software you'll be using from above and we're ready to get going.

Step 1 (install new hard drive)
Install your new hard drive (this is the hard drive you're transferring your currently installed Operating System TO) into the computer which will be your final computer hardware you're going to settle with. In my case it was a completely different computer tower BUT your may only be transferring your OS to a new hard drive and not changing any hardware so you would install the hard drive into your current computer that you want the larger drive in.

Step 2 (live clonezilla media creation)
Using your current computer operating system, we'll use it to create the live usb or livecd of clonezilla. Clonezilla has some tips for creating it HERE. You can not simply copy the clonezilla ISO to a usb stick or to a cd-rom as data, that won't work. You need to use software that writes the ISO to the usb stick or the optical media as well as making the usb stick or optical media bootable. Meaning, the computer BIOS sees it as a bootable device and the computer boots the usb stick or optical media versus the internal hard drive that's in the computer you're using. Once your done creating your live media of clonezilla shut down your computer

Step 3 (backup partitions to image files)
If you made a live cd or live dvd, put it in the optical drive and then turn off the computer which contains the hard drive that you want to transfer FROM. If you created a live usb stick, plug it once the computer is off. Turn the computer on and activate a boot menu if you can (it was F11 on mine), this will allow you to choose which device to boot to, in the case of a live cd, choose the correct optical drive. In the case of a live usb stick, choose the applicable usb stick. It should boot into clonezilla, hit enter to choose the defaults, choose the proper language and hit enter, I clicked "don't touch keymap" for the keyboard setting and hit enter. Choose Start Clonezilla, hit enter. Choose the device-image option (first option), hit enter. The next screen is where you choose where you want to backup your images (what they refer to as being /home/partimag) (NOTE: do NOT choose the new hard drive to store your images onto because it's going to be formatted later on), in my case I was using a 200GB external usb hard drive so that option is local_dev, hit enter.  Then choose the folder or directory where the image will be saved to. Click beginner mode as that's the easiest and worked just fine for me. The next screen I choose saveparts option because I had a / partition and a /home partition I need to backup. Then choose the partition you want to create an image of by arrowing onto it and hitting the space bar (it will put an asterisk to signify that's the partition you're backing up), name it appropriately and hit enter.  I can't find any screenshots so I am not certain on the next few steps but it should just be hitting enter and then hitting "y" telling it to perform the backup image creation. After it's done, you have the option of powering off, rebooting, starting over from scratch or starting over keeping the same location for storing another image. I choose to start over fresh just in case. So perform the same steps to backup your next partition but obviously this time choose the next partition you want to backup and when it comes time to name it, ensure you choose a different name because the default name will be the same as your first image backup. Hit "y" a few times and it should now create another image but this time of the newly selected partition you choose to create an image of. I only had 2 partitions so I am done with this step but if you have more partitions than keep creating images of them until you're done. Reboot the computer so it boots to your current operating system that you're using. Pfffff, that was a long step. Sorry about that.

Step 4 (live linux-secure-remix creation)
If you don't have a second flash drive just use the same one you used for clonezilla. You'll use the same steps to write the linux-secure-remix ISO to the usb stick as you used during step 1. Remember, use a method that "burns the ISO image" onto the usb stick and makes it bootable as well.

Step 5 (partition your new drive)
This step you can either boot into your current OS installation OR insert the live media which contains linux-secure-remix on it into the computer that has the new hard drive. In my case I had to boot the live media since this new computer didn't have a hard drive with any OS in it. If using your current OS installation, than use whatever method needed to partition your new hard drive. This step is important in that you need to partition your new drive the same way your old drive is partitioned, not in size, but the partition numbering. NOTE: the new partitions should be larger than what they are now that you're transferring FROM. Primary and logical partitions need to match. I choose to stick with msdos (MBR) style partitioning versus going to the new GPT partitioning scheme which is required for drives larger than 2TB. MBR works for 2TB drives and lower. Sorry this tutorial won't go into switching from MBR to GPT but I have read it can be done without data loss. In my case I had sda1 as my only primary partition, sda2 was an extended partition which contained sda5 and sda6 as logical partitions. I formatted sda1 and sda6 as ext4. If using a livecd or live usb, then boot the computer and enter the BIOS boot menu so you can choose either the livecd or the live usb stick to boot to. Once booted into linux-secure-remix (it's basically Ubuntu 13.04 with some pre-installed applications) you'll want to open the application called Gparted.


NOTE: If you have more than 1 disk within this computer, ensure you're on the correct one. Follow the steps above for partitioning and ensure the partitions are the same as your old drive you're transferring FROM. Now you're done partitioning the new drive and it's ready to accept the images of your partitions that you're transferring. If you made a livecd then put the clonezilla livecd into your optical drive prior to shutting down. You can shut down your computer as it's time to reboot into Clonezilla.

Step 6 (restore backup'd up images onto new hard drive)
If you created a live usb stick, plug it in. Turn the computer on and activate a boot menu if you can (it was F11 on mine), this will allow you to choose which device to boot to, in the case of a live cd, choose the correct optical drive. In the case of a live usb stick, choose the applicable usb stick. If you can't activate a BIOS boot menu, then go into the BIOS and change the boot order to the proper media, whether it's the livecd or the live usb stick. It should boot into clonezilla, hit enter to choose the defaults, choose the proper language and hit enter, I clicked "don't touch keymap" for the keyboard setting and hit enter. Choose Start Clonezilla, hit enter. Choose the device-image option (first option), hit enter. The next screen is where you choose where you stored your images (what they refer to as being /home/partimag), in my case it was the 200GB external usb hard drive so that option is local_dev, hit enter.  Then choose the folder or directory where the images were saved to. Click beginner mode as that's the easiest and worked just fine for me. The next screen I choose the restoreparts option because now we're "restoring a partition" to the new hard drive. Choose the image you want to restore, this will be your first image you created of your first partition, hit enter. Now choose the destination, which should be your first partition on your new hard drive, most likely sda1 if the new hard drive is your only hard drive in the computer. NOTE: ensure you choose the correct hard drive and partition as this will overwrite whatever is there with your backed up image and hit enter. There may be a few more enters or it's asking you a couple times if you're 100% positive that you want to perform this action since it's going to overwrite whatever is on the "target partition" with what's in the image file. Hit "y" if you're sure and off you're running. Once done you have just restored your first partition from your old smaller drive to your new larger drive. Perform the same steps again for anymore partitions that you imaged and then you're done restoring images onto the new hard drive. We're almost DONE. You can attempt to reboot your computer removing the clonezilla live media but I am betting it doesn't boot into your OS, I had a flashing cursor in the upper right corner and that was it. No Xubuntu for me.......YET.

Step 7 (fixing your MBR/boot loader, most likely grub2)
I realized after the fact that if we had chosen advanced options when backing up the partitions to image files and the advanced options when restoring we may not have needed this step but I choose beginner so it is what it is and we need to install grub2 to the MBR so that the BIOS passes on the hardware to a bootloader which will then boot the installed OS. This is done using linux-secure-remix. So put it your linux-secure-remix livecd or livedvd in the optical drive OR plug in your live usb stick and boot the computer to one you created. Once inside linux-secure-remix we need to run the boot-repair application


Choose the recommended repair which is what fixed mine. When it shows you a URL for where it uploaded the boot-repair log file, write it down so in case this doesn't work, you can obtain help from others and point them to the boot-repair log file which will help others figure out why it's not working. You should now reboot your computer removing whatever live media you were using and it should now boot into your Operating System. 

That's it, YOU DID IT! Congrats. I hope this was helpful to someone. Leave me a comment if I missed something somewhere or to say thank you if this helped you.

-Ubu out






Post a Comment