Clone hard drive

I want to install PureOS on a second laptop, just the same as the first.

How can I clone my first hard drive onto a second one to then install this second hard drive?

Both laptops are pretty much the same. So I expect the drivers to work.

https://clonezilla.org/show-live-doc-content.php?topic=clonezilla-live/doc/03_Disk_to_disk_clone

Or use the dd command if you are prepared to be sufficiently careful !!

Note also that you would expect, in normal circumstances, to change a few things on the second laptop after booting the second laptop e.g.

  • the system’s hostname
  • if not using DHCP to get an IP address then the system’s IP address
  • if you running an SSH server on the original laptop then generate a new host key
  • generate new random UUID for any file systems
  • if using Samba and using a non-default hostname, that hostname

I’m sure there are other things …

Adding:

Well here’s one more thing that came up in a different topic:

  • if you clone a disk that contains an encrypted partition then the resulting disk will have exactly the same master key and exactly the same passphrase as the original disk. There are good to strong arguments, depending on exact use case, that you should update both the master key and the passphrase of the clone.
3 Likes

I know very little about PureOS commands. Can you enlighten me on the “dd” command?

Then the dd command is probably not for you.

With the dd command you can accidentally wipe out all the content of a disk. Hence why you have to be careful.

As with most shell commands, you can use man dd to bring up the manual page for the command, in this case the dd command.

Some tips from me …

  • You should not in general clone a disk that is in use. Hence, you should not clone the disk that you booted from. So if you want to clone the disk that you normally boot from then you first must boot from a different disk. That would often be a “live boot” from a USB flash drive.

  • To help with getting the source disk and destination disk correct, which is an essential part of the process, you would generally check for available disk devices before plugging in the destination disk, then plug in the destination disk, then check again for available disk devices - so that you can see which was the newly appearing disk - all assuming that the destination disk is a removable disk. The goal of this step is to know the device names (/dev/something) of the source and destination disks i.e. with ls -l /dev and in addition to this or instead of this, confirm disk size and model with sudo fdisk -l /dev/something

  • Ignore the /dev/whatever for the partitions of a disk, if any. Hence if /dev/sdc appears then you might also get /dev/sdc1, or you might get /dev/sdc1 and /dev/sdc2. Ignore sdc1 and/or sdc2. Those are for the individual partitions of the disk. You want to clone the whole disk, the partition table and all the partitions. So, in this example, you would want /dev/sdc

  • You don’t want either the source disk or the destination disk to be mounted, or any partition of those disks to be mounted. So if they automatically mounted then you want to unmount them. Use mount -l | grep /dev/disk to check each of source and destination disk for whether it is mounted and sudo umount /dev/disk to unmount if needed.

With that preparatory work done …

sudo dd if=/dev/source of=/dev/destination bs=1M status=progress

None of the above is specific to PureOS. Should work on just about any Linux distro.

4 Likes