Friday, January 28, 2011

Historical Question: Why does slice C or slice 2 cover the entire disk

Something that I was discussing with a couple of friends and we were unable to figure it out. In FreeBSD and OpenSolaris/Solaris when you partition a drive a partition is created that covers the whole disk:

da0s1c
c0d0s2

For example, the output of my main hard drive in my OpenSolaris server:

xistence@Keyhole.network.lan:/dev/rdsk# prtvtoc /dev/rdsk/c4d0s2
* /dev/rdsk/c4d0s2 partition map
*
* Dimensions:
*     512 bytes/sector
*      63 sectors/track
*     255 tracks/cylinder
*   16065 sectors/cylinder
*    7296 cylinders
*    7294 accessible cylinders
*
* Flags:
*   1: unmountable
*  10: read-only
*
* Unallocated space:
*       First     Sector    Last
*       Sector     Count    Sector 
*           0     16065     16064
*
*                          First     Sector    Last
* Partition  Tag  Flags    Sector     Count    Sector  Mount Directory
       0      2    00      16065 117145980 117162044
       2      5    01          0 117178110 117178109
       8      1    01          0     16065     16064

What was the reasoning behind using partition 2? Why not partition 0? Where in the history of unix was this decided? What legacy feature did it serve at that point in time? With GPT partitioning that goes away entirely (from what I have found).

Just something interesting ...

Since ParoX mentioned GPT style partitioning and how Solaris represents that in terms of vtoc layout, here is the output from one of my disks that is 1 TB and is in a ZFS array, and has automatically been set up with GPT:

xistence@Keyhole.network.lan:~# prtvtoc /dev/rdsk/c5d0
* /dev/rdsk/c5d0 partition map
*
* Dimensions:
*     512 bytes/sector
* 1953520128 sectors
* 1953520061 accessible sectors
*
* Flags:
*   1: unmountable
*  10: read-only
*
* Unallocated space:
*       First     Sector    Last
*       Sector     Count    Sector 
*          34       222       255
*
*                          First     Sector    Last
* Partition  Tag  Flags    Sector     Count    Sector  Mount Directory
       0      4    00        256 1953503455 1953503710
       8     11    00  1953503711     16384 1953520094
  • It's a result of the slices traditionally being laid out as follows:

    s0: root
    s1: swap
    s2: bkup

    They assigned the most important thing to the first slice and continued with decreasing importance :) (Who needs swap if you have no root partition? Further, who needs to backup anything if you have no data.)

    I don't know when exactly this was decided upon (probably fairly early on; whenever the Solaris devs decided to use Solaris-style disk identifiers and slices.)

    The problem goes away with GPT since the MBR style partition scheme is not applicable. (Though I'm personally not familiar with how Solaris represents GPT partitions...)

    Hope this helped XD


    ================
    Edit:
    Now you've got me interested. I'll post a few links I found just before I head off to work.

    Solaris 2.4 Sysadmin answer book: Customary slices
    Solaris 2.4 User Guide: Peripheral Administration

    Both these docs are circa 1994 and they define the creation of s2 as integrated into 'format' even then. Gotta keep digging XD!

    X-Istence : It helps, but is still not the concrete answer I was looking for :-) I already knew possible reasons as to why, and the default slice layout. I would like solid evidence or proof!
    X-Istence : Happy to drag someone else into the madness that is this question :-).
    ParoX : Ok... The concept of slices seems to have originated somewhere around the releases of BSD 4.2 and Unix System V.4 (1984-1989)... Time to hit up the library >.< (There wasn't much internet logging at that time for obvious reasons.)
    ParoX : http://docsrv.sco.com/cgi-bin/man/man?vtoc+7 Apparently UnixWare uses s0 as the entire partition with s1 and s2 as root and swap respectively. Interesting...
    ParoX : I'm narrowing this down to the introduction of UFS in 1982 in the BSD tree. I'm now quite confident that SVR borrowed the concept from BSD in its 4.2 Release (after rummaging through a ton of old programmer's references.) I'll hit up the library again tomorrow lol
    David : Sounds like a question for Marshall McKusick, the fella behind so much of UFS and FFS...
    From ParoX
  • More information about this question:

    According to http://en.wikipedia.org/wiki/BSD_disklabel on FreeBSD the c partition on a disk that is also in use by other operating systems will only extend onto the entire FreeBSD slice, and partition d would be the entire hard drive!

    The c partition addresses the entire disk in dedicated mode, or the entire FreeBSD slice in slice mode. The other partitions are for general use.

    FreeBSD Manual Disk Adding see 18.3.1 number 3.

    From X-Istence
  • Back in the old days we would do backups using "dd" of the entire disk. Therefore, we had the "c" slice so that we could do it all with one command.

    That's why the "c" slice exists.

    Of course, if a disk is only 10% full you spend 90% of your time copying blocks that will never be used. Backing up swap is virtually useless. "dd" is a waste of time unless you really want to copy block-by-block.

    This was all before RAID-0 disk mirroring and volume managers did all that kind of partition copying for you.

    (Someone mentioned "dump" on the "c" slice. That won't work. "dump" is a file-by-file copy [actually, inode by inode] so that won't work.)

    Cristian Ciupitu : Yes, but why *c* and not *a*?
    TomOnTime : Why was that letter chosen? I don't know. Either Ritchie, Thompson, or maybe Bill Joy could answer that. My guess is that they used 0, then 1, then someone has this brilliant idea of an overlapping partition label. The next slot was available, and a lot safer than moving partitions around. Remember... this was when entire universities had 1 or 2 computers. You did major system changes rarely. It wasn't like today where if you were making a change like this you would freely re-imagine your machines. With 50 people all sharing one computer, upgrades wait until everyone is ready.
    From TomOnTime
  • Why was scsi id 3 your default boot disk in vintage Sun OS?

    All those moments will be lost in time, like tears in rain.

0 comments:

Post a Comment