11 Replies Latest reply on Aug 6, 2007 9:05 PM by user4994457

    Reading raw disk on Solaris

    807559
      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...
        • 1. Re: Reading raw disk on Solaris
          807559
          did you try using the raw device instead of the block device as you listed?

          dd if=/dev/rdsk/c0t1d0s0 bs=1 skip=0 count=1024
          and
          dd if=/dev/rdsk/c0t1d0s2 bs=1 skip=0 count=1024

          jeff
          • 2. Re: Reading raw disk on Solaris
            807559
            Yeah, sorry, forgot to say that. I did try it as well and it gives the same result. I just need to open the device... in a C program... like in Linux the HDD devices are /dev/sda, /dev/hda, etc... and Mac OS X give /dev/disk0, /dev/disk1, etc which works!
            • 3. Re: Reading raw disk on Solaris
              807559
              if you have a device that's listed in format (or rmformat for that matter) - you should be able to do a prtvtoc on the backup slice (the s2 entry) and then from there for any of the listed slices do a dd

              if one or more of them are failing, then that sounds like a problem -

              when you added the HDD to your system, did you ensure that the jumper is set in the "cable select" position?

              post a format results (echo | format) to ensure its there first before we try to dd from a device that's not being recognized - jeff

              edit - I haven't done the look yet, but I thought there was some OBP limitation to the size of IDE drive that was supported in the SunBlade hardware set - a quick search on sunsolve should reveal, I just haven't had the time to do so yet
              • 4. Re: Reading raw disk on Solaris
                807559
                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
                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 65533 alt 2 hd 16 sec 255>
                /pci@1e,600000/ide@d/dad@1,0
                Specify disk (enter its number):


                It is an 160Gb Seagate CE drive. I will try another 'raw' disk (of smaller size too) in the SunBlade 1500 to see if there is an issue with the particular disk...
                • 5. Re: Reading raw disk on Solaris
                  807559
                  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?
                  • 6. Re: Reading raw disk on Solaris
                    807559
                    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...
                    • 7. Re: Reading raw disk on Solaris
                      user4994457
                      The problem is that the sd driver doesn't talk to disks without a valid Solaris VTOC.

                      The label is one sector (block 0 on the disk). That's what is written by format when you do a 'label'.

                      Presumably you could use a generic scsi driver instead of the 'sd' driver to read blocks directly.

                      --
                      Darren
                      • 8. Re: Reading raw disk on Solaris
                        807559
                        Thanks for the reply. Someone suggested that I access the device directly (from the /devices directory?) but I don't know what this is...

                        I thought it was /pci@1e,600000/ide@d/dad@1,0 but this is an empty directory...

                        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 ..

                        Anyone know what the direct path to the device would be?
                        • 9. Re: Reading raw disk on Solaris
                          user4994457
                          Devices are just entry points for a driver. You can't communicate "directly" with hardware, there must be a driver.

                          The path you're trying to use is for the 'dad' driver, used for SPARC IDE access. There's a man page where you can see that it will create nicer names as /dev/dsk and /dev/rdsk. So this is the same device you're trying to use earlier, just a more complex name.

                          On my machine for instance (yours should be similar):
                          % ls -l /dev/dsk/c0t0d0s0
                          lrwxrwxrwx 1 root root 46 Nov 16 2005 /dev/dsk/c0t0d0s0 -> ../../devices/pci@1f,0/pci@1,1/ide@3/dad@0,0:a

                          --
                          Darren
                          • 10. Re: Reading raw disk on Solaris
                            807559
                            I don't see why a disk driver would need to write a label on it before it would work...

                            Anyway:
                            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... I am beginning to think that Solaris is not such a great platform to develop on now (as even Linux and MacOSX manage to let you access disk devices in the way you would expect to be able to.)
                            • 11. Re: Reading raw disk on Solaris
                              user4994457
                              I don't see why a disk driver would need to write a
                              label on it before it would work...
                              Because that's how it was written.

                              The 'sd' driver only gives you access to individual slices/partitions on the disk. Until the label is present, none of those slices are defined.
                              Anyway:
                              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...
                              Correct. If you want to do it without a label, you must use an alternate driver. Not the dad/sd driver.
                              Any more ideas anyone... I am beginning to think that
                              Solaris is not such a great platform to develop on
                              now (as even Linux and MacOSX manage to let you
                              access disk devices in the way you would expect to be
                              able to.)
                              SPARC and x86 are different. The x86 driver does allow for access of the disk outside the Solaris label, but the SPARC driver does not. 99.9% of the time, no one cares about this limitation.

                              The 'sgen' driver is a generic scsi driver. I haven't tried to use it, but it should give access to the raw device without a label. You'll need to modify /kernel/drv/sgen.conf and reload the driver. There is a man page for it.

                              --
                              Darren