Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

The HDD I have my Ubuntu installed is about to fail. I would rather not lose 3 years worth of data, customisation and apps. I am looking for a way to move the complete system (SWAP included, because I'm not sure if I can relink the system to a new SWAP partition) to another HDD. But not the complete HDD< only the partition containing Ubuntu, to a partition on a different HDD. Basically I'd like to do what I've been able to do with Norton Ghost for my Windows install. I thought about using Clonezilla but I think I would have issues with GRUB (Especially trying to boot from a different UUID than what is in the conf file). do you know of any way this could be done?

PS, my home directory is encrypted but that's not really an issue, because I can work around that.

EDIT: changed the explanation to make it clearer

share|improve this question

4 Answers 4

up vote 12 down vote accepted

I actually ended up using Gparted from the Live CD. I copied the partition and pasted it in the unallocated space on the other HDD. Then I used blkid to check the UUIDs and edited the fstab file. Worked like a charm!

share|improve this answer

You can do it by using dd. For complete info check the site.

Clone a Hard Drive Using an Ubuntu Live CD

Warning dd is a very powerful low-level tool and even one little typo is sufficient to wipe out an entire disk. Please be very careful with its use and try to use a higher-level tool if at all possible.
Note also that this method only works if your target disk is the same size or larger


Cloning hard drives is a common maintenance task. Don’t bother burning a new boot CD or paying for new software – you can do it easily with your Ubuntu Live CD.

Not only can you do this with your Ubuntu Live CD, you can do it right out of the box – no additional software needed! The program we’ll use is called dd, and it’s included with pretty much all Linux distributions. dd is a utility used to do low-level copying – rather than working with files, it works directly on the raw data on a storage device.

You can also use:

Clonezilla, a free hard drive cloning software. Clonezilla runs from a live CD, and features a simple user interface. You’ll still need to be aware of what you’re doing, of course, but this tool can simplify your job immensely with its step-by-step breakdown.

You can download Clonezilla here

Warning Make sure that you check out the Limitation of Clonzilla before you start.

You also mentioned that you have used Ghost for windows, well you can use Ghost for Linux as well.

Source: http://www.howtogeek.com/howto/19141/clone-a-hard-drive-using-an-ubuntu-live-cd/

Source: http://www.makeuseof.com/tag/2-methods-to-clone-your-linux-hard-drive/

share|improve this answer
    
Does dd also allow for partitions only to be copied? As in sudo dd of=/dev/sdb3 of=/dev/sda2 –  boywithaxe Jun 15 '12 at 8:18
    
Providing both drive are the same exact size. And the command is in your case dd if=/dev/sd3 of=/dev/sd2 –  Mitch Jun 15 '12 at 8:29
    
Thanks, however the partitions are on two different physical drives, /dev/sda and /dev/sdb. Wouldn't Using sd3 and sd2 as descriptors copy within one physical drive? –  boywithaxe Jun 15 '12 at 8:34
    
the drives do not need to be the same size, the only requirement is that the drive you are copying the information to is bigger than the drive being copied. –  Bruno Pereira Jun 15 '12 at 8:49
1  
ddrescue would be a better option here since the hard disk is faulty. –  Ciro Santilli Apr 27 at 7:15

Some years ago I used successfully this tool to "clone" my partitions: G4L. Everything worked with some post-installation corrections, such as resizing partitions (I cloned the partitions on different size HD) and grub reinstall (it's pretty simple, you only need a live CD to reinstall it in the MBR).

You can safely ignore your swap partition (you will be able to recreat it at a second time) or clone it too and active it later, manually editing /etc/fstab or from command line.

In the past weeks I did again the clone with clonezilla, and everything went ok with the same post-cloning corrections. So don't worry and give them a try, nothing on your original HD will be touched!

EDIT:

I found an old mail where I described the first cloning process. I acted as follow:

  • Partitioned my new HD connected via USB exactly as the old one
  • Cloned the partitions in raw mode with G4L
  • Booted with a Live CD and did the resize of partitions with resize2fs
  • Disconnected the HD from USB and mounted on SATA/PATA.
  • Booted again with the Live CD and mounted the new disk:

mkdir disk

mount /dev/sda1 disk (where sda1 contains boot and root partitions)

mount /dev/sda2 disk/boot (if you have a different boot partition)

mount --bind /dev/ disk/dev/

mount -t proc none disk/proc

chroot disk /bin/bash

grub-install /dev/sda (to install GRUB on sda MBR)

  • Restart, check the swap
  • Enjoy
share|improve this answer

Well, I just used usb stick + ubuntu live.

I was transferring ubuntu 13.10 from larger hdd to a smaller ssd, and clonezilla "said" that it can't be done this way since target partition is smaller than the source partition.

So I started ubuntu live, mounted both hdd's (new disk, was partitioned earlier of course, don't forget about swap ;) ), and just:

cd /media/ubuntu/old-hdd-uuid/

then:

sudo cp -R --preserve=all bin/ boot/ cdrom/ dev/ etc/ home/ lib/ lib32/ lib64/ media/ mnt/ opt/ proc/ root/ run/ sbin/ srv/ sys/ tmp/ usr/ var/ /media/ubuntu/new-hdd-uuid/

above you can see that it's just copying all directories from one hdd to another, recursively with all permissions and stuff preserved.

cd /media/ubuntu/new-hdd-uuid/

then I had to make two symlinks in root directory of a new disk:

sudo ln -s boot/vmlinuz-x.xx.x-xx-generic vmlinuz
sudo ln -s boot/initrd.img-x.xx.x-xx-generic initrd.img

and the next step was installing grub, so:

sudo grub-install --boot-directory=boot/ /dev/sdxy

where x - device, y - partition number (if unsure use cfdisk or fdisk to print partition table...)

and the last step was, changing uuid of a new hdd to uuid from old hdd (it's the easiest way to fool grub config, fstab or else without searching and fixing configurations)

sudo tune2fs /dev/sdxy -U OLD-UUID

new UUID will show after device remounting. So now reboot and if everything is ok, your ubuntu should start...

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.