• VTOC (or EFI) is required to access slices of a disk device
  • s2 slice is used to access whole disk (including VTOC on the disk beginning)
  • new disk device comes without VTOC
  • system: Solaris 10 OS, on SPARC architecture

Question: How can it be, that format is able write VTOC to a disk if it does not have a VTOC?

Question in detail: To create VTOC, format needs to write s2. To write s2, VTOC needs to exist. Simplified: to create VTOC, VTOC needs to exist. How this chicken and egg problem is avoided by format?

ext #1: if I label an un-labeled disk (c2t5006016041E076B0d8s2), the following happens:

11157:  open("/dev/rdsk/c2t5006016041E076B0d8s2", O_RDWR|O_NDELAY) = 3
11157/1:        write(1, " D i s k   n o t   l a b".., 33)      = 33
11157/1:        read(0, 0xFF2B9CD0, 1024)       (sleeping...)
11157/1:        read(0, " y\n", 1024)                           = 2
11157/1:        open("/dev/rdsk/c3t5006016141E076B0d8s0", O_RDONLY|O_NDELAY) = 4
11157/1:        ioctl(4, 0x0417, 0xFFBFED80)                    Err#22 EINVAL
11157/1:        close(4)                                        = 0
11157/1:        ioctl(3, 0x04C9, 0xFFBFF52C)                    = 0
11157/1:        ioctl(3, 0x0402, 0xFFBFF644)                    = 0
11157/1:        ioctl(3, 0x0418, 0xFFBFF670)                    = 0
11157/1:        ioctl(3, 0x04C9, 0xFFBFF5B4)                    = 0
11157/1:        ioctl(3, 0x04C9, 0xFFBFF5B4)                    = 0
11157/1:        ioctl(3, 0x04C9, 0xFFBFF5B4)                    = 0
11157/1:        ioctl(3, 0x04C9, 0xFFBFF5B4)                    = 0
11157/1:        ioctl(3, 0x04C9, 0xFFBFF5B4)                    = 0
11157/1:        write(1, "\n\n F O R M A T   M E N".., 15)      = 15

what are those ioctl() calls? They cleanly do the job, but what are these calls actually?


The OS doesn't use read/write calls to read or write the vtoc. It just need to be able to successfully open the s2 device (which is just a symlink to the real device) to know if a disk is there. There is hopefully no need for the s2 slice to exist on the disk for this open to succeed. The format command then uses low level functions implemented in the device driver to access and write the vtoc. The ioctls you observed are precisely these calls.


  • 0x0417 = DKIOCGEXTVTOC (get extended vtoc)
  • 0x0402 = DKIOCSGEOM (set geometry)
  • 0x0418 = DKIOCSEXTVTOC (write extended vtoc to disk)
  • can you tell me how did you get the name of the syscalls from? – asdmin Nov 10 '10 at 11:00
  • /usr/include/sys/dkio.h – jlliagre Nov 10 '10 at 12:54

At the raw level, the VTOC is just another block on the disk. However, it is always in the same location. format(1m) and fmthard(1m) manipulate the disk through the raw disk device (/dev/rdsk/c...) and directly access the sectors which should contain the VTOC - if one does not exist, they simply overwrite the existing contents of that sector.

  • format writes VTOC to s2, s2 works only if VTOC is present. simplified: VTOC can only be written if VTOC exists. This answer is not an answer to my question. – asdmin Nov 5 '10 at 14:32
  • 1
    @asdmin: format writes VTOC to the 2nd and 3rd sectors of the disk. By convention VTOC disks have an s2 that spans the whole disk which encloses the VTOC. Format does not need to read the VTOC as it does not write to a slice, it writes to the disk via a lower level raw device driver. – Iain Nov 5 '10 at 16:41
  • s2 by default and including on an unformatted disk maps to sector 0 and following ones which obviously always exists. There is no need for a vtoc to exists to write a vtoc, hopefully. – jlliagre Nov 5 '10 at 16:46
  • i have checked. if I overwrite the first megabyte of s2 with zeroes, I cannot write on the disk again. Ability to write to s2 of the disk is restored by labeling the disk again. – asdmin Nov 8 '10 at 10:24

format(1M) does not need slices to work, it access the raw disk device and labels it. After the disk is labelled, the s2 slice is one way of addressing the whole disk.

On the other hand, fmthard cannot write a VTOC to a disk that isn't labelled. You have to label it first with format(1M).

I believe there is no chicken and egg problem, it's just that some utilities know to access a raw disk and write what's needed and other need more guidance with slices.

  • this answer is close to the answer I seek for. how can format access the disk without label? is there a system call for that? Please see the truss output in the question (question extended) – asdmin Nov 8 '10 at 10:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.