2

I have a Debian 10 system running on my laptop, and I'd like to clone it over to my Ubuntu laptop (which has a larger hard drive than the Debian laptop), replacing the Ubuntu installation altogether. What is the easiest and fastest way to accomplish this so that I can get up and running with all my themes, configuration files, aliases intact and everything looking just as it is now on my current Debian system?

Josh
  • 39
  • 1
  • 4
  • 1
    clone the disk with `dd` would be the simplest option, or try something like clonezilla https://clonezilla.org/show-live-doc-content.php?topic=clonezilla-live/doc/03_Disk_to_disk_clone – Bart Sep 13 '19 at 08:23
  • and then change the UUIDs and update fstab and the swap device uuid in intramfs. Thaat's enough for you to google how, Why change the UUIDs? Its just cleaner - your machines will not have the same should you continue to use the older one. Does it really matter? Not really really, but I do it... – RichieHH Nov 22 '20 at 11:20

2 Answers2

2

Missing Details

Doing this kind of thing is a serious business, you should not take it lightly. As a person who actually did this before, I must say that devils are in the details; details that you left out of the question:

  • What is the current exact partition configuration on each machine?

    • Single OS partition, or separate ones for /, /home, /usr, and /var?
    • Using swap partition, or not?
    • Are there data storage, other OSes, or boot-only (a la EFI) partitions in the mix?
    • What are current ordering of partitions?
    • Does each machine have only single disk?
  • What is the partitioning type of each machine (MBR or GPT?)

  • What is the current boot mode of each machine (classic BIOS/CSM, UEFI, or god-forbid UEFI+Secure Boot?), and could you change the target machine's boot mode?
  • What is type of the disk interface your are using on each machine (PATA or SATA?)
  • Is unplugging disk from source machine a viable or desirable option? or would you rather do it over the Ethernet wire?

    • If you would rather do it over the wire, does wired link between both machines exist and is over 1Gbps+ speed?
  • If you opt to unplug disk from the source machine; does plugging it inside target machine being a viable or desirable option?

    • If not, do you have an external SATA/eSATA connector on target machine? (Together with necessary cable/power supply adapter to use it?)
    • If still not, do you have USB 3.0+ hard disk adapter that you could use? (And does the target machine support USB 3.0+?)
  • How does kernel's initramfs on the source machine was originally configured at the install time? ("Full drivers", or "Minimal required drivers"?)

  • How command-line savvy are you? (Namely, can you "log in as root", "mount read only", "bind-mount", and "chroot into" on command line?)

I'm using a different Debian version, on a configuration that is different from yours. Without these information in your question, I'm afraid that you are leaving the question very open-ended and very time-consuming to answer...


Simple Approach

This is a simple (mostly point-and-click) approach, but is arguably lengthy, fragile, and relies on lots of assumptions...

Assumptions for both machines: single-partition OS, no swap partition, no other partition, MBR partitioning scheme, classic BIOS, SATA disk interface, unplugging source disk and plugging it inside target machine is OK and desirable...

  1. Make sure that both machines are powered off.
  2. Unplug source disk off the source machine.
  3. Connect the source disk into the target machine, make sure that it is not detected as the first disk.
  4. Boot the target machine with modern GNU/Linux boot disk, make sure that no partitions are mounted.
  5. Use gparted to remove the Ubuntu partition from the target disk.
  6. Use clonezilla to copy the source partition from source disk to target disk verbatim. (Lengthy process)
  7. Use gparted to expand the target partition to fit the space. (Lengthy and dodgy process)
  8. Re-initialize the target disk's boot loader (using any means necessary).
  9. Shut down the target machine
  10. Remove the source disk from the target machine.
  11. Plug the source disk back into source machine.
  12. Disconnect the target machine from network.
  13. Boot the target machine (cross your fingers while you're at it).
  14. Log in (probably as root).
  15. Reconfigure your host name.
  16. Reconfigure your IP address.
  17. Connect the target machine to the network.
  18. Enjoy the new machine!

But only if it would have been that easy...

If any of the assumptions were false (and I know at least 3 of them are likely to be false on most modern desktop system); all the bets would be off, and chances are you would be left with either unbootable or severely handicapped system on target machine.

Actually, I have drafted an alternate answer based on how I actually did this with Debian 5.0 "Lenny" over 100 Mbps Ethernet wire several years ago, but it assumes that you knows GNU/Linux command line and system utilities associated with this kind of task very well; and I can't tailor it to match your question unless you edit your question to address the missing details above.

  • Hello and welcome to U&L! I happened across your answer and noticed that you felt several details were missing from the question. Once you have a few more reputation points, the correct thing to do on Stack Exchange in that situation is to leave clarifying comments on the question. Then the owner of the question can update it in response, after which you can provide an informed Answer. .Thank you! – Jeff Schaller Sep 15 '19 at 11:58
0

Create 2 debian live USB ( e,g: the standard ISO)

On the Ubuntu machine , boot from debian live then setup the root password and configure the root access through ssh.

sudo -s
passwd
apt update
apt install ssh

Add the following line to your /etc/ssh/sshd_config:

PermitRootLogin yes

Then:

systemctl restart ssh

on debian machine: boot from debian live , setup ssh :

sudo -s
apt update
apt install ssh
systemctl start ssh

then clone your device (e,g: /dev/sda)

dd bs=128K if=/dev/sda | ssh root@destination "dd bs=128K of=/dev/sda conv=noerror,sync status=progress"

Reinstall grub on the remote machine:

ssh root@destination
mkdir /mnt/target 
mount /dev/sdaX /mnt/target
mount --bind /proc /mnt/target/proc
mount --bind /sys /mnt/target/sys
mount --bind /dev /mnt/target/dev
mount --bind /run /mnt/target/run
cp /etc/resolv.conf /mnt/target/etc/resolv.conf

/dev/sdaX : the root partition , a separate boot partition should be mounted.

Use the command blkid to check the UUIDs under /etc/fstab (/mnt/target/etc/fstab) before reinstalling grub.

Reinstall grub :

chroot /mnt/target /bin/bash
grub-install /dev/sda
exit

Unmount the mounted partitions then reboot.

Debian : Reinstall Grub EFI

Debian: backup/Clone

Archlinux: Cloning an entire hard disk

GAD3R
  • 63,407
  • 31
  • 131
  • 192