3

I have an Ubuntu system with a large project, many small projects, and (of course) loads of packages and libraries.

If I buy a new computer and want to replicate all of this, how do I do it? I presume installing Ubuntu on the new machine and then copying the file tree from some point down will fail since the new machine will have it's own way of viewing things, understanding of how things are tied together, etc., and just replacing the new file tree starting with root with a copy from the old machine is an idiotic idea.

1
  • 1
    I still believe in new clean install & restore /home, perhaps some settings in /etc. but are the applications server type that have folders in /, not in /home? You can export a list of installed apps and restore that. You should normally do all that as backup as when hard drive fails, you have to restore from backups. Best practice for Backups - theFu ubuntuforums.org/showthread.php?t=2368992& ubuntuforums.org/…
    – oldfred
    Dec 26, 2019 at 20:21

2 Answers 2

9

Clonezilla is your friend. Download its ISO from https://clonezilla.org/downloads/download.php?branch=alternative then make a LiveUSB from the ISO file. Reboot your PC after attaching the destination drive to the original PC and boot from the Clonezilla USB. Choose disk to disk and clone away!

Then, for your sanity's sake, once the disk-to-disk cloning completes, image the system with Clonezilla, saving the partitions (which will be compressed) to the target drive's root or /home partition. Once completed, boot from that drive, be it HDD or SSD. Obtain the size of the compressed image, and burn that to DVDR. Make a second copy to a USB flash drive. Verify the contents match the source, then the DVDR goes offsite, and the copy on USB is attached to the Clonezilla flash drive so you can reconstitute your system as of (today) if you ever need.

5
  • 2
    +1000 for clonezilla!
    – chili555
    Dec 26, 2019 at 21:35
  • I presume once I do the clone to a hard drive, I then use Clonezilla on the new machine, having it read from the hard drive?
    – eSurfsnake
    Dec 26, 2019 at 23:32
  • Clone drive-to-drive in Clonezilla, and then make a backup drive-to-image. That creates a file you can then write to DVDR.
    – K7AAY
    Dec 27, 2019 at 0:24
  • Why would you need both USB and DVDR? Nothing indicates the clone has to be archived.
    – Mast
    Dec 27, 2019 at 8:41
  • Belt-and-suspenders. A DVDR lasts longer than a flash drive, so that's what I suggest goes offsite.
    – K7AAY
    Dec 27, 2019 at 16:45
3

When using Linux copying or migrating your existing system to an other harware is much easier than you might think with your Windows experience. You need a copy of your HDD or put your existing one in your new computer and you have pretty good chances that you boot in your new hardware without any problem.

If you want to copy your existing system to a new HDD:

  1. Make sure your new location is as big or bigger than your existing one.

  2. Boot a live CD (any one will fit you that offers a terminal).

  3. Make sure your existing system (the drive you want to move) and your new drive are connected to your machine but they are not mounted. (cat /proc/partitions will show your available drives.)

  4. Now this will do the trick for you:

    sudo dd bs=4M conv=sync,noerror status=progress if=/dev/hda of=/dev/hdb 
    

    where /dev/hda is your existing system and /dev/hdb is the new drive you want to copy your existing system to. Take care not to use partition numbers because you want to copy everything (eg. MBR, partitions and all contents) to your new location.

Be sure not to exchange the drive names in if=your_existing_drive and of=your_new_drive or you will destroy your existing system by overwriting it with the contents of your new drive (e.g. a bunch of pretty zeroes if that is a brand new formatted drive).

If you could boot from /dev/hda in your old system chances are that your new cloned drive /dev/hdb will fit in any computer hardware and you will boot from it. After you started your new system you may finish adjusting settings that your new hardware offers or requires, and check for gparted to adjust your partition sizes if your new drive is bigger than the old one.

0

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