[OT] raw-disks && cooked-disks ?

Wilkinson,Alex Alex.Wilkinson at dsto.defence.gov.au
Fri Feb 22 11:37:45 CST 2002

Thanks Glen.

 - aW

On Thu, 21 Feb 2002, Glen Turner wrote:

glen.t:>>On Thu, 21 Feb 2002, Wilkinson,Alex wrote:
glen.t:>>> What I don't know and find confusing is the difference between mkfs on either a
glen.t:>>> raw disk or a cooked disk.
glen.t:>>Traditional UNIXen have
glen.t:>> - a raw device.  Byte 0 is the first byte on the disk.
glen.t:>> - a cooked device, better thought of as a 'formatted' device.  Byte 0
glen.t:>>   is the first byte on the device that is available to user data.
glen.t:>>Think of a tape drive with a compulsory tape label.  Writing to byte 0 of
glen.t:>>the raw tape device will overwrite the first byte of the label, but
glen.t:>>writing to byte 0 of the cooked tape device will write to the first byte
glen.t:>>after the label (that is, the first byte of user data).
glen.t:>>So we use the cooked device name as input to applications like 'tar', as
glen.t:>>we are writing user data.  But we use the raw device name as input to
glen.t:>>'label', as we are writing the tape's system data.
glen.t:>>For disks the distinction gets fuzzier.  After all you access disks by
glen.t:>>filename, not by byte offset.  But you can see how 'mkfs', with its need
glen.t:>>to write superblocks and i-nodes and all sorts of other system stuff,
glen.t:>>needs the raw device name.
glen.t:>>Linux broke with the UNIXen tradition and did away with raw devices.
glen.t:>>After all, as we noticed they aren't really needed for using disks and
glen.t:>>Linux was a IBM PC based operating system without an old-fashioned
glen.t:>>compulsory-label tape drive in sight.  So when you use mkfs on Linux you
glen.t:>>give the name of the cooked device.
glen.t:>>It turns out that not needing raw devices is only sort-of-true.
glen.t:>>User-space filesystems need access to the raw disk device, just like
glen.t:>>kernel filesystems have.  And databases like Oracle work fastest when they
glen.t:>>use their own filesystem.  So later Linux did add raw devices, but in a
glen.t:>>completely different way to all other UNIXen.  Ouch.
glen.t:>>> Why does mkfs only work /dev/rdsk/... on IRIX but on others it can
glen.t:>>> work with /dev/dsk/...?
glen.t:>>Because this is such a common error and the distinction between raw
glen.t:>>devices and cooked devices is so minor for disks that the program should
glen.t:>>really accept either name and format the disk.  Anything else is just
glen.t:>>> I know that raw disks are character devices and cooked disks are block
glen.t:>>> devices and that by running mkfs on a disk we are creating the
glen.t:>>> a fs with a specfic block size and layout etc...
glen.t:>>Whoa.  Devices are classified into character or block.  Think of it as:
glen.t:>>Character devices can only be accessed serially (read character 1, read
glen.t:>>character 2).  With Block devices any block can be retrieved (give me
glen.t:>>block 10 now, without reading block 1,2,3,...,7,8,9 first).
glen.t:>>*Access methods* in UNIX are cooked or raw.  In traditional UNIXen the
glen.t:>>access method is indicated by which device you use.  This isn't the only
glen.t:>>alternative: Linux uses an ioctl() directive to set the access method; on
glen.t:>>IBM mainframes you link in differing I/O libraries; VMS has a whole raft
glen.t:>>of access methods, you select the one you want when you OPEN the file.
glen.t:>>> But I would have thought you could only create a fs on a character disk ?
glen.t:>>You can create a filesystem on blocked or character devices.  Blocked
glen.t:>>devices such as disks are by far the most common in these times.  But
glen.t:>>newer tape technologies are formatted with a filesystem and accessed
glen.t:>>by filename just like disks are.
glen.t:>>The Linux kernel has really good filesystem support.  Almost anything that
glen.t:>>can be named can be turned into a filesystem.  smbfs and NFS are
glen.t:>>filesystems that send bytes over a network rather than access disk. davfs
glen.t:>>can be used to access web sites.  Linux itself has a filesystem that is
glen.t:>>used to access the kernel's confguration and counters (procfs, which is
glen.t:>>usually mounted at /proc).
glen.t:>>So the filesystem these days isn't really thought of as being restricted
glen.t:>>to any device type.
glen.t:>>Glen Turner                                 Network Engineer
glen.t:>> (08) 8303 3936      Australian Academic and Research Network
glen.t:>> glen.turner at aarnet.edu.au          http://www.aarnet.edu.au/
glen.t:>> The revolution will not be televised, it will be digitised

LinuxSA WWW: http://www.linuxsa.org.au/  IRC: #linuxsa on irc.linux.org.au
To unsubscribe from the LinuxSA list:
  mail linuxsa-request at linuxsa.org.au with "unsubscribe" as the subject

More information about the linuxsa mailing list