Link to home
Create AccountLog in
Avatar of Dwight Baer
Dwight BaerFlag 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.
Avatar of Dwight Baer
Dwight Baer
Flag of Canada image

ASKER

Attached is a pdf with the above procedure and a couple of screen snaps.  Mostly for my future reference.
cloning-a-linux-hd.pdf
Avatar of John Tsioumpris
I think you are looking for Clonezilla server : https://www.youtube.com/watch?v=cRXNipWrg4U
Dd is a low level media copy.
Dumo/restore might be faster.
Using Clonezilla .. To image unconfigured system
If you have 20 to setup per session. Use of a deployment, or disk less network based ... But that takes time to setup, test. Are these lab systems use LDAP to be in a position for central management of user accounts?

Virtualized?
An option? I,e. Users access a VM rather than physical host.
ASKER CERTIFIED SOLUTION
Avatar of Dr. Klahn
Dr. Klahn

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Thanks John, arnold and Dr. Klahn.

Yes, I agree I should probably use Clonezilla.  But if dd works then I'll stick with it.  I'll try "bs=16M"

dump/restore seems like a very heavy-duty tool.  I'll consider it in the future maybe.  I installed it and looked at the man page.

I agree, we should use more virtualization.  But I'm not the decision-maker in this regard.

Thanks again.  I love  Experts-Exchange.