30

I am running an Ubuntu 14.04 LTS and I experienced some issues with my hard drive. I bought a new HDD of the same size (1TB), and I intend to move all my data (softs, work, pics, etc.) on the new HDD.

What is the easiest way to do that?

3
  • 2
    You can copy-paste partitions with gparted from a live CD
    – Panther
    Jun 24 '15 at 6:02
  • Or you could use clonezilla (GPL) clonezilla.org
    – Bruni
    Jun 24 '15 at 6:30
  • 7
    NOTE: Regardless of which method is used to copy, it is much safer to do this on a system (hardware) that has been booted from Live CD/USB media. Copying the live system, while running from that drive AND with a suspect HDD, may cause issues that you may not immediately notice.
    – david6
    Jun 24 '15 at 7:13
17

The easiest way to do this is by using Gparted from Live CD/USB as suggested above. To do this have a look at the "Copying and pasting a partition" section in the Gparted manual. To reproduce the steps given in the link:

To copy a partition:

  1. Select an unmounted partition. See the section called “Selecting a Partition”.

  2. Choose: Partition → Copy. The application marks the partition as the source partition.

To Paste a partition:

  1. Select an unallocated space on a disk device. See the section called “Selecting Unallocated Space”.

  2. Choose: Partition → Paste. The application displays the Paste /path-to-partition dialog.

  3. If you want you can adjust the size and location of the partition. See the section called “Specifying Partition Size and Location”.

  4. If you want you can specify the alignment of partition. See the section called “Specifying Partition Alignment”.

  5. Click Paste. The application displays the copy partition operation in the Pending Operations pane.

7
  • Thank you for helping me with this, but i think i will use a manual simple way as @Frantique suggested below, sudo cat /dev/sda >/dev/sdb i know it's risky, but looks the easiest way to me tho. Jun 24 '15 at 6:49
  • Yes, it is your choice. May be some others will find this method easier :) Be careful with dd (and even cat) as they can mess up things if not used with caution.
    – Ron
    Jun 24 '15 at 8:22
  • 1
    @AdascaliteiLucian don't do the cat (see comment above). If you want to speed up things, use a larger buffer size (64MB or so) with dd
    – Fabby
    Jun 24 '15 at 8:53
  • cat is safer and simpler than dd. There's no reason at all not to use it.
    – terdon
    Jul 2 '19 at 9:55
  • 1
    Gparted: Can someone clarify whether everything in the partitions is fully accessible(permissions of: Directories, files and Veracrypt containers); & if all partitions can be used to recreate the same PC by loading it to bare hardware?
    – CloudE11
    Jan 11 '21 at 0:46
11

Boot from a live system, plug in the new HDD via USB (or another (s)ata cable, depending on your hardware), and start a 'Terminal'.

Check what is the path for your old HDD (probably /dev/sda), and the new one as well (/dev/sdb), and issue this command:

sudo dd if=/dev/sda of=/dev/sdb status=progress

Note that it will take a long time. You can monitor the progress on the terminal.

Another possibility is (even faster than dd):

cat /dev/sda >/dev/sdb
9
  • 1
    I gues this is the method i will choise, to be honest, i preffer the shell thing instead of Gparted thing. Jun 24 '15 at 6:47
  • 1
    Lucian: da, e cea mai buna solutie. ;)
    – Frantique
    Jun 24 '15 at 6:52
  • 5
    using dd with a larger block size will speed it up. e.g. sudo dd if=/dev/sda of=/dev/sdb bs=1024k Jun 24 '15 at 6:59
  • 1
    Buna asta :), nu m-as fi astepat :), oricum tin thread-ul deschis in caz de experientez ceva probleme, Teoretic eu vreau sa inlocuiesc un Hard Wd Blue 1Tb, care deja cred ca i se duc acele de pe platane, cu un Hard Wd Black 1Tb, si nu vreau sa reinstalez toata nebunia iarasi, imi ia o zi sa mi le pun toate la punct, si prefer sa fac treaba asta. Estimativ cred ca mi-ar lua in jur de 4 5 ore sa se copie. Multumesc inca o data. Jun 24 '15 at 7:06
  • 2
    This should work, but note that you are writing every block. If you're in a VM environment and are cloning a sparsely-allocated disk, you're going to copy everything, including the empty space, undermining the benefit of sparse allocation. For this situation, a gparted copy/paste (after shrinking the source to a near-minimum size) will be better. As would a file-based clone to a newly-created partition.
    – David C.
    Mar 22 '18 at 22:37
9

Using CloneZilla (http://clonezilla.org/) will take care of the details.

4
  • 7
    Although your answer is 100% correct, it might also become 100% useless if that link is moved, changed, merged into another one or the main site just disappears... :-( Therefore, please edit your answer, and copy the relevant steps from the link into your answer, thereby guaranteeing your answer for 100% of the lifetime of this site! ;-) You can always leave the link in at the bottom of your answer as a source for your material...
    – Fabby
    Jun 24 '15 at 9:17
  • 3
    Could you expand a little on this? For example outline how you'd use clonezilla to clone a partition...
    – Oli
    Jun 24 '15 at 9:48
  • 5
    Don't be so hard Fabby: Clonezilla exists since long (almost 10 years now I think). If the site is moved, you can always google it. The full manual, and the quick guides are available on the site. What do you want included: the download sites: osdn, sourceforge? Or the github repository? Anyway, when the project becomes so abandoned that the website doesn't work anymore, it is most often better not to use it, unless you read the source.
    – jringoot
    Aug 4 '17 at 6:25
  • 1
    I agree with jringoot. If the link becomes unavailable, the answer is moot anyway. Oct 5 '19 at 13:20
3

I created a bash script to automate this whole cloning process to another disk using rsync in the easiest way possible.

The script takes care of everything like changing fstab file, installing the proper grub in your new disk and updating it to create a new grub menu.

You just have to prepare your target disk with the appropriate partitions using gparted for example.

For more details, please visit its repository at https://github.com/thiggy01/clone-ubuntu

2
  • Good job on cloning the cloning script I wrote. Thanks for giving credit in your github. Jan 3 '20 at 12:18
  • Glad you liked. I just needed a tool to upgrade my computer from a hdd to a sdd. Then, I found your script and, as you didn't restrict its use, I decided to customize it to automate the whole process.
    – thiggy01
    Jan 3 '20 at 21:28

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