Reading raw disk on Solaris

Hello

I wonder if someone could help me in reading a raw (non-Solaris) disk on a Solaris system...

I have an IDE HDD in my Sun Blade and would like to read it (using C). It appears on the system and with the format command shows up as c0t1d0.

I use the dd command to read the disk as such:

rhino# dd if=/dev/dsk/c0t1d0s0 bs=1 skip=0 count=1024
dd: /dev/dsk/c0t1d0s0: open: I/O error
rhino# dd if=/dev/dsk/c0t1d0s2 bs=1 skip=0 count=1024
dd: /dev/dsk/c0t1d0s2: open: I/O error

but as you can see I get an error.

How do I read a raw, unformatted, non-Solaris disk in my Solaris box?

Any ideas appreciated...

try "/dev/rdsk/c0t1d0s0"?

There are two forms of disk devices, block and raw.

Sorry forgot to say I tried that as well, and no, that doesn't work either.

Try a block size (bs) that matches the drives block size. With a disk it should be multiples of 512.

I haven't tried it, but the point is that it is a raw disk - i.e. FS unknown... so things such as 'blocksize' does not exist or unknown...

I just need to open the device... in a C program... like in Linux the HDD devices are /dev/sda, /dev/hda, etc...

If you are on a sparc box and you want to read a disk you use the backup slice (s2) - this is as opposed to a raw slice.

Also you need to be root to do this.

Yup (from above) doing this:

rhino# dd if=/dev/dsk/c0t1d0s0 bs=1 skip=0 count=1024
dd: /dev/dsk/c0t1d0s0: open: I/O error
rhino# dd if=/dev/dsk/c0t1d0s2 bs=1 skip=0 count=1024
dd: /dev/dsk/c0t1d0s2: open: I/O error

The same with /dev/rdsk result in the same error, and yes I am root...

Are you are certain that you are looking at the right disk and not the cd/dvd drive ?

Yup:

rhino# iostat -En
c0t1d0           Soft Errors: 0 Hard Errors: 0 Transport Errors: 0 
Model: ST3160022ACE     Revision: 9.51     Serial No: 5JS7STTP         
Size: 137.44GB <137438952960 bytes>
Media Error: 0 Device Not Ready: 0  No Device: 0 Recoverable: 0 
Illegal Request: 0 
c0t0d0           Soft Errors: 0 Hard Errors: 0 Transport Errors: 0 
Model: ST3120026A       Revision: 8.01     Serial No: 4JT0VLFZ         
Size: 120.03GB <120034123776 bytes>
Media Error: 0 Device Not Ready: 0  No Device: 0 Recoverable: 0 
Illegal Request: 0 
c0t2d0           Soft Errors: 1 Hard Errors: 0 Transport Errors: 0 
Vendor: TSSTcorp Product: CDW/DVD TS-H492C Revision: SI00 Serial No:  
Size: 0.00GB <0 bytes>
Media Error: 0 Device Not Ready: 0 No Device: 0 Recoverable: 0 
Illegal Request: 1 Predictive Failure Analysis: 0

I will try another 'raw' disk in case there is a problem with this one...

I am not referring to cluster sizes, I am refering to how SCSI controllers read disks, they read multiples of sectors.

And as you say, you haven't tried it.

Hi porter, I appreciate your responses... but I feel you are barking up the wrong tree here.

I have now put in a smaller HDD (came out of a Sun box originally) and here are the results:

rhino# iostat -En
c0t1d0           Soft Errors: 0 Hard Errors: 0 Transport Errors: 0 
Model: ST340016A        Revision: 3.10     Serial No: 3HS1Z16S         
Size: 40.02GB <40020664320 bytes>
Media Error: 0 Device Not Ready: 0  No Device: 0 Recoverable: 0 
Illegal Request: 0 
c0t0d0           Soft Errors: 0 Hard Errors: 0 Transport Errors: 0 
Model: ST3120026A       Revision: 8.01     Serial No: 4JT0VLFZ         
Size: 120.03GB <120034123776 bytes>
Media Error: 0 Device Not Ready: 0  No Device: 0 Recoverable: 0 
Illegal Request: 0 
c0t2d0           Soft Errors: 1 Hard Errors: 0 Transport Errors: 0 
Vendor: TSSTcorp Product: CDW/DVD TS-H492C Revision: SI00 Serial No:  
Size: 0.00GB <0 bytes>
Media Error: 0 Device Not Ready: 0 No Device: 0 Recoverable: 0 
Illegal Request: 1 Predictive Failure Analysis: 0 
rhino# format
Searching for disks...done
 
 
AVAILABLE DISK SELECTIONS:
       0. c0t0d0 <ST3120026A cyl 57459 alt 2 hd 16 sec 255>
          /pci@1e,600000/ide@d/dad@0,0
       1. c0t1d0 <DEFAULT cyl 19156 alt 2 hd 16 sec 255>
          /pci@1e,600000/ide@d/dad@1,0
Specify disk (enter its number): ^D

rhino# dd if=/dev/dsk/c0t1d0s0 bs=512 skip=0 count=1024
dd: /dev/dsk/c0t1d0s0: open: I/O error
rhino# dd if=/dev/dsk/c0t1d0s2 bs=512 skip=0 count=1024
dd: /dev/dsk/c0t1d0s2: open: I/O error
rhino# dd if=/dev/rdsk/c0t1d0s0 bs=512 skip=0 count=1024
dd: /dev/rdsk/c0t1d0s0: open: I/O error
rhino# dd if=/dev/rdsk/c0t1d0s2 bs=512 skip=0 count=1024
dd: /dev/rdsk/c0t1d0s2: open: I/O error
rhino# 

Still the same problems. Any more ideas?

Maybe you could tell dd where you want to send the output ?

Got it to work now... It looks like I have to LABEL the disk!

When you put a disk in a Solaris box that is not a Solaris disk - it reports the disk as having a corrupt label...

If use format and then label the disk it then seems to then allow access using dd... (if I then use dd to zero the disk, the label info is lost.)

Can anyone tell me what/where the Solaris disk label is? How big is it, what info, etc?

Obviously I don't want to write info onto the disk if that info is going to corrupt whatever system the 'raw' disk came out of! I just want to put it into a Solaris system to enable it to be analysed (by extracting the data off).

I will try coding some C to access the disk and see if this is any more succesful or whether it has to be labelled...

You may be able to access the disk from the /devices path to the device. It is not by any means certain, but it might work.

Close, but:

rhino# dd if=/devices/pci@1e,600000/ide@d/dad@1,0 bs=1 skip=0 count=1024
read: Is a directory
0+0 records in
0+0 records out

rhino# ls -la /devices/pci@1e,600000/ide@d/dad@1,0
total 4
drwxr-xr-x   2 root     sys          512 Dec 18  2006 .
drwxr-xr-x   5 root     sys          512 Dec 18  2006 ..

You onlt chose the path containing the device, you need to use the full path to the actual device.

Go on give me a hint :wink: what would be the full path of the device? I thought that (/devices/pci@1e,600000/ide@d/dad@1,0) was it...

rhino# ls -l /dev/dsk/c0t1d0s0
lrwxrwxrwx 1 root root 43 Dec 6 2006 /dev/dsk/c0t1d0s0 -> ../../devices/pci@1e,600000/ide@d/dad@1,0:a

rhino# dd if=/devices/pci@1e,600000/ide@d/dad@1,0:a bs=1 skip=0 count=1024 | od -x
dd: /devices/pci@1e,600000/ide@d/dad@1,0:a: open: I/O error
0000000
rhino# 

I still get an error accessing this HDD if there is no label on it. Unfortunately the HDD I am trying to analyse has data where Solaris wants to write this label...

Any more ideas anyone?

Please try to switch the "bs" and "count" values like:

dd if=<your device> of=<outputfile> bs=1024 count=1

perhaps this was the issue.

Regards,
Marian

Nice try :wink:

Although it looks like a dd error... it is not. The error is accessing the device via the handle... The Solaris box can not read HDD that has no LABEL it can identify (i.e. a Sun 'format' label)..