View Full Version : Cloning an entire drive?
spiderpig
07-08-2008, 07:49 PM
I've had this question for some time, but have never asked...
There is an article from the OpenBSD Journal which covered cloning drives:
http://undeadly.org/cgi?action=article&sid=20080319204706
The author advocates using dump & restore on each partition, but if cloning the entire drive is the goal, why not simply back up the c partition?
:confused:
Eam404
07-08-2008, 08:54 PM
Well if by C drive you mean /root partition then no you cant just backup your root partition. Things like usrland apps and /etc configuration files are all items that most people like to back up; at lest generally. Dump/Restore works great on BSD systems. If you are wanting a more universal way to "clone" your hard drive the dd command works wonders. Heres a small example: http://www.linuxweblog.com/dd-image
spiderpig
07-08-2008, 09:33 PM
Well if by C drive you mean /root partition then no you cant just backup your root partition.
Actually, my terminology was quite precise. I assume what you refer to /root is typically /dev/wd0a on a bootable IDE drive, or /dev/sd0a is the bootable drive is SCSI. Otherwise, /root is merely a directory, not a partition.
Again, given that /dev/wd0c or /dev/sd0c both covers the entire disk and is accessible, why not clone it instead of each individual partition?
revzalot
07-08-2008, 09:37 PM
Thanks for bringing this up and I've always wanted to find a way to clone drives. One way is using g4u but I want to clone a drive by using the same box. Is it possible to just go into single user mode, mount the two drives:
# mount -a /dev/wd0
# mount -a /dev/wd1
then use the copy command:
# cp /dev/wd0 /dev/wd1
Is this possible assuming both drives are the same capacity.
spiderpig
07-08-2008, 10:05 PM
Is this possible assuming both drives are the same capacity.
No, for at least two reasons. One, cp(1) copies relative to the user that invoked the command. If cp is invoked as a user other than root, then permissions may be set which will not allow that user to read and copy. If root is used to copy files, then individual user ownership is lost. Two, consider all the device nodes residing in /dev. The script /dev/MAKEDEV is executed at installation time for a reason.
ocicat
07-08-2008, 10:36 PM
No, for at least two reasons.
If the drive being cloned is a boot drive, you should also consider running installboot as the article suggests.
BSDfan666
07-09-2008, 12:02 AM
For one revzalot, /dev/{wd0,wd1} don't exist.. and you can't use "cp" like that either.
To backup a partition, I use either tar or dump, if I'm trying to recover something.. like lost data off a friends thumb drive or w/e, I duplicate the partition with dd...
dd if=/dev/rsd0i of=partition-image.img
Then work on the image instead of risking the drive..
J65nko
07-09-2008, 12:08 AM
The author advocates using dump & restore on each partition, but if cloning the entire drive is the goal, why not simply back up the c partition?dump and restore act on filesystems.From the dump man pageNAME
dump - filesystem backupLabel "c" does not have a filesystem, it is just a virtual label encompassing the complete disk, which could have other operating systems installed.
From one of my systems$ disklabel wd0
# Inside MBR partition 0: type A6 start 63 size 81915372
# /dev/rwd0c:
type: ESDI
disk: ESDI/IDE disk
label: WDC WD3200AAKS-2
flags:
bytes/sector: 512
sectors/track: 63
tracks/cylinder: 255
sectors/cylinder: 16065
cylinders: 38913
total sectors: 625142448
rpm: 3600
interleave: 1
trackskew: 0
cylinderskew: 0
headswitch: 0 # microseconds
track-to-track seek: 0 # microseconds
drivedata: 0
16 partitions:
# size offset fstype [fsize bsize cpg]
a: 81787372 63 4.2BSD 2048 16384 1
b: 128000 81787435 swap
c: 625142448 0 unused 0 0
i: 204796620 163830870 unknown
j: 256509855 368627490 MSDOSSee, no fstype defined for label "c" ;)
I have some other OS's installed]fdisk wd0
Disk: wd0 geometry: 38913/255/63 [625142448 Sectors]
Offset: 0 Signature: 0xAA55
Starting Ending LBA Info:
#: id C H S - C H S [ start: size ]
------------------------------------------------------------------------
*0: A6 0 1 1 - 5098 254 63 [ 63: 81915372 ] OpenBSD
1: A9 5099 0 1 - 10197 254 63 [ 81915435: 81915435 ] NetBSD
2: A5 10198 0 1 - 22945 254 63 [ 163830870: 204796620 ] FreeBSD
3: 05 22946 0 1 - 38912 254 63 [ 368627490: 256509855 ] Extended DOSThese all lie within the boundaries of the label "c" size of 625,142,448 sectors.
dump is not so smart it can backup NetBSD, FreeBSD and the extended DOS partitions in one go ;)
BSDfan666
07-09-2008, 12:10 AM
What J65nko posted *should* be common knowledge, I'm not even going to comment on Eam404's reply. ;)
Eam404
07-09-2008, 02:32 PM
Welp, I guess thats what I get for not reading the whole post...
vBulletin® v3.7.2, Copyright ©2000-2009, Jelsoft Enterprises Ltd.