41

I'd like to buy a new 1TB disk to replace my old 150GB disk.
Is there an easy way to copy my Ubuntu installation with

  • my home folder content,
  • system settings,
  • applications,
  • and so on...

so at the end I can just unplug my old disk and plug the new one without having to re-install everything?

2
  • @Eric Carvalho and Fabby, Ravexina, David Foerster, George Udosen. This question have been created in Nov 2010. The other question is from June 2015. If we apply the time rules, this question was the 1st one to be created and answered. ;)
    – Boris
    Sep 1, 2018 at 5:53
  • This question, and the linked "...already has answers" question are different in important ways. This is about simply replacing a hard drive. That is about moving only the OS (and swap) to a new hard drive. Very different. Oct 25, 2020 at 21:30

4 Answers 4

45

sudo dd if=/dev/sda of=/dev/sdb will create an exact replica of sda to sdb as long as sdb is at least as big as sda.

Plugin your hard disk to your system, make sure the BIOS is recognizing it correctly and boot normally to your system.

Check your hard disks with Disk Utility(To launch Disk Utility, you can use the dash),
make sure that your old hard disk is sda and your new hard disk is sdb (change the devices on the example command to reflect your hardware configuration), no need to mount the new disk (it should be empty anyways so there is nothing to mount).

Run the command with the right devices in a terminal wait until its finished and that's it.

PS: triple check the command and make sure that your old hard disk is in the if part and that your new disk is in the of part of the command.

Your partitions will be copied from your old disk to the new one byte by byte so no need to worry about reconfiguring / installing MBR and bootloader. The only thing you need to do after the disk is copied is to remove the old disk from the system or set the new disk as boot device in your BIOS.

Later on when you tested that all is ok you can resize your partitions on the new disk with gparted, boot from a LiveCD, install gparted and resize the partitions of your new disk to fit your needs.

This solution requires no installation of extra tools except for the installation of gparted later on for resizing the partitions.

4
  • 1
    Just a simple curiosity, before Using the dd command , does the new /dev/sdb (Unformatted, exclusively just out of the box) needs to be formatted to ext4 or other format depending on the older drive installed format.
    – atenz
    Jun 25, 2012 at 6:42
  • 5
    dd doesn't provide any indications of it's progress when run. It just sits at the cursor until it has run and finished leaving you no idea how far along it is. To monitor it's progress while it's running, see (askubuntu.com/questions/215505/…).
    – James
    Nov 12, 2012 at 22:39
  • 1
    If you have both disks mounted and have done the dd copy, why not immediately use gparted from the currently booted /dev/sda to repartition /dev/sdb before booting /dev/sdb?
    – Glenn
    Jan 9, 2015 at 1:25
  • 4
    As per James comment and link, dd from Ubuntu up supports an additional command line argument status=progress which shows progress. So sudo dd if=/dev/sda of=/dev/null status=progress where /dev/null is replaced with the destination drive. and /dev/sda is replaced with the source drive. Oct 25, 2020 at 21:21
4

I would recommend partimage.
You can live-boot, install partimage and copy your partitions over.
What I really like about this software is that it is quite easy to handle (it's semi-graphical :-) ) and it's fast because it only copies the non-empty blocks. In other words you can copy a 10Gb partition to a bigger (on your new drive) one without much hassle.

Install it with apt-get.
more here: http://www.partimage.org/

3

May I suggest that you consider the 150GB drive to already be a backup of your home folder?

I would replace the 150GB drive with the 1TB drive and install Ubuntu with the same version that is on the 150GB drive. I would create a separate /home partition.

Next I would shut down and connect the 150GB drive to the machine and boot.

After that, I would mount the 150GB drive and copy the contents of the 150GB drive's home folder into the home folder of the /home partition of the 1TB drive. I would include all of the hidden files that begin with a dot (.) that you see when you select View>Show Hidden files in the File Manager menu.

I would then re-boot with the hope that the installed programs and utilities would pick up the configuration files in their respective dot (.) folders. Certainly the data in the Documents and Music folders (and other such folders) would be there.

I had to do something similar a few years ago when I created a separate /home partition without knowing that the OS would break because it could not find its /home folder. I did not have backup of my data. I solved my problem by installing Ubuntu into another partition. I copied my data into it. I then re-installed Ubuntu in my working / partition and set the mount point for my new /home partition and then copied my data back from the specially installed Ubuntu partition.

It is not the clever or beautiful solution but it works. I can say that from experience.

Regards.

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