[luau] use dd for disk clone?
Ray Strode
halfline at hawaii.rr.com
Thu Aug 15 12:46:00 PDT 2002
>
>
>dd seems to be file oriented, but I guess you
>can just treat two mounted disks as files?
>
It's not a good idea to do it on mounted disks (at lease read-write mounted
disks), but yes, you can just use the device names as if they were files.
>What would that look like, use /dev/hda and /dev/hdb as
>
>stdin and stdout, something like that?
>
Well, if you are trying to replicate one disk onto another, then that
would work.
(Assuming the drives are identical. I'm not sure if it would work or not
if, the
drives were different sizes/had different geometry).
so the command would be
dd if=/dev/hda of=/dev/hdb
or
cp /dev/hda /dev/hdb
If you want to make an image then you would do something like
dd if=/dev/hda of=mydrive.img
or
cp /dev/hda mydriveimage.img
If you just want to do one partition (say hda1), you would do:
dd if=/dev/hda1 of=mypartition.img
If you do your partitions separately, then it should be easier to
restore the data on a different size drive.
For instance,
dd if=mypartition.img of=/dev/hdb1
or
cp mypartition.img /dev/hdb1
One advantage of doing it by partition, is you should be able to
actually mount
the image file as if it were a partition using the loopback filesystem.
mount myparition.img /mnt/mypartition -oloop
>If you use / it would cause a problem
>because you'd be including your destination in your source,
>right?
>
I'm not sure i follow you here. If you want to do a raw copy, then /
isn't even
related, because / is a filesystem concept and raw copies don't know about
filesystems, they just know about bits.
>Isn't there also an issue regarding open files, etc.? When I
>clone a disk in irix, the manual says to do it in single user
>mode, I presume because you want all the files in a consistent
>state.
>
Yes. Like i said, better to do it mounted as readonly, or not mounted
at all. Single
user mode would be a good way to ensure that.
>Anyone see a way of using dd to make a disk image file instead
>of cloning a disk?
>
See above.
>Would tar do? Tarball too big? Would tar be able to make an
>exact copy? Would it leave out .files?
>
Yes, tar would work I think, but would be a lot slower, because it would
work at
the filesystem level instead of the bit level. There are other issues
to think about
two, like if you had more than one drive mounted, then tar would include
the
contents of all mounted drives in the archive.
--Ray
More information about the LUAU
mailing list