Freebsd – Why does slice C or slice 2 cover the entire disk

freebsdpartitionsolaris

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

Best Answer

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.

DD isn't perfect. If a disk is only 10% full you spend 90% of your time copying blocks that are "junk" or (for example) are used for "swap" (useless to be backed up). "dd" is a waste of time unless your disk is nearly full or if, for some reason, you need an exact, block-by-block, copy.

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

Someone else asked "why is it c, not the first partition, or the last". The answer is "tradition". I can only guess that Ken or Dennis (or possibly Bill Joy or Kirk McKusick) had a good reason at the time. I assume they had used the first two partition labels for actual partitions. Then one day someone had the idea of the over-lapping partition for doing backups and "c" was the next partition available. Since there were only 2-3 Unix machines at the time, doing this twice can "set the standard" that gets used for the rest of time.

Another example of how historic accidents become standards that never go way is described in this article: Understanding the bin, sbin, usr/bin , usr/sbin split