The file systems mentioned above are all based on flash memory, and the file systems described in this article use RAM as their storage space. Their common advantage is that they read and write very quickly (because they read and write in memory), and the disadvantage is that all data is lost when the system is reset. Second, RAM-based file system 1, RAMDisk file system RAMDisk is a part of the fixed size of memory as a partition to use. It is not an actual file system, but a mechanism for loading the actual filesystem into memory and can be used as the root file system. A, features a. It can improve the performance of the system by putting some files that are frequently accessed but not modified through ramdisk into memory; b. Compared with Cramfs and JFFS2, the compression rate is not high, and the resource is much; c. fast access; d. read-only file system, off Electrical data loss. B, create method A. Create and mount after the kernel
View the RAMDisk available to the system
#ls-al/dev/ram*
The kernel manages RAMDisk as a device file and does not consume memory space before it is formatted
#mke2fs/dev/ram0
This command formats a RAMDisk, and the following prompts appear:
MKE2FS 1.41.12 (17-may-2010)
FileSystem label=
OS Type:linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, stripe width=0 blocks
16384 inodes, 65536 blocks
3276 blocks (5.00%) reserved for the Super user
The Data block=1
Maximum filesystem blocks=67108864
8 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345.
Writing Inode Tables:done
Writing superblocks and filesystem accounting Information:done
This filesystem would be automatically checked every mounts or
180 days, whichever comes. Use Tune2fs-c or-i to override. Load RAMDisk #mkdir/mnt/ramdisk #mount/dev/ram0/mnt/ramdisk can view the size of the RAMDisk created Root@jgf:~/qihuan # df-k/DEV/RAM0
FileSystem 1k-blocks Used Available use% mounted on
/dev/ram0 63461 1289 58896 3%/mnt/ramdisk uninstall #umount/mnt/ramdisk B. How to create a RAMDisk mirror file Provides a script to create the prepared Rootfs folder as Ramdisk.img, run on Ubuntu, or use the Ubuntu mke2fs command to format a piece of RAM, under Mount to/mnt, and then copy Rootfs to it, It becomes a ramdisk.img image file when it is copied. make_ramdisk.sh
#!/bin/bash
# Housekeeping...clean before img
Rm-f/tmp/ramdisk.img
# Finish up ...
Umount/mnt/ramdisk
Cp/tmp/ramdisk.img./
Rm-fr/mnt/ramdisk then generates a ramdisk.img that can be mounted on your Ubuntu test
#mount ramdisk.img/mnt/-O loop
#ls/mnt
Bin etc init lost+found modules proc Sys usr Dev home lib mnt sbin tmp var If the implementation writes it to a section of NAND, then the uboot starts with some parameter configuration, And you need to read the kernel immediately after reading it to the appropriate location of the memory, and then start Linux:
Define Config_bootargs "Root=/dev/ram0 rw console=ttys0,115200 mem=64mb initrd=0x41000000,0x800000"
Define Config_bootcommand "mtdparts default; NAND read 0x41000000 0xe00000 0x800000; NAND read 0x40008000 0x400000 0x300000; Bootm 0x40008000; " Of course, in embedded, support for RAMDisk requires some configuration, listing:
1. General Setup--->
[*] Initial RAM filesystem and RAM disk (INITRAMFS/INITRD) support
2. File Systems--->
<*> Second Extended FS Support
3. Device Drivers--->
[*] Block Devices--->
---block devices
<*> Loopback Device Support
<*> Cryptoloop Support
<*> RAM block Device support
() Default Number of RAM disks
(8192) Default RAM disk size (Kbytes) Description: 1, this is configured to support Initramfs (just the following to introduce an important file system) and RAMDisk support 2, RAMDisk is based on EXT2, so need Support EXT2, of course, also have EXT3 type of RAMDisk 3, here can specify RAMDisk maximum space 2, RAMFS and Tmpfs file system two file systems (hereinafter referred to as RAMFS) is Linus Torvalds developed A memory-based file system that works on the virtual file system (VFS) layer, cannot be formatted, can be created, can be created with the maximum amount of memory that can be used, and can be read and written. Many daemon processes in embedded Linux generate a lot of log messages, as well as kernel logging mechanisms such as SYSLOGD, DMESG, and KLOGD, which generate a lot of messages in/var/and/tmp/directories. If these messages are stored in flash, it is bound to greatly deplete the life of the Flash, here the best way is to use RAMFS. Compared with the traditional ramdisk, the difference is that it cannot be formatted and the file system size can be changed dynamically. A, Mount mode
#mkdir/mnt/ramfs
#mount-T Ramfs None/mnt/ramfs
Note that RAMFS does not have a corresponding/dev/device node
By default, Ramfs is limited to half the size of memory, or it can be done by MaxSize (KB units)
#mount-T Ramfs none/mnt/ramfs-o maxsize=2000
In addition, in/ETC/RC.D and other documents will see such a content
#mount-T Tmpfs tmpfs/var-o size=512k
#mkdir-P/var/tmp
#mkdri &
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.