Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clone a server? 2

Status
Not open for further replies.

Hondy

Technical User
Mar 3, 2003
864
GB
Hi

Having spent a lot of time fiddling to get my first proper CentOS Linux install up and runnning - whats the best way to clone it?

Ghost works well on Windows servers but the last time i tried to restore a Linux image that was Ghosted it wasn't pretty.

I doubt I could remember every last config line etc, I have documented a lot of things but there were many fiddles to get things working - so it would be nice to clone the server in some way, what do you use?

Thanks


 
dd really isnt that hard. it can just do everything and the kitchen sink!

A basic command to clone a disk is...

dd if=/dev/sda of=/dev/sdb bs=32256 conv=noerror,notrunc

That command will clone from /dev/sda to /dev/sdb, sets the block size to 32256 (63*512) and tells it not to truncate the destination and dont stop on an error...

You should probably boot to like a knoppix linux cd, that way the disks wont be mounted.

knoppix also has dcfldd another version of dd that can give you the status of the clone...
dcfldd if=/dev/sda of=/dev/sdb bs=32256 sizeprobe=if conv=noerror,notrunc
 
hi engjohn

I forgot to mention I'm a Linux noob and I know what "c:" on a Windows server but I', not advanced to know what a /dev/sda is :S

How do you enumerate what drives are called? What do the words actually mean "dev" and "sda"?? whats wrong with /disk1/part1? I'm sure it means something, i think they name things like that to confuse us Windows users! :)
 
physical disks are typically partitioned into sections - just as Windows does it where you might see C: and D: as two parts of a single drive... "partitioning" means the same thing.

linux spends a little more effort in naming shorthand for drives that reflects the drive hardware type... IDE drives often get a shorthand versus SCSI/SATA drives getting a shorthand of "sd"

linux then appends letters to each succeeding drive that is of that type.

If you attached two SATA drives to your linux machine, in all likelihood you would have drives "sda" and "sdb" present (CD/DVD drives can jump into that sequence just like on Windows, this is all controlled by the BIOS and "published" to the OS)

The bit that looks a little more odd is that linux' general approach to fully naming the drives is to add them to the viewable filesystem under the path "/dev"

If you look under "/dev" for a while, you'll see references to modems, serial ports, other drives, and number of other references that you probably don't need to fret about. Remember that linux really likes to view the world as a filesystem... (think of "/dev" as 'devices')

So now, if you have a physical drive named "sda", it's going to have - perhaps - a few partitions for different folders to keep things separated and safe. If you partitioned "sda" into 3 (three) partitions, then you'd have those partition numbers appended to the drive name... thus giving you "sda1", "sda2", "sda3"

In full form (as in the prior post) you'll see the partitions referenced as "/dev/sda1", "/dev/sda2" and "/dev/sda3"

This shows how the physical partitions are attached to the system from linux' perspective.

THEN, the process of mounting these partitions is where the user-facing folders become real. Using the "mount" command (which you may never need to worry much about) you will create a relationship between a partition and a folder name.

So, if you wanted the partition "/dev/sda2" to appear as the folder "/home" on your machine, then the mount command makes that happen.

You can see the whole mapping of partitions to folders (and some other information that will confuse you) in the output of the commands "df" or "mount" (or by viewing the content of /etc/fstab -> do not edit this file! <- )

The biggest transition you need to make from Windows to Linux on this matter is to understand that "C:" would be equivalent to "sda" in terms of how much of the drive it describes if the drive had one partition (which is typical of Windows installations). The bit that Windows hides from you and that linux exposes to you is that the folders may either be virtual or logical assignments to a partition.

OR, said another way... if you make /dev/sda into a one-partition disk (/dev/sda1) then all your folders (/home, /boot, /var, /tmp, ...) would be virtual to that partition. This is how Windows (perhaps more precisely MSDOS and NTFS) views the world and creates drive letters.

If you wanted to translate linux' preference for a few partitions for keeping specific folders distinct from others (e.g. a small /boot partition to avoid filling it and making linux difficult to boot) then Windows would use several partitions of the primary drive and you would know them as "C:", "D:", "E:", "F:".

I'm sure someone else has written a more meaningful "how to understand the linux filesystem" document, but I've had a lot of caffeine and needed a distraction.

HTH.
Dave.


D.E.R. Management - IT Project Management Consulting
 
massively useful post! I get it now, it makes much more sense now you've explained it.

\devices\scsi_disk_a:partition2 etc right? :) sweet!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top