On Mon, Nov 07, 2011 at 04:03:37PM +0100, Otto Moerbeek wrote:
> On Mon, Nov 07, 2011 at 03:54:14PM +0100, Benny Lofgren wrote:
> 
> > On 2011-11-06 21.42, David Vasek wrote:
> > > On Sun, 6 Nov 2011, Benny Lofgren wrote:
> > >> On 2011-11-06 18.00, Bambero wrote:
> > >>> Thanks, but without skip=1 dd will copy partition table and mbr too
> > >>> (first block 521b).
> > >>> So it may damage my partition table on second machine. I'm I wrong ?
> > >>
> > >> No, you will not copy the partition table with your command, since
> > >> you are using wd0a. That partition starts after the boot sector(s)
> > >> and partition table, so what you're in fact doing is skipping the
> > >> first blocks of the file system that is on partition a of wd0. Which
> > >> you don't want to do. (If you had used wd0c on the other hand, you
> > >> would have gotten the disk partition metadata as well. But you don't
> > >> want that either.)
> > >>
> > [...]
> > > 
> > > Benny, with this you will overwrite the disklabel of whole target disk,
> > > as the disklabel in a typical case indeed resides at the beginning of
> > > the wd0a. See disklabel(5).
> > 
> > Ah, you are absolutely correct, thanks. Please ignore my previous advice!
> > 
> > (Except the part about seek= and skip= not operating on 512 byte block
> > sizes but on the block size set by bs=/ibs=/obs=, that one will bite
> > anyone not paying attention to detail.)
> > 
> > Sorry for spreading FUD. (Although I can't really seem to find this out
> > from just reading disklabel(5) (I did check prior to my last comment), but
> > then again my brain's English language center might very well be somewhat
> > deficient...)
> > 
> > The best bet is probably to either go the dump/restore route like someone
> > suggested or simply save the target disk's label to file using something
> > like "disklabel wd1 >/tmp/disklabel.wd1" and then restoring it after dd
> > with "disklabel -R wd1 /tmp/disklabel.wd1" (since the in-core copy of the
> > original disk label will keep the working layout, there is no risk involved
> > with temporarily overwriting the label as long as it is restored prior to
> > the new disk's partitions being used).
> 
> There's also /etc/daily, you can get some inspiration from the
> ROOTBACKUP part of it. 

Especially these lines:
        sync
        dd if=/dev/r$rootdev of=/dev/r$rootbak bs=16b seek=1 skip=1 \
                conv=noerror
        fsck -y /dev/r$rootbak
that looks very much like what triggered the OP's question.

Note; sync before, dd that skips disklabel on filesystem mounted read-write,
fsck -y after to fix inconsistencies due to that. Dirty but practical.

I am myself curious to know if the 16 sectors are unused by all
4.2BSD filesystem partitions or if this is true only for partition 'a'.
Also, what if 'a' is RAID, or if e.g 'd' is the first used partition?

> 
>       -Otto
> 
> > 
> > 
> > Regards,
> > /Benny
> > 
> > -- 
> > internetlabbet.se     / work:   +46 8 551 124 80      / "Words must
> > Benny Lofgren        /  mobile: +46 70 718 11 90     /   be weighed,
> >                     /   fax:    +46 8 551 124 89    /    not counted."
> >                    /    email:  benny -at- internetlabbet.se

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB

Reply via email to