[geeks] Raw disk access under Solaris
Jonathan Patschke
jp at celestrion.net
Fri Sep 16 12:46:02 CDT 2016
On Thu, 15 Sep 2016, JP Hindin wrote:
> My understanding is the blocksize of the filesystem is irrelevant - I'm
> doing a raw copy (or, rather, I'm _attempting_) and effectively all I'm
> asking is for the disk to feed the bytes directly from sector 0 right
> through until the last sector.
I wouldn't be so sure about that.
https://github.com/OpenIndiana/illumos-gate/blob/master/usr/src/uts/common/io/scsi/targets/sd.c
Near line 30620:
* 5. Supported blocksizes of target devices
*
* Sd supports non-512-byte blocksize for removable media devices only.
* For other devices, only 512-byte blocksize is supported. This may be
* changed in near future because some RAID devices require non-512-byte
* blocksize
Disks don't serve bytes; they serve blocks.
> So as I was saying, _format_ uses: /devices/sbus at 1f,0/QLGC,isp at 3,10000/sd1,0
>
> Great, raw disk, no partitions? Eeeeexcept this doesn't exist.
Nope, it doesn't. Code in usr/src/cmd/format/startup.c truncates device
names at the first colon. You're seeing a pretty-printed version of the
device name.
> So I still have no idea how on earth 'format' does its magic.
Reading the source for format (in usr/src/cmd/format/startup.c) indicates
that it just calls open() on the device (specifically, the *s2 slice),
leaving the kernel to handle the details. If that fails, code in
auto_sense.c will issue a generic SCSI command to guess the disk geometry
to build a pseudo-VTOC for format's use.
Note also the comment just above there (in the kernel source) where it
says the sd driver creates an in-memory default VTOC if none is present on
disk, provided you're using x86. Since you're on SPARC, you don't get
this benefit.
This says to me that you probably need to use another platform to solve
this problem. Try netbooting a BSD and see if you can dd the raw device
to /dev/null just to exercise it. If that fails, you probably have a
strange block size.
--
Jonathan Patschke
Austin, TX
USA
More information about the geeks
mailing list