1

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?

Ul Tome
  • 87
  • 2
  • 8
  • First question: Maybe try booting from the external drive on the other computer. You may have to adjust the boot order in the BIOS of that computer if it is not already set to try booting from a USB device before trying the hard drive. – pell Jul 15 '23 at 19:49
  • Try to ask only one question at a time. The image can probably be copied (using dd again) onto any partition that is larger. Once the copy is active you can probably resize it o use all the space. You are probably going to need to set up booting as copying the linux partition probably did not copy the stuff that actually does the boot. – icarus Jul 15 '23 at 20:02
  • if one person gives you a really good answer to the first question, and another person gives you a really good answer to the second question, then how will you choose which of the answers is correct? ... you can choose only one – jsotola Jul 15 '23 at 21:54

1 Answers1

1

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.

user10489
  • 5,834
  • 1
  • 10
  • 22
  • 2
    Just to add: rsync is a great tool for bringing in backed-up files after you perform a fresh installation. – pell Jul 15 '23 at 22:48