Sample Header Ad - 728x90

Is this a safe way to migrate my data to a new computer?

3 votes
2 answers
273 views
I recently bought a new laptop and I would like to migrate to it with as little hassle as possible. I don't want to do a fresh install since I have made various tweaks to my current setup for things like automounting remote drives from my NAS, configuring networking etc. that I would prefer not to have to redo. My current thinking is that I can just dump the contents of my hard drive to a file, then cat that file onto the new drive. The general idea will be: 1. On the old computer, cat the drive into a file on an external USB disk and (as root):
# cat /dev/sda > /mnt/externalUsb/sda.img
2. I then boot into a live system on the new computer, connect the external drive and (as root):
# cat /mnt/externalUsb/sda.img | sudo tee /dev/sda
3. Shut down the live session, reboot the machine and, I hope, find myself in a working system which is a perfect clone of my old machine. Or, perhaps more realistically, something like: 1. Create the partitions I want on the new machine, making sure they are larger than the equivalent ones on my old machine. 2. On the old computer, cat the partitions into files on an external USB disk (as root):
for i in 5 6; do cat /dev/sda"$i" > /mnt/externalUsb/sda"$i".img; done
3. On the new machine, after making sure the numbers are the same or modifying the command accordingly:
for i in 5 6; do cat /mnt/externalUsb/sda"$i".img; > /dev/sda"$i"; done
Some relevant notes: * The hardware of the old and new machines is relatively similar as I will be moving from a ThinkPad T460P to a ThinkPad P14s Gen 2 . * The new machine has a 1TB hard drive but the old one is only 512G. * I am using Arch, dual booted with a Windows 10. I am not particularly bothered about keeping the Windows install. My current machine's disk setup:
$ sudo parted -l
Model: ATA SAMSUNG MZ7LN512 (scsi)
Disk /dev/sda: 512GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system     Name                          Flags
 1      1049kB  274MB   273MB   fat32           EFI system partition          boot, hidden, esp
 2      274MB   290MB   16.8MB                  Microsoft reserved partition  msftres
 3      290MB   86.4GB  86.1GB  ntfs            Basic data partition          msftdata
 5      86.4GB  136GB   50.0GB  ext4
 6      136GB   437GB   301GB   ext4
 9      437GB   485GB   47.3GB  ntfs                                          msftdata
 8      485GB   495GB   10.5GB  ext4
 7      495GB   511GB   16.1GB  linux-swap(v1)                                swap
 4      511GB   512GB   1049MB  ntfs            Basic data partition          hidden, diag
I am expecting the kernel to detect the new/different hardware the first time it boots and sort it out for me automatically. Am I missing something obvious here? Any specific problems I might encounter? The new drive is larger, so that shouldn't be a problem, right? I have an ecryptfs-encrypted directory (two of them, actually), am I right in assuming that won't be an issue? Will I need to do anything special to handle the EFI system partition perhaps? ----- I accepted MC68020's helpful answer, but I ended up taking a different approach: I booted a live system, created the root and /home partitions and then just copied all my files over using rsync as described in the Arch Wiki . I managed to boot the "new" system, but it still needs some tweaks, notably for the graphics driver. This isn't an approach to be taken if you don't know your way around Linux and enjoy tinkering. Of course, if you don't enjoy it, it's unlikely you'll be using Arch.
Asked by terdon (251605 rep)
Jun 26, 2022, 04:20 PM
Last activity: Jul 17, 2022, 07:48 PM