Linux initial RAM disk (initrd) overview
Linux initial RAM disk (initrd) overview
Learn about its anatomy, creation, and use in the Linux boot process
M. Tim Jones
(mtj@mtjones.com
), Consultant Engineer, Emulex
M. Tim Jones is an embedded software architect and the author of GNU/Linux Application Programming
, AI Application Programming
, and BSD Sockets Programming from a Multilanguage Perspective
.
His engineering background ranges from the development of kernels for
geosynchronous spacecraft to embedded systems architecture and
networking protocols development. Tim is a Consultant Engineer for
Emulex Corp. in Longmont, Colorado.
Summary:
The Linux® initial RAM disk (initrd) is a temporary
root file system that is mounted during system boot to support the
two-state boot process. The initrd contains various executables and
drivers that permit the real root file system to be mounted, after
which the initrd RAM disk is unmounted and its memory freed. In many
embedded Linux systems, the initrd is the final root file system. This
article explores the initial RAM disk for Linux 2.6, including its
creation and use in the Linux kernel.
What's an initial RAM disk?
The initial RAM disk (initrd)
is an initial root file system that is mounted
prior to when the real root file system is available. The initrd is bound to the
kernel and loaded as part of the kernel boot procedure. The kernel then mounts
this initrd as part of the two-stage boot process to load the modules
to make the real file systems available and get at the real root
file system.
The initrd contains a minimal set of directories and executables to achieve
this, such as the insmod
tool to install kernel modules
into the kernel.
In the case of desktop or server Linux systems, the initrd is a transient
file system. Its lifetime is short, only serving as a bridge to the real
root file system. In embedded systems with no mutable storage, the initrd
is the permanent root file system. This article explores
Ïà¹ØÎĵµ£º
Ò»£ºÇ°ÑÔ
×î½üÔÚÑо¿androidµÄsensor driver£¬Ö÷ÒªÊÇE-compass£¬ÆäÖÐÓõ½ÁËLinux input×Óϵͳ.ÔÚÍøÉÏÒ²¿´Á˺ܶàÕâ·½ÃæµÄ×ÊÁÏ£¬¸Ð¾õ»¹ÊÇÕâƪ·ÖÎöµÄ±È½ÏϸÖÂ͸³¹£¬Òò´ËתÔØÒ»ÏÂÒÔ±ã×Ô¼ºÑ§Ï°£¬Í¬Ê±ºÍ´ó¼Ò·ÖÏí£¡
£¨Õâƪ²©¿ÍÖ÷ÒªÊÇÒÔ¼üÅÌÇý¶¯ÎªÀýµÄ£¬²»¹ý½²½âµÄÊÇLinux Input Subsystem£¬¿ÉÒÔ×ÐϸµÄÑо¿Ò»Ï£¡£©
¼üÅÌÇý¶¯½«¼ì ......
1. ѧ»áд¼òµ¥µÄmakefile
2. ±àһЩӦÓÃ
³ÌÐò
£¬¿ÉÒÔÓÃmakefileÅÜÆðÀ´
3. ѧ»áдÇý¶¯
µÄmakefile
4. дһ¼òµ¥charÇý¶¯£¬makefile±àÒëͨ¹ý£¬¿ÉÒÔinsmod£¬ lsmod£¬ rmmod. ÔÚÇý¶¯µÄinitº¯ÊýÀï´òÓ¡hello world£¬insmodºóÓ¦¸ÃÄܹ»Í¨¹ýdmesg¿´µ½Êä³ö
¡£
5. дһÍêÕûÇý¶¯£¬ ¼ÓÉÏread£¬ write£¬ ioctl£¬ pollingµÈ¸ ......
1
¡¢ÏÂÔØÔ´Âë
¡¡¡¡
´Ó
CVS
µÄ¹Ù·½ÍøÕ¾
cvshome.org
ÉÏÑ°ÕÒ£¬ÓÉÓÚ
CVS
ÀúÊ·ÉÏÒ²³öÏÖ¹ýһЩ°²È«Â©¶´£¬ËùÒÔ½¨ÒéÒª¶¨ÆÚÈ¥Æä¹Ù·½ÍøÕ¾ÉÏ¿´¿´ÓÐûÓÐ×îа汾ÍƳö¡£
¡¡¡¡
2
¡¢±àÒë°²×°
¡¡¡¡
# tar -xjpvf cvs-1.12.5.tar.bz2
¡¡¡¡
# cd cvs-1.12.5
¡¡¡¡
# ./configure --prefix=/usr/local/terry_yu/cvs
¡¡
--d ......
±¾³ÌÐò¿ÉÒÔ¶ÁÈ¡.wavÎļþ£¬È»ºó½øÐв¥·Å¡£
È·ÈÏ·½·¨£ºcat /etc/sndstat£¬Èç¹ûÏÔʾÎÞ´ËÉ豸£¬ÔòûÓа²×°Çý¶¯¡£
#include <unistd.h>#include <fcntl.h>#include <sys/types.h>#include <sys/ioctl.h>#include <stdlib.h>#include <stdio.h>#include&nbs ......
linux—selectÏê½â
selectϵͳµ÷ÓÃʱÓÃÀ´ÈÃÎÒÃǵijÌÐò¼àÊÓ¶à¸öÎļþ¾ä±úµÄ״̬±ä»¯µÄ¡£³ÌÐò»áÍ£ÔÚselectÕâÀïµÈ´ý£¬Ö±µ½±»¼àÊÓµÄÎļþ¾ä±úÓÐÒ»¸ö»ò¶à¸ö·¢ÉúÁË״̬¸Ä±ä¡£
¹ØÓÚÎļþ¾ä±ú£¬Æäʵ¾ÍÊÇÒ»¸öÕûÊý£¬Í¨¹ýsocketº¯ÊýµÄÉùÃ÷¾ÍÃ÷°×ÁË£º
int socket(int domain, int type, int protocol);
ÎÒÃÇ×îÊìϤµÄ¾ä±úÊÇ0¡¢1¡¢2 ......