38

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
  • 3
    You can copy-paste partitions with gparted from a live CD
    – Panther
    Jun 24, 2015 at 6:02
  • Or you could use clonezilla (GPL) clonezilla.org
    – Bruni
    Jun 24, 2015 at 6:30
  • 10
    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, 2015 at 7:13

4 Answers 4

20

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, 2015 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, 2015 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, 2015 at 8:53
  • cat is safer and simpler than dd. There's no reason at all not to use it.
    – terdon
    Jul 2, 2019 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, 2021 at 0:46
15

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
  • 2
    I gues this is the method i will choise, to be honest, i preffer the shell thing instead of Gparted thing. Jun 24, 2015 at 6:47
  • 2
    Lucian: da, e cea mai buna solutie. ;)
    – Frantique
    Jun 24, 2015 at 6:52
  • 6
    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, 2015 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, 2015 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, 2018 at 22:37
10

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

4
  • 8
    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, 2015 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, 2015 at 9:48
  • 6
    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, 2017 at 6:25
  • 2
    I agree with jringoot. If the link becomes unavailable, the answer is moot anyway. Oct 5, 2019 at 13:20
4

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

3
  • 1
    Good job on cloning the cloning script I wrote. Thanks for giving credit in your github. Jan 3, 2020 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, 2020 at 21:28
  • Can confirm the script works, have used it to clone an older HDD to a new SSD. The script did a great job in checking the prerequisites and I could boot from the SSD immediately. One caveat was, I had to change the UUID of the / partition in /etc/fstab by hand - for some reason this has not been changed.
    – Tyreal
    Apr 2, 2023 at 6:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .