RAMDISK(HW) XENIX System V RAMDISK(HW)
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(C).
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.
Page 1 (printed 8/7/87)
RAMDISK(HW) XENIX System V RAMDISK(HW)
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
use this example to determine the major device numbers for
any other required ramdisks. 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
______________________________
Page 2 (printed 8/7/87)
RAMDISK(HW) XENIX System V RAMDISK(HW)
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
______________________________
| | | | | |
Once you determine the major and minor device numbers of a
new ramdisk, make|the|appropriate device node using
mknod(C). | | | | | |
| | | | | |
To make a file|system|on a non-permanent ramdisk, the device
file must be held|open between the mkfs and the mount(C)
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 /dev/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 can generally
put the memory to better use elsewhere.
Files
/dev/ram00
See Also
mkfs(C), mount(C), mknod(C)
Page 3 (printed 8/7/87)