Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ ramdisk(HW) — OpenDesktop 1.1.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

mkfs(ADM)

mount(ADM)

mknod(C)


     RAMDISK(HW)                          UNIX System V



     Name
          ramdisk - memory block device


     Description
          The ramdisk device driver  provides  a  block  interface  to
          memory.  A  ramdisk can be used like any other block device,
          including making it into a  file  systems  using  mkfs(ADM).
          There are eight ramdisks available.

          The characteristics of a ramdisk file are determined by  its
          minor  device  number.   The bits in the minor device number
          encode its size, longevity, and which of the eight  possible
          ramdisks it is.

          The  three  low-order  bits  of  the  minor  device   number
          determine which of the eight ramdisks is being accessed.

          The next four bits of the minor device number determine  the
          size  of the ramdisk.  The size of a ramdisk must be a power
          of 2, and must be at least 16K.  Since 4 bits are available,
          there  are  16  possible sizes, starting at 16K and doubling
          every time the size indicator  is  incremented,  to  produce
          possible sizes of 16K, 32K, 64K, and up.

          The high-order bit is a longevity indicator.  If set, memory
          is  permanently  allocated  to  that  ramdisk,  and  can  be
          deallocated  only  by  rebooting  the   system.    Permanent
          ramdisks  can  only be allocated by the superuser.  However,
          once a permanent ramdisk is allocated (by  opening  it),  it
          can  be  read  and  written by anyone having the appropriate
          permissions on the ramdisk inode.

          If clear, the ramdisk is deallocated when no processes  have
          it  open.  To create an easily removable, but semi-permanent
          ramdisk, use a separate process to keep the device open  for
          as long as necessary.

          Since a complete set  of  ramdisks  (8)  would  consume  256
          inodes, only one example 16K ramdisk (/dev/ram00) is created
          when the system is installed.  The system administrator  can
          check  this  existing  file  to  determine  the major device
          number for any other required ramdisks.  All  ramdisks  will
          use the same major device number.

          The following table shows how the  minor  device  number  is
          constructed:

          _______________________________________________________________
         |           Example Minor Device Number Construction           |
         |______________________________________________________________|
         | Description       Longe-     Size (see        Ram      Minor |
         |                    vity     next table)    Disk No.    Device|
         |                                                        Number|
         |________________|________|___|___|___|___|___|___|___|________|
         | 16K (#1)       |    0   |  0|  0|  0|  0|  0|  0|  1|     1  |
         |  (Temporary)   |        |   |   |   |   |   |   |   |        |
         | 16K (#1)       |    1   |  0|  0|  0|  0|  0|  0|  1|   129  |
         |  (Permanent)   |        |   |   |   |   |   |   |   |        |
         | 64K (#0)       |    0   |  0|  0|  1|  0|  0|  0|  0|    16  |
         |  (Temporary)   |        |   |   |   |   |   |   |   |        |
         | 512K (#7)      |    1   |  0|  1|  0|  1|  1|  1|  1|   175  |
         |  (Permanent)   |        |   |   |   |   |   |   |   |        |
         |________________|________|___|___|___|___|___|___|___|________|

          The contents of the size field and the corresponding ramdisk
          size is shown in the next table.


                         ______________________________
                        |   Size Bits  |  Ramdisk Size|
                        |__|___|___|___|______________|
                        | 0|  0|  0|  0|       16K    |
                        |__|___|___|___|______________|
                        | 0|  0|  0|  1|       32K    |
                        |__|___|___|___|______________|
                        | 0|  0|  1|  0|       64K    |
                        |__|___|___|___|______________|
                        | 0|  0|  1|  1|      128K    |
                        |__|___|___|___|______________|
                        | 0|  1|  0|  0|      256K    |
                        |__|___|___|___|______________|
                        | 0|  1|  0|  1|      512K    |
                        |__|___|___|___|______________|
                        | 0|  1|  1|  0|        1M    |
                        |__|___|___|___|______________|
                        | 0|  1|  1|  1|        2M    |
                        |__|___|___|___|______________|
                        | 1|  0|  0|  0|        4M    |
                        |__|___|___|___|______________|
                        | 1|  0|  0|  1|        8M    |
                        |__|___|___|___|______________|
                        | 1|  0|  1|  0|       16M    |
                        |__|___|___|___|______________|
                        | 1|  0|  1|  1|       32M    |
                        |__|___|___|___|______________|
                        | 1|  1|  0|  0|       64M    |
                        |__|___|___|___|______________|
                        | 1|  1|  0|  1|      128M    |
                        |__|___|___|___|______________|
                        | 1|  1|  1|  0|      256M    |
                        |__|___|___|___|______________|
                        | 1|  1|  1|  1|      512M    |
                        |__|___|___|___|______________|

          To create a ramdisk, follow these steps:

          1. Create the device node.

          You must first create  the  device  that  the  ramdisk  will
          reside on.  It has the form:

               mknod device_name b_or_c major_device_number minor_device_number

          where  b_or_c  ``b'' or ``c''.  `'b'' is for blocked devices
          and is the one you will use.  The major number  will  always
          be  31.   The  minor number is derived from the table above.
          The minor number is the sum of the three attribute columns.

          Longevity:
               permanent = 128   non-permanent = 0

          Size:
          16K = 0    128K = 24   1 Meg = 48   8 Meg = 72
          32K = 8    256K = 32   2 Meg = 56   16 Meg = 80
          64K = 16   512K = 40   4 Meg = 64   32 Meg = 88

          Ram Disk number:  0 through 7 Note: There are only 8 devices
          available.   Two  different  size  devices may not share the
          same number.

          For example, to create a 64K permanent  ramdisk,  the  minor
          number could vary from 144 to 151.  If the disk number was 1
          the mknod command would be:

               mknod /dev/ram64 b 31 145

          2. Make a file system.

          This creates a file system on  the  the  ramdisk.   In  this
          example mkfs has the form:

               mkfs device_name size_of_file_in_Bsize_blocks

          In this example, the command to create  a  64K  file  system
          would be:

               mkfs /dev/ram64 64

          3. Mount the filesystem.

          This mounts the  selected  device  on  the  specified  mount
          point.  It has the form:

               mount device_name mount_point

          In order to mount  the  example  64K  ramdisk  on  /mnt  the
          command would be:

               mount /dev/ram64 /mnt

          To make a file system on a non-permanent ramdisk, the device
          file  must  be held open between the mkfs and the mount(ADM)
          operations.  Otherwise, the  ramdisk  is  allocated  at  the
          start of the mkfs command, and deallocated at its end.  Once
          the ramdisk is mounted, it is open until it is unmounted.

          The following shell fragment shows one way to use mkfs on  a
          non-permanent 512K ramdisk, then mount it:

          (       /etc/mkfs /dev/ram40 512
                  /etc/mount /dev/ram40 /mnt
          ) < /dev/ram40


     Notes
          ramdisks must occupy contiguous memory.  If free  memory  is
          fragmented,  opening a ramdisk may fail even though there is
          enough total memory available.  Ideally, all ramdisks should
          be  allocated  at  system  startup.   This helps prevent the
          ramdisks themselves from fragmenting memory.

          ramdisks are geared towards use in specialized applications.
          In  many  cases,  you  will  notice  a  decrease  in  system
          performance  when  ramdisks  are  used,  because  UNIX   can
          generally put the memory to better use elsewhere.


     Files
          /dev/ram00

     See Also
          mkfs(ADM), mount(ADM), mknod(C)


     Value Added
          ramdisk is an extension of AT&T System  V  provided  by  the
          Santa Cruz Operation.


     (printed 2/15/90)                                RAMDISK(HW)









































































































































































































































































































































































































Typewritten Software • bear@typewritten.org • Edmonds, WA 98026