# disklabel -z equivalent for FreeBSD ?



## o0larry0o (Jul 15, 2012)

Hi everyone,

I'm trying to do a raw copy with dd from one disk to another.
But unfortunately the dd command is failling :
dd: /ada3: Read-only file system

ada3 is my destination drive.

I tried several options, I created a partition and filesystem, mounted the drive, was able to create a folder, but still the same issue.

I also tried to destroy everything by doing "gpart destroy ada3" still no luck.

ater googling a while I found out this on a dd man page:

 1.  [Tru64 UNIX]  To copy to a raw disk, the disk label must first be
       zeroed using the disklabel -z command.  For example:
	    disklabel -z /dev/disk/dsk1

       [Tru64 UNIX]  If you do not zero out the disk label, dd fails with the
       following error message:
	    dd write error: Read-only file system


I would like to give this a try, but I cannot find any equivalent with "bsdlabel" on my FreeBSD 9.0.

Any thoughts to help me ?

Thanks.


----------



## tingo (Jul 15, 2012)

From what you have written above, you are trying to write to a *filesystem* called /ada3. It is not clear if this filesystem has anything to do with the ada3 drive you mention (which would be /dev/ada3). Please provide the output of the `$ mount` command.
Note: you don't have to mount a drive to a filesystem if you want to write to it with dd. You can write to the drive directly, like this
`# dd if=/some/file of=/dev/ada3 bs=...`
Just make sure that you are writing to the correct drive, or you will wipe out data you care about.


----------



## wblock@ (Jul 15, 2012)

Additionally: dd(1) is a poor way to copy a drive.  Even if the target drive is exactly the same size as the source drive, a lot of unoccupied sectors are copied.  If the target drive is larger than the source, space is wasted because the partitioning can't be changed.  The target drive can't be smaller than the source, even if the source drive is not full.  Other methods like dump(8)/restore(8) can be much better.  It depends on which filesystem is used.

If dd(1) is the only option, see http://forums.freebsd.org/showpost.php?p=115526&postcount=9 about making it as fast as possible.


----------



## o0larry0o (Jul 15, 2012)

Both drive are exactly the same (same model), and I really need to do a raw copy.
(see my other thread here  http://forums.freebsd.org/showthread.php?t=32571)

The drive is not mounted, and as I said I tried to mount it and create a file system on it which was writable, but still dd could not write on it.
after that I destroyed the file system. Still couldn't write on it.

I don't care about what's on that drive so I started to zero it out. The process is still ongoing. I will see after that if dd is able to write from my main HDD to the new one.


----------



## wblock@ (Jul 15, 2012)

If zeros can be written to the drive, it shows the drive is writable.  Please show the exact commands you are using.


----------



## Sebulon (Jul 15, 2012)

Ah heck, my bad! It's a typo in the command. I've gone back and corrected it.

@o0larry0o

I missed "/dev/" from pointing to the target(of) drives, but you have to understand that it is only an example command. Never just copy/paste a command like that without thinking about what it actually does to *your* system. If you aren't 100% sure that ada3,4- and 5 are the new drives, you may end up writing zeros over the data you want to back up!

/Sebulon


----------



## o0larry0o (Jul 15, 2012)

I figured it out on my own 3 minutes ago ...
but the strange thing is that I have 3 drives to copy, and the first one worked perfectly with of=/ada3 ...I don't get it .. well I just wasted 3 hours of writing zero on this drive lol.

Thanks for your help
I'll be back soon enough on my other thread for the rest of the story


----------

