How do I adapt a .img clone of my hard disk (1 partition with openSUSE) to another computer?

I have used the dd command to backup my Linux partition (openSUSE Tumbleweed) into a .img file that I saved on an external hard drive.

However, I guess dd-ing it on another computer may cause problems, since the hardware is different and therefore the config of my Linux should probably be adjusted.

How do I do that properly?

And, second question: if my hard drive gets stolen, what would that .img file compromise? And if it is significant, how would you recommand me to make it more secure? Maybe encrypt it? What method would you use?

Asked By: Ul Tome


Linux is fairly robust in that it typically auto-detects most devices at boot and the image might work on any hardware. There are a few exceptions (like nVidia drivers and some rare raid drivers) where the driver needs to be embedded in the initrd to boot correctly, but likely you need the same work-arounds to boot for the initial install that you would to boot the image. Likely you would be able to boot the image without these drivers and then reinstall them afterwards, which would rebuild the initrd.

A bigger problem is that modern operating systems use UEFI to store bootstrap software outside of the partition, so the image by itself won’t be bootable. You need to also either copy the boot pieces from the UEFI partition (and this is not guaranteed to work), or you need to run a boot repair to reinstall those pieces on the disk you copy the partition onto. (This is less of an issue if you copy the entire disk rather than the partition, but you may still need to reinstall the boot loader in the new computer’s UEFI menu.)

Having said that, dd is not the best way to move linux onto a new system.
A tool that does a file by file copy instead of a partition copy like tar might be more efficient (but suffers the same boot issues mentioned above) but requires extra steps before and after the copy to get things working. Some backup software might work better as well and might be able to also restore the boot loader.

As to what would the img compromise… using dd to copy a partition (or disk) copies the entire partition, including unused space which might contain fragments of deleted files. So leaking the image would not only compromise all data in the filesystem, but possibly data you have deleted. Additionally, copying the unused "free" space is not efficient and would not be copied by a more suitable tool that is filesystem aware and can skip the unused space.

In some cases, it might even be faster and more reliable to just reinstall the system from scratch with a linux installation disk and then copy the data (mostly home directories) from the old disk.

Answered By: user10489