.TH ram "" "" "Device Driver"
.PC "Driver for manipulating RAM"
.PP
.II /dev/ram?
.II /dev/ram?close
.II "device driver^RAM"
.II "driver^RAM"
The \*(CO
.B ram
devices let you allocate and use
the random-access memory (RAM) of the computer system directly.
A typical use is for a RAM disk, which is a \*(CO file system kept in memory
rather than on a floppy disk or hard disk.
.PP
The \*(CO RAM device driver has major number 8.
You can access it either as a block-special device
or as a character-special device.
The high-order bit of the minor number gives the RAM device number (0 or 1);
as you can see, you can have no more than two RAM devices in memory at any
one time.
The low-order seven bits give the device's size in 64-kilobyte chunks.
.PP
The first call to
.B open()
on a RAM device with nonzero size (1 to 127)
allocates memory for the device;
.B open()
fails if sufficient memory is not available.
Accessing a RAM device with a minor number that specifies size zero
frees the allocated memory, provided all earlier
.B open()
calls have been closed.
.PP
Initially, \*(CO includes two block-special devices for RAM disks:
the 512-kilobyte device
.B /dev/ram0
(8, 8) and the 192-kilobyte device
.B /dev/ram1
(8, 131).
It also includes the devices
.B /dev/ram0close
(8, 0) and
.B /dev/ram1close
(8, 128).
You should resize the RAM devices
to suit the amount of memory available on your system.
.SH Examples
The following example formats and mounts a 512-kilobyte RAM disk on directory
.BR /fast .
.DM
	mkdir /fast
	/etc/mkfs /dev/ram0 1024
	/etc/mount /dev/ram0 /fast
.DE
.PP
When the RAM disk is no longer needed,
its allocated memory can be freed as follows:
.DM
	/etc/umount /dev/ram0
	cat /dev/null >/dev/rram0close
.DE
.PP
The next example replaces the default
.B /dev/ram0
with a one-megabyte device that contains a \*(CO file system.
The minor number 16 specifies RAM device 0 and a size of one megabyte
(i.e., 16 chunks of 64 kilobytes each).
The new RAM device contains 2,048 blocks of 512 bytes each.
.DM
	rm /dev/ram0
	/etc/mknod /dev/ram0 b 8 16
	/etc/mknod /dev/rram0 c 8 16
	/etc/mkfs /dev/ram0 2048
	chmod ugo=rw /dev/ram0
	chmod ugo=rw /dev/rram0
.DE
.PP
The command
.B chmod
is necessary to make the new RAM drive accessible.
.SH Files
.B /dev/ram*
.SH "See Also"
.Xr "compress," compress
.Xr "device drivers," device_dr
.Xr "fsck," fsck
.Xr "mkfs," mkfs
.Xr "mount," mount
.Xr "ramdisk," ramdisk
.Xr "umount," umount
.Xr "uncompress," uncompres
.Xr "zcat" zcat
.SH Notes
Moving frequently used commands or files to a RAM disk
can improve system performance substantially.
However, the contents of a RAM device are lost if the
system loses power, reboots, or crashes.
Therefore, you should frequently back up files
from the RAM disk to a more permanent medium.
.PP
If a RAM device uses most but not all available system memory, its
.B open()
call will succeed but subsequent commands may fail
because insufficient memory remains for the system.
.PP
.II "ram1"
The \*(CO installation program
.B /etc/build
uses RAM device
.B /dev/ram1
as a RAM disk during installation.
Commands
.BR compress ,
.BR uncompress ,
.BR zcat ,
and
.B fsck
sometimes use
.B /dev/ram1
as a temporary storage device.
Users should avoid using
.B /dev/ram1
as a RAM disk because of these programs.
In addition, users of
.BR compress ,
.BR uncompress ,
and
.B zcat
may have to change the size of
.B /dev/ram1
from the default size of 192 to 512 kilobytes, to handle
files compressed to 16 bits.
The following script makes this change; note that it must be run by the
superuser
.BR root :
.DM
	cat /dev/null >/dev/rram1close
	rm /dev/ram1 /dev/rram1
	mknod /dev/ram1  b 8 136
	mknod /dev/rram1 c 8 136
.DE
