Many of the applications found within the NST distribution require Read/Write file system capability. A widely used script for the creation of additional RAM disk based file systems that satisfies this need was build. The create_ramdisk script will setup a RAM disk file system up to a default maximum size of 2GigaBytes (NST v1.0.5 and above).
When you use the create_ramdisk make sure you have sufficient available RAM for the file system. Use the system utility free to help you determine information about free and used memory on your system.
The following caption depicts how one uses the create_ramdisk script:
[root@probe root]#
/root/bin/create_ramdisk -h
Usage: create_ramdisk [-v] -s <size in MB> -d <RAM device> [-m <mount point>] [-h]
This script creates a user specified RAM disk of size: "-s <size in MB>" using RAM
device: "-d <RAM device>" at a default or user specified mount point
"[-m <mount point>]".
-s <size in MB> | --size <size in MB>
RAM disk size in Mega Bytes (MB).
-d <RAM device> | --ram-device <RAM device>
RAM device to use for this RAM disk. NST will use the corresponding mount points
for the selected RAM device if no user mount point "[-m <mount point>]" is
specified:
/dev/ram2 => Mount point: /mnt/ram2 /dev/ram3 => Mount point: /mnt/ram3
/dev/ram4 => Mount point: /mnt/ram4 /dev/ram5 => Mount point: /mnt/ram5
/dev/ram6 => Mount point: /mnt/ram6 /dev/ram7 => Mount point: /mnt/ram7
/dev/ram8 => Mount point: /mnt/ram8 /dev/ram9 => Mount point: /mnt/ram9
-m <mount point> | --mount-point <mount point>
Optional parameter to specify a mount point directory for the RAM device. If this
parameter is not used, then one of the above default mount points will be used.
Example: -m /data1
-v | --verbose
This optional switch will enable verbose output. Without this switch set, minimal
output from the execution of this script will be displayed.
-h | --help
Displays this help information.
**Notes: 1) If the mount point or the RAM device is already in use, this script will
exit and display a message indicating the reason for exiting.
2) If you unmount or detach the RAM device the Linux Kernel will not free
the allocated memory associated with the RAM device. This can be useful
if one wants to mount this device again: All data will be preserved. If
you need to free the memory back to the Kernel, one can use the "busybox"
command: "busybox freeramdisk <RAM device>". Use the "free" system memory
utility command to check your results.
---------------------------------------------------------------------------------------
Example 1: Create a 128MB RAM disk at mount point: "/mnt/ram6" ...
# /root/bin/create_ramdisk -s 128 -d /dev/ram6
Example 2: Unmount and free the memory associated with RAM device: "/dev/ram6" back to
the kernel...
# free
# umount /mnt/ram6
# free
# busybox freeramdisk /dev/ram6
# free
---------------------------------------------------------------------------------------
The following is an example of creating a 128MB file system at mount point: /dev/ram9 using the create_ramdisk script:
[root@probe root]#
/root/bin/create_ramdisk -v -s 128 -d /dev/ram9
=============================================================
= Creating a 131072KB RAM disk at mount point: /mnt/ram9... =
=============================================================
*** Zeroing out RAM device: "/dev/ram9"...
/bin/dd if=/dev/zero of=/dev/ram9 bs=1k count=131072
131072+0 records in
131072+0 records out
*** Creating a 131072KB Linux ext2 file system on RAM device: "/dev/ram9"...
/sbin/mke2fs -vm 0 /dev/ram9 131072
mke2fs 1.32 (09-Nov-2002)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
32768 inodes, 131072 blocks
0 blocks (0.00%) reserved for the super user
First data block=1
16 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 34 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
*** Creating RAM disk mount point: "/mnt/ram9"...
*** Mounting RAM disk device: "/dev/ram9" at mount point: "/mnt/ram9"...
/bin/mount -t ext2 /dev/ram9 /mnt/ram9
*** Show all current mounts...
/bin/df -k
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/ram 63461 31152 32309 50% /
none 127024 0 127024 0% /dev/shm
/dev/cdrom 493856 493856 0 100% /mnt/cdrom
/dev/ram9 126931 13 126918 1% /mnt/ram9
*** Successfully created a 131072KB RAM Disk: "/dev/ram9" at mount point: "/mnt/ram9"...
If you unmount or detach the RAM disk based file system the Linux Kernel will not free the allocated memory associated with the RAM device. This can be useful if one wants to mount this device again: All data will be preserved. If you need to free the memory back to the Kernel, one can use the busybox command: "busybox freeramdisk <RAM device>". Use the free system memory utility command to check your results.