Avatar of Dwight Baer
Dwight Baer
Flag for Canada

asked on 

What’s the most efficient way to clone a Linux hard drive?

I have about 20 hard disks to clone for a new student lab with identical hardware.  I’d like not to have to purchase any additional software.  I do have a hard drive dock which holds one hard disk.
Below is the procedure I just used and it worked, but I’m sure there’s a better way.
Starting with a “master” workstation running Ubuntu (Machine 1)
1.      Install linux on a different machine (Machine 2).  Just the initial installation, no configuration needs to be done.  (Hardware is identical to the 1st machine.)  I suppose all I’d actually need to do is format this hard disk.  But it’s a small format case and there isn’t a power connector for a second drive.
2.      Remove the hard disk (Hard disk 2) and place it in the hard drive dock.  Connect the hard drive dock to Machine 1 via USB.
3.      Boot Machine 1;  it sees Hard Disk 2 as /dev/sdb
4.      (as root) dd if=/dev/sda of=/dev/sdb
5.      Place Hard Disk 2 back in Machine 2 and boot.  It comes up in maintenance mode.
6.      fsck /dev/sda
7.      Now Machine 2 boots as a clone of Machine 1.
8.      Edit /etc/hostname and /etc/hosts to reflect the Machine 2’s correct name.
LinuxSoftwareInstallationHardware

Avatar of undefined
Last Comment
Dwight Baer

8/22/2022 - Mon