dd command and which drive

Hi,

I created an image on NetBSD with dd if=/dev/wd1d | gzip -9 > /storage/backup.img.gz. I was able to install it on the second drive in a server with CentOS with gunzip -c backup.img.gz | dd of=/dev/sdb. I have tried both gunzip -c backup.img.gz | dd of=/dev/ada1 and gunzip -c backup.img.gz | dd of=/dev/ad6 and it doesn't work. The second drive is not bootable. Any ideas of what I am doing wrong?

Kind Regards,
Steve
 
Are you talking about installing the image on a NetBSD drive or a FreeBSD drive? In NetBSD I specify the entire "raw" drive as described in this wiki. FreeBSD uses a different syntax.
 
Hello,

This is the command on ran on the NetBSD system to create the image.
dd if=/dev/rwd1d | gzip -9 > /storage/backup.img.gz
(I typed this in wrong before. It should have been if=/dev/rwd1d) So, it used the raw device and everything seemed to work fine.

On CentOS server I ran:
gunzip -c backup.img.gz | dd of=/dev/sdb
After several hours, it finished and I was able to boot from the second drive on that system.

I used the same image that I created on the NetBSD system.
On FreeBSD I ran:
gunzip -c backup.img.gz | dd of=/dev/ada1
and I also tried:
gunzip -c backup.img.gz | dd of=/dev/ad6

But the second drive in the FreeBSD system is not bootable. It just hangs before anything comes on the screen.

Thanks,
Steve
 
From dmesg:
Code:
ada0 at ahcich0 bus 0 scbus0 target 0 lun 0
ada0: <SanDisk SDSSDXP480G R1311> ATA-8 SATA 3.x device
ada0: Serial Number 132716400283
ada0: 300.000MB/s transfers (SATA 2.x, UDMA6, PIO 512bytes)
ada0: Command Queueing enabled
ada0: 457862MB (937703088 512 byte sectors: 16H 63S/T 16383C)
ada0: Previously was known as ad4
ada1 at ahcich1 bus 0 scbus1 target 0 lun 0
ada1: <SanDisk SDSSDXP480G R1311> ATA-8 SATA 3.x device
ada1: Serial Number 133361400860
ada1: 300.000MB/s transfers (SATA 2.x, UDMA6, PIO 512bytes)
ada1: Command Queueing enabled
ada1: 457862MB (937703088 512 byte sectors: 16H 63S/T 16383C)
ada1: Previously was known as ad6
GEOM: ada1s1: invalid disklabel.
Trying to mount root from ufs:/dev/ada0p2 [rw]...

From fstab:
Code:
# Device        Mountpoint      FStype  Options Dump    Pass#
/dev/ada0p2     /               ufs     rw      1       1
/dev/ada0p3     none            swap    sw      0       0
 
This is about FreeBSD. I must admit that I am a bit frustrated because this worked everywhere else I tried it, just not on FreeBSD (I could create an image with dd on one OS and then use dd with a different OS to restore it to a hard drive). Really, the question should have been asked differently, so I will try to do that now.

First, question is in FreeBSD, what are the device names for hard drives? It looks like ada? What device should an image be written to in FreeBSD, if I wanted to write to the entire drive (in this case the second hard drive)?

Second, what is the block size used by default with dd on FreeBSD and is it different than other unix like OSs? If the image was created with a different block size than what it is being restored to the hard drive with, will this make the data on the drive corrupt?

Third, the other thing I notice is that ada1s1 says it has an invalid disklabel. I don't understand how it can boot without a valid disklabel. I tried to look at his with bsdlabel, but I am not sure what I am looking at.

I have tried asking on other list and everyone has been helpful, but really they don't know FreeBSD, so I am asking here. I know this may sound like an exercise in futility, but I would really appreciate any help I can get.
 
First, question is in FreeBSD, what are the device names for hard drives? It looks like ada? What device should an image be written to in FreeBSD, if I wanted to write to the entire drive (in this case the second hard drive)?
da(4), ada(4), mfid and a few other possibilities depending on the type of driver and controller. And there's no choice on FreeBSD, there are no "raw" devices or something similar. There's a drive, nothing more.

Second, what is the block size used by default with dd on FreeBSD and is it different than other unix like OSs?
Code:
     The dd utility copies the standard input to the standard output.  Input
     data is read and written in 512-byte blocks.
See dd(1)

If the image was created with a different block size than what it is being restored to the hard drive with, will this make the data on the drive corrupt?
No, it just means how many blocks are written in one go. It doesn't matter if you have 4 writes of 512 byte blocks or a single write with a 2K block, it's still the same amount of data. The blocksize parameter of dd(1) has no relation to the (physical) blocksize of the disk.

Third, the other thing I notice is that ada1s1 says it has an invalid disklabel.
It's a slice, which is an MS-DOS/BIOS partition. It doesn't require a bsdlabel. Besides that, your output shows ada1p1, not ada1s1. There is a difference (GPT vs. MBR).
 
Please stop using dd(1) to copy drives. It is brute-force and does not understand the data being copied, leading to partitioning and other problems. If you must use it, realize it has numerous ways to go wrong, and at least use a 64K blocksize to avoid overhead.
 
Back
Top