ºìÁªLinuxÃÅ»§
Linux°ïÖú

¸øÄãµÄLinux×°±¸Ramdiskì®Ò»ÏÂ

·¢²¼Ê±¼ä:2007-11-23 16:33:31À´Ô´:ºìÁª×÷Õß:skyAND
×î½ü°Ñ±Ê¼Ç±¾µÄÄÚ´æ´Ó512MBÒ»¾ÙÉý¼¶ÖÁ2GB£¬Ê¹ÓÃʱµÄ³©¿ì¸ÐÊÇÎÞ·¨ÐÎÈݵġ£Ö®Ç°µÄʹÓÃÏ°¹ßÍêÈ«±»´òÆÆ£¬ÏÖÔÚÊǺÁ²»ÁßØĵذÑÒªÓõ½µÄÈí¼þÄÜ¿ª¶àÉپͿª¶àÉÙ£¬ÅäºÏLinuxϵͳÓÅÐãµÄ»º´æ¼¼Êõ£¬µçÄÔʹÓÃʱ¼¸ºõÊÇÔ½ÓÃÔ½¿ì£¬Ë¿ºÁ²»ÏëÖØÆô¡£

ˬ¿ìÖ®Ó࣬ÎÒÓÖÏ룬Èç¹ûÖ»ÊÇÕâÑù¡°ÌîѼ¡±Ê½µÄÀûÓÃ2GBÄÚ´æËƺõҲ̫ÂäºóÁË£¬ÎÒµÃÀûÓÃLinux¹¹¼ÜµÄÏȽøÖ®´¦£¬À´³ä·ÖʹÓÃÄÚ´æ¡£ÓÚÊÇ£¬ÎÒÏëµ½ÁËRamdisk£¡

Ramdisk£¬¼´½«ÄÚ´æ×÷Ϊ´ÅÅÌÓá£ÄÚ´æµÄËÙ¶ÈÖ®¿ì£¬ÊǵçÄÔ´æ´¢É豸Öнö´ÎÓÚCPU»º´æºÍÏÔʾ¿¨ÏÔ´æµÄ£¬¶øµçÄÔÖÐÓ²ÅÌÖ®Âý£¬ÊÇÓÐÄ¿¹²¶ÃµÄ¡£

½«ÄÚ´æÈÝÁ¿µÄÒ»²¿·Ö×÷ΪÐéÄâ´ÅÅÌ£¬ °Ñ¾­³£ÐèÒª¶ÁÈ¡ºÍ½»»»µÄÊý¾Ý·ÅÖÃÆäÖУ¬Õâ²ÅÊǶÔÄÚ´æµÄ×îºÃÀûÓá£

·Ï»°²»¶à˵£¬ÈÃÎÒÃÇÒ»²½²½À´ÉèÖÃRamdisk¡£

Linux 2.6ÄÚºËÒ»°ãĬÈÏÖ§³Ö16¸öRamdiskÉ豸£¬Äã¿ÉÒÔʹÓÃÒÔÏÂÃüÁî¿´¿´ÄãµÄLinuxÓжàÉÙ¸ö¿É¹©Ê¹ÓõÄRamdisk£º

ls /dev/ram*

Ò»°ãÇé¿öÏ£¬ÎÒÃDz»»á°Ñ16¸ö¶¼ÓÃÍ꣬ÕâÀïÎÒÃÇÖ»ÓÃÒ»¸ö¾Í¹»ÁË¡£

¸úʹÓÃÈκοյÄÉ豸һÑù£¬ÎÒÃÇÏÈÒª°Ñ¡°´ÅÅÌ¡±¸ñʽ»¯³ÉÎÒÃÇÏëÒªµÄ¸ñʽ£¬ÕâÀﻹÊÇÓÃ×îÆÕ±éµÄext3°É£º

sudo mkfs.ext3 /dev/ram0

¸ñʽ»¯³Éext3¼¸ºõÊÇ˲¼äÍê³ÉµÄ£¬ÒòΪÊǸñʽ»¯ÄÚ´æÂï¡£ÎÒÃÇ»áÎÊ£¬ÄÇÕâ¸ö´ÅÅ̵ÄÈÝÁ¿ÊǶàÉÙ£¿´ÓÊä³öµÄÐÅÏ¢¿ÉÒÔ¿´µ½£¬±ÈÈçÎÒµÄÊÇ£º blocks=67108864£¬´óÔ¼ÊÇ64MB¡£Òò´ËÎÒ¿ÉÒÔ´´½¨¹²16¡Á64=1024MBµÄÐéÄâÄÚ´æ¡£

¸ñʽ»¯ºÃÁË£¬ÏÖÔÚÒª°ÑËü¹ÒÔØÆðÀ´Ê¹Óá£

ÔÚÈÎÒâÄãÏëÒªµÄλÖý¨Á¢Ò»¸öÎļþ¼Ð£¬±ÈÈçÎҵģº/hom/tualatrix/ramdisk£¬È»ºóÖ´ÐÐÃüÁî¹ÒÔØ£º

sudo mount /dev/ram0 ~/ramdisk/

¹ÒÔغÃÁË~±ð¼±£¬»¹²»ÄÜÓÃÄØ¡£ÒòΪramdiskµÄËùÓÐȨÊÇrootµÄ£¬ÎÒÃÇÒª°ÑËü±ä³É×Ô¼ºµÄ£º

sudo chown tualatrix:tualatrix ~/ramdisk

ÖÕÓÚŪºÃÁËÕâ¸öRamdisk£¬ÏÖÔÚ¿ÉÒÔËæÐÄËùÓûµÄÏñ¶Ô´ýÆÕͨÎļþ¼ÐÒ»Ñù¶ÔÆä²Ù×÷ÁË¡£

µ«ÊÇ£¬Õâ¸ö²Å64MBµÄÐéÄâ´ÅÅÌÄܸÉʲôÄØ£¿Äܲ»ÄÜ°ÑËüµÄÈÝÁ¿·Å´óµã£¿

±§Ç¸£¬³ýÁËʹÓøñʽ»¯¶à¸ö/dev/ram½øÐÐ×ÓĿ¼¹ÒÔØÒÔÍ⣬ÎÒÔÝʱûÓÐÕÒµ½°ÑRamdiskµ¥¸ö·ÖÇøÈÝÁ¿±ä´óµÄ·½·¨¡£

²»¹ý£¬Õâ¸öRamdiskÕæµÄºÜÇ¿£¡Èç¹ûÄã°ÑËüÀûÓúõĻ°£¬ËüÒ»¶¨ÄÜ°ïÉÏÄãµÄ棬ÒòΪËüµÄËٶȷdz£¿ì£¡

ÎÒ¶ÔÆäÓÃhdparm½øÐÐÐÔÄܲâÊÔ£¨ sudo hdparm -tT /dev/ram0£©£¬buffered disk readsµÄËٶȴﵽÁË842MB/s£¬¶øÎÒµÄÓ²ÅÌÖ»ÓÐ32MB/s£¬¿ìµ½30±¶µÄ²î¾àÁË¡£

¾ßÌåÏëÔõôÀûÓÃËü£¬¾ÍÒª¿¿´ó¼Ò·¢»ÓÁË~±ÈÈ罫/tmpĿ¼¹ÒÔØÖÁRamdiskÒ²ÊǸö²»´íµÄÖ÷Ò⣡

²»¹ý±ðÍüÁË£¬¹Ø»úʱÄÚ´æµÄÊý¾Ý¿ÉÒªÏûʧÁË¡£Èç¹ûÄãÐèÒª±£´æÊý¾Ý£¬Õâʱ¿ÉÒÔд¸öת´¢Êý¾ÝµÄ½Å±¾£¬·ÅÈë/etc/init.d/£¬ÔÙÁ´½ÓÖÁ /etc/rc0.d£¨Ubuntuϵͳʱ¹Ø»úµ÷ÓôËĿ¼½Å±¾£©£¬ÔÙд¸ö½Å±¾×Ô¶¯¸ñʽ»¯²¢¹ÒÔØRamdiskºÍµ÷ÓÃÊý¾Ý£¬Í¬Ñù·ÅÈë /etc/init.d/£¬ÔÙÁ´½ÓÖÁ/etc/rc2.d£¨Ubuntuϵͳ¿ª»úĬÈϵ÷Óã©£¬ÕâÑù¾Í¿ÉÒÔ·½±ãʵÏÖ×Ô¶¯¹ÒÔغÍ×Ô¶¯×ª´¢ÁË¡£

¾ßÌåµÄ¾ÍÒª¿¿´ó¼ÒÁé»îÓ¦ÓÃÁË£¬´óÄÚ´æµÄÅóÓÑ»¹²»¸Ï¿ìÐж¯¡£
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 0 ÌõÆÀÂÛ