backups & cloning

Polytropon freebsd at edvax.de
Wed Sep 30 03:03:10 UTC 2009


On Tue, 29 Sep 2009 22:23:00 -0400, PJ <af.gourmet at videotron.ca> wrote:
> I feel a bit stupid, as usual, my carelessness led me to miss the
> difference between ad1 and ad2... dumb, dumb, dumb.

As long as you realize it BEFORE any writing operation, it's
no problem. Keep in mind that the numbering of ad*, as well
as of da* (which your USB disk will probably show up as)
depends on the position of the drive on the ATA controller,
e. g.	primary master   -> /dev/ad0
	primary slave    -> /dev/ad1
	secondary master -> /dev/ad2
	secondary slave  -> /dev/ad3
	...
This numbering sceme even does take place if you're using
the master channels only, so in this example you would have
the ad0 and ad2 drives, no matter if ad1 is present or not.



> But... 2 questions:
> 1. will the s1a slice dump the entire system, that is, the a, d, e, f
> and g slices or is it partitions?

As far as I remember, you cannot dump slices. You can dump
partitions only, or, in other words, the dump program does
operate on file systems (and those are represented by one
partition per file system).

If you want to duplicate slice-wise, dd should be used, such
as the following example:

	# dd if=/dev/ad0s1 of=/mnt/usb/slice1.dd bs=1m

If you want to duplicate partition-wise, you need to dump and
restore each partition, just as my verbose example showed.



> I've been very confused with the slices/partitions.

The term slice refers to what MICROS~1 calls "DOS primary
partitions" in the widest sense. Due to DOS limitations,
PCs do only support 4 slices per disk.

The term partition refers to a sub-area inside a FreeBSD
slice. Partitions can be used to separate functional
subtrees partition-wise. Of course, I often see settings
where there's only one partition on the slice, that's
a common thing.



> I meant above, to dump the whole slice - but I guess that it has to be
> done with the partitions.

Partitions: use dump + restore
Slices: use dd
Whole disks: use dd



> and when I do dump -0Laf  /dev /ad1s1a  /dev/da0s1a
> the errors are
> "write error 10 blocks into volume 1
> do you want to restart:"

Okay, everything is clear now. Just "interpret" the dump
command:

	dump full snapshot autosize output=/dev /ad1s1a

First of all, /ad1s1a does not exist. Then, /dev/da0s1a is
ignored. The command doesn't make sense. The syntax of dump
can be simplified as follows:

	dump (other options) -f outputfile inputdevice

Note that outputfile can be - (the standard output) which
can then be redirected somewhere else.

At this position, I need to ask you: What are you trying to do?
	a) I want to dump ad1s1a as it is onto the disk that
	   is da0.
	b) I want to dump ad1s1a as a file on the disk that is
	   da0.

Let's take a) first. I assume you have prepared the disk da0
as shown in my earlier example, or you simply have used sysinstall
to create a slice on the disk and partitions inside the slice that
are big enough to hold the data you want to transfer to them.

Check their existance:

	# ll /dev/ad0* /dev/da0*

The listing should give you similar slices and partitions both
for the source and the target disk.

First you mount the target disk and change the working directory
to it:

        # mount /dev/da0s1a /mnt
        # cd /mnt

Now you dump from your ad0 disk to where you currently are:

        # dump -0 -L -a -u -f - /dev/ad0s1a | restore -r -f -

Proceed with the other partitions. Mount them, change into
their mountpoints that are now relative to /mnt (e. g. /mnt/var,
/mnt/home) and repeat this command, substituting the source
/dev/ad0s1[defg]. Finally, change back to / and umount 
everything in a successive way, sync, done.

For case b) it's much easier. When you want to create data
files, you don't need to slice / partition your USB disk, just
newfs and mount it:

	# newfs /dev/da0
	# mount /dev/da0 /mnt

Now you can create all the data files for the different partitions:

        # dump -0 -L -a -u -f /mnt/root.dump /dev/ad0s1a
        # dump -0 -L -a -u -f /mnt/tmp.dump /dev/ad0s1d
        # dump -0 -L -a -u -f /mnt/var.dump /dev/ad0s1e
        # dump -0 -L -a -u -f /mnt/usr.dump /dev/ad0s1f
        # dump -0 -L -a -u -f /mnt/home.dump /dev/ad0s1g



> The first time I tried with -L the error was 20 blocks...
> Both the slices for dump from and to are same size (2gb) and certainly
> not full by a long shot ( if I reccall correctly, only about 14% is used)

As far as I see, the command line just was wrong.


> why into SUM?

The idea behind doing dump / restore in SUM is - in addition with
unmounted partitions - to ensure that no write access disturbes
the reading process from the partitions. Of course, it's possible
to use -L and stay in MUM.



> I'm really the only user and I usually stay as root????

It's valid to perform dump / restore as root.



> if SUM, shouldn't the # below be $?

No. The # indicates root permissions in any shell. The $ indicates
non-root access in sh or bash, the same does % in csh.



> So, ad1 is the target disk and ad0 is the source?

I don't know your disk setup. :-)

If you're booting from ad0 and want to duplicate THIS particular
system, then this is your source. But you said that you want to
use a USB disk as target, that would be da0 then.



> I don't follow the next sequence...
> after shutdown, boot in SUM?

No. The command

	# shutdown now

gets you into SUM. You can achieve this by rebooting and and issuing

	boot -s

at the loader prompt, but why so complicated? :-)



> the following commands ($ instead of # ?) would be on the source (ad0 ?)

Correct.



> What is happening with the umount commands below?

It unmounts any partitions that aren't required for system
operations (here: for dumping and restoring). If you use
the -L flag for dump, this step isn't needed.



> And the mount -r / ?

This mounts / in read-only mode, because you can't unmount it,
you need /sbin/dump, for example, so it should be reachable.



> The fsck is to clean the partitions, right?

Correct. BUT: If you don't umount the partitions and want to use
-L as described above, don't fsck the partitions. The fsck should
be run on unmounted partitions only. It's just to make sure that
the partitions you want to dump are in good condition.



SUMMARY: You don't need the SUM step. You don't need to unmount
the partitions, but then you should not run fsck, and you should
use -L for dump.




-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...


More information about the freebsd-questions mailing list