Peter Fraser wrote:
> /etc/daily uses the following code
> 
> sync
> echo ""
> echo "Backing up root filesystem:"
> echo "copying /dev/r$rootdev to /dev/r$rootbak"
> dd if=/dev/r$rootdev of=/dev/r$rootbak bs=16b seek=1 skip=1 \
>       conv=noerror
> fsck -y /dev/r$rootbak
> 
> where as http://www.openbsd.org/faq/faq10.html#DupFS
> says to use either 
> 
> cd /SRC; dump 0f - . | (cd /DST; restore -rf - )
> 
> or
> 
> cd /SRC; tar cf -  . | (cd /DST; tar xpf - )
> 
> I figured out that tar does not work for pipes or dev files
> so it is not any good for copying the root file system.
> 
> But I don't know why you should pick "dd" over "dump".
> For example using
> 
> newfs /dev/$rootbak
> mount /dev/$rootbak /altroot
> cd /; dump 0f - . | (cd /altroot; restore -rf - )
> umount /altroot
> 
> is dramatically faster the using "dd". But
> I assume that there must be some reason for using "dd"
> for copying "/".  The faster the copying takes place
> the less likely there is any inconsistency. So what am
> I missing.

You missed the important step of TESTING. :)
Try it.  You will find your new / partition won't boot.  Short reason:
the physical inode of the file /boot is hard coded into the PBR.  You
won't keep the same inode if you dump/restore.

Tip: when doing this, make your / partition as small as you can make it
comfortably.  That will minimize the difference between dd and
dump/restore.

> PS I also don't understand why the first 16*512 bytes are
> skipped when using "dd"?

I was really hoping someone else would answer this, I'm not completely
sure about my answer...I think that's where the PBR and the disklabel
hides.  Actually, I *know* it is the PBR, I'm guessing about the
disklabel, but looking at the contents, I'm pretty sure I'm at least
partly right.

> If I want to copy a whole physical disk, should I also skip the
> first 16*512 bytes?

Maybe.  Maybe not.
If the two disks are to have the exact same contents, sure.
If they would have different disk labels, no.
BTW: that script skips the first 16 blocks of the 'a' partition, not the
first 16 blocks of the disk.  The 'a' partition normally starts one
track into the disk on an i386/amd64 system, which is sometimes 63
blocks.  And sometimes not.

Nick.

Reply via email to