Migrate all my data to new computer without OS reinstall

I run ubuntu 22 with LUKS full disk encryption on my old laptop

disk

nvme0n1                                                   disk  476.9G 
├─nvme0n1p1           /boot/efi                           part    512M vfat
├─nvme0n1p2           /boot                               part    1.7G ext4
└─nvme0n1p3                                               part  474.8G crypto_LUKS
  └─nvme0n1p3_crypt                                       crypt 474.8G LVM2_member
    ├─vgubuntu-root   /                                   lvm   472.8G ext4
    └─vgubuntu-swap_1 [SWAP]                              lvm     1.9G swap

I plan to switch to a new laptop which has a similar storage capacity

I there a way I could migrate my whole disks content, so I don’t have to manually reinstall anything ?
Should I transfer the whole disk img as encrypted ?
It there anything else to setup on the new latop (bios/grub setting) that won’t be transfered with the disk image ?

Ps: Off course I have a external USB HDD as a transfer medium

Asked By: n0tis

||

In some instances you can simply install the hard drive in a different system. I transferred a Ubuntu 22.04 system with multiple users from a Dell 755 to a Dell 7020. It worked immediately.

The backout plan is to put the main hard drive back in the system it came from.

Answered By: quill

General Strategy

If (and it is BIG if) the new laptop has similar hardware such as internal drive, graphics card and WiFi, the old installation may work on the new laptop. In that case you may create an image file of the whole disk and restore it in the new computer’s internal disk.

If not, you will need to install Ubuntu (with encryption if you want),install the apps you have/want and restore your personal files from backup.

In either case, you must backup your personal files in an external drive that is not the drive you will use to transfer the transfer medium. Make two backups if possible using two different methods.

Internal Drive Consideration

You say, "both the laptops have similar storage capacity." Similar is not good enough for full disk cloning. Different manufacturers use different hardware and firmware. As a result even though both SSD/HDD says they are 500 GB one may be slightly bigger or smaller than the other. It is hard to determine which is which by casually looking at the size of the SSD/HDD. If your new SSD/HDD is even one byte smaller, the cloned image will not fit.

There may be other SSD/HDD consideration I don’t know about. Other readers can tell me in comments and I will incorporate them in the answer later.

Hardware Consideration

In Ubuntu there are two types of drivers for graphics cards, WiFi, fingerprint readers etc:

  1. Opensource drivers are usually built into the Ubuntu kernels and are automatically installed. If both your laptops have components and peripherals that have opensource drivers then it is great!
  2. Proprietary drivers are special drivers usually provided by hardware vendors. They have to be installed separately.

Open the app Software & Updates and select the tab Additional Drivers on top. If you see "No proprietary drivers are in use" at the bottom and "No additional drivers available" in the main window, then your laptop needs only opensource drivers.

Boot your new laptop with a Ubuntu Live USB using the Try option and follow the same process to see if the new laptop needs any additional proprietary drivers. If it does your current installation of Ubuntu may not work if it is transplanted to the new laptop.

Options:

1: Replace the new SSD with the old SSD/HDD

If you are comfortable opening your laptops and if the laptops have removable SSDs (or HDD) then you can try this. Unless you break or short circuit something, this is the easiest solution. It won’t work if the two laptops contain two different types of SSDs that do not fit into each other’s socket.

2: Clone the whole SSD/HDD

In the older systems with MBR and old BIOS one could clone a partition or two partitions from the old disks to the new disk and it could work. This does not work well with GPT and UEFI based new computers.

Cloning the disk may not work if the old disk has MBR and the new disk has GPT.

You can try various cloning utility ISOs and create bootable USB from them or use the Ubuntu Live USB using the Try option. The Disks app can create a disk image of your internal disk and keep it in the USB HDD. Both your laptops must have at least two USB ports:

  1. one for the Live USB to boot from and
  2. Second for the USB HDD to write/read the disk image file

3: Install and restore from backup

This is my favored option. This avoids opening and prying out disks from the laptops, counting bits and bytes of disk space, confusion between MBR and GPT, opensource and proprietary drivers any any other issues you may encounter.
Just follow these steps:

  1. Make a list of software and applications you have installed on your
    old laptop.
  2. Make a list of changes to configuration you have made, for example
    in the folder and subfolders of /etc/.
  3. Copy these altered configuration files in a USB drive.
  4. Freshly install Ubuntu (with encryption) on your new laptop.
  5. Restore your personal files from backup.
  6. Install the apps and software you need. This gives you a chance to
    review and not install applications you don’t need anymore.
  7. Restore your altered configuration files in /etc/ if needed.

Done.

Hope this helps

Answered By: user68186

I successfully made my transfer from thinkpad t14s gen1 intel to thinkpad e14 gen5 intel.
SSD Disk had different physical size, so I could not physically swap it.
Software wise, they had exactly the same storage size.
Here is the procedure for anyone interrested:

  • flash clonezilla on USB stick
  • on old computer, boot on clonezilla image, backup encrypted disk img to external usb storage
  • on new computer, boot on clonezilla image, restore disk img.

Quite amazingly, I did not have to update /etc/fstab or reinstall grub (I guess clonezilla took care of it).
I did not need update-initramfs.
Everything booted correctly out of the box.
Thanks to clonezilla team

Answered By: n0tis

I have moved a whole system several times between machines, but there were some conditions:

  1. The disk was not encrypted
  2. There were no proprietary drivers in use, only whatever is built into the kernel.
  3. These machines used MBR boot method and not UEFI.

If these conditions are not met, you may or may not succeed – I cannot guarantee anything.

Probably the easiest way is to use Clonezilla. Prepare a bootable Clonezilla USB or DVD (if you have a DVD drive), and boot your "source" machine from it. You will also need to have an external HDD to store disk image produced by Clonezilla. After creating the image, reconnect the external HDD to your "target" machine, boot it from Clonezilla USB/DVD and restore the image to the new machine.

The whole process is described in detail on Clonezilla website. That should work in most cases.

In case it doesn’t, there are multiple "manual" methods, from manually creating and restoring disk image or partition images (of course you must do it while booting the machine from live USB/DVD, not from installed system), or even making a tar archive of the whole filesystems and unpacking it to proper partitions on the target disk. In any of these cases, you may also need to adjust /etc/fstab to your new partition names, and also need to install/reinstall GRUB. However, this may require some advanced knowledge of the system boot process to manually fix whatever Clonezilla wasn’t unable to fix. I had one case, when moving a quite old OS from one server to another, that I had to update the kernel on the already cloned target server (on a system that didn’t boot! – this was indeed tricky), because the kernel was too old and displayed a message on boot that it doesn’t support the processor of the newer server.

Answered By: raj
Categories: Answers Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.