Linux ÖÐµÄ ½»»»¿Õ¼ä£¨Swap space£© ÔÚÎïÀíÄڴ棨RAM£©±»³äÂúʱ±»Ê¹Óá£Èç¹ûϵͳÐèÒª¸ü¶àµÄÄÚ´æ×ÊÔ´£¬¶øÎïÀíÄÚ´æÒѾ³äÂú£¬ÄÚ´æÖв»»îÔ¾µÄÒ³¾Í»á±»ÒƵ½½»»»¿Õ¼äÈ¥¡£ËäÈ»½»»»¿Õ¼ä¿ÉÒÔΪ´øÓÐÉÙÁ¿ÄÚ´æµÄ»úÆ÷Ìṩ°ïÖú£¬µ«ÊÇÕâÖÖ·½·¨²»Ó¦¸Ã±»µ±×öÊǶÔÄÚ´æµÄÈ¡´ú¡£½»»»¿Õ¼äλÓÚÓ²ÅÌÇý¶¯Æ÷ÉÏ£¬Ëü±È½øÈëÎïÀíÄÚ´æÒªÂý¡£
½»»»¿Õ¼ä¿ÉÒÔÊÇÒ»¸öרÓõĽ»»»·ÖÇø£¨ÍƼöµÄ·½·¨£©£¬½»»»Îļþ£¬»òÁ½ÕßµÄ×éºÏ¡£
½»»»¿Õ¼äµÄ×Ü´óСӦ¸ÃÏ൱ÓÚÄãµÄ¼ÆËã»úÄÚ´æµÄÁ½±¶ºÍ 32 MBÕâÁ½¸öÖµÖнϴóµÄÒ»¸ö£¬µ«ÊÇËü²»Äܳ¬¹ý 2048 MB£¨2 GB£©¡£
2.2. Ìí¼Ó½»»»¿Õ¼ä
ÓÐʱ£¬Äã»áÓбØÒªÔÚ°²×°ºóÌí¼Ó¸ü¶àµÄ½»»»¿Õ¼ä¡£ÀýÈ磬Äã°ÑϵͳÄÚ´æ´Ó 64 MB Éý¼¶µ½ 128 MB£¬µ«ÊÇÄãÖ»ÓÐ 128 MB µÄ½»»»ÄÚ´æ¡£Èç¹ûÄãÖ´ÐеÄÊÇ´óÁ¿Ê¹ÓÃÄÚ´æµÄ²Ù×÷»òÔËÐÐÐèÒª´óÁ¿ÄÚ´æµÄ³ÌÐò£¬°Ñ½»»»ÇøÔö¼Óµ½ 256 MB ¿ÉÄÜ»á¶ÔÄãÓÐÀû¡£
ÄãÓÐÁ½ÖÖÑ¡Ôñ£ºÌí¼ÓÒ»¸ö½»»»·ÖÇø»òÌí¼ÓÒ»¸ö½»»»Îļþ¡£ÍƼöÄãÌí¼ÓÒ»¸ö½»»»·ÖÇø£¬²»¹ý£¬ÈôÄãûÓжàÉÙ¿ÕÏпռä¿ÉÓ㬴´½¨½»»»·ÖÇø¿ÉÄܻ᲻´óÈÝÒס£
ÒªÌí¼ÓÒ»¸ö½»»»·ÖÇø£¨¼ÙÉè /dev/hdb2 ÊÇÄãÏëÌí¼ÓµÄ½»»»·ÖÇø£©£º
Ó²ÅÌÇý¶¯Æ÷²»ÄÜÔÚ±»Ê¹Ó㨷ÖÇø²»Äܱ»¹ÒÔØ£¬½»»»·ÖÇø²»Äܱ»ÆôÓã©¡£Òª´ïµ½ÕâһĿµÄµÄ×î¼òµ¥·½·¨ÊÇÔÚ¾ÈԮģʽÏÂÒýµ¼ÄãµÄϵͳ¡£Çë²ÎÔÄ µÚ9Õ À´»ñµÃ½«ÏµÍ³Òýµ¼Èë¾ÈԮģʽµÄ˵Ã÷¡£µ±Ìáʾ¹ÒÔØÎļþϵͳʱ£¬Ñ¡Ôñ ¡¸Ìø¹ý¡¹ ¡£
Èç¹ûÇý¶¯Æ÷²»°üº¬Èκα»Ê¹ÓõķÖÇø£¬Ä㻹¿ÉÒÔжÔØÕâЩ·ÖÇø£¬Ê¹Óà swapoff ÃüÁîÀ´¹Ø±ÕÓ²ÅÌÇý¶¯Æ÷ÉϵÄËùÓн»»»¿Õ¼ä¡£
ʹÓà parted »ò fdisk À´´´½¨½»»»·ÖÇø¡£ parted ±È fdisk ʹÓÃÆðÀ´¸ü·½±ã£¬Òò´Ë£¬Ö»ÓÐ parted ÔÚÕâÀï»á±»ËµÃ÷¡£ÒªÊ¹Óà parted À´´´½¨½»»»·ÖÇø£º
ÔÚ shell ÌáʾÏÂÒÔ¸ùÓû§Éí·Ý¼üÈëÃüÁ parted /dev/ hdb ¡£ÕâÀïµÄ /dev/ hdb ÊÇÄãµÄ´øÓпÕÏпռäµÄÓ²ÅÌÇý¶¯Æ÷µÄÉ豸Ãû³Æ¡£
ÔÚ (parted) ÌáʾÏ£¬¼üÈë print À´²é¿´ÏÖ´æµÄ·ÖÇøºÍ¿ÕÏпռäµÄÊýÁ¿¡£ÆðÖ¹ÖµÒÔ MB Ϊµ¥Î»¡£Åж¨Ó²ÅÌÇý¶¯Æ÷ÉϵĿÕÏпռäÊýÁ¿£¬ÒÔ¼°ÄãÏë¸øн¨µÄ½»»»·ÖÇø·ÖÅäµÄ¿Õ¼äÊýÁ¿¡£
ÔÚ (parted) ÌáʾÏ£¬¼üÈë mkpartfs part-type linux-swap start end £¬ÕâÀïµÄ part-type ÊÇ primary¡¢extended¡¢logical ÖеÄÒ»¸ö£¬ start ÊÇ·ÖÇøµÄÆðʼµã£¬ end ÊÇ·ÖÇøµÄÖÕÖ¹µã¡£
¾¯¸æ:¸Ä±ä»áÁ¢¼´·¢Éú£¬ÔÚ¼üÈëʱÇë½÷É÷´ÓÊ¡£
¼üÈë quit À´Í˳ö parted ¡£
ÏÖÔÚ£¬Äã¾Í¿ÉÒÔ´´½¨½»»»·ÖÇøÁË£¬Ê¹Óà mkswap ÃüÁîÀ´ÉèÖý»»»·ÖÇø¡£ÔÚ shell ÌáʾÏÂÒÔ¸ùÓû§Éí·Ý¼üÈëÒÔÏÂÃüÁ
mkswap /dev/hdb2
ÒªÁ¢¼´ÆôÓý»»»·ÖÇø£¬¼üÈëÒÔÏÂÃüÁ
swapon /dev/hdb2
ÒªÔÚÒýµ¼Ê±ÆôÓ㬱༠/etc/fstab ÎļþÀ´°üÀ¨ÒÔÏÂÐУº
/dev/hdb2 swap swap defaults 0 0
ÔÚϵͳÏ´ÎÒýµ¼Ê±£¬Ëü¾Í»áÆôÓÃн¨µÄ½»»»·ÖÇø¡£
ÐÂÌíÁ˽»»»·ÖÇø²¢ÆôÓÃËüÖ®ºó£¬Çë²é¿´ cat /proc/swaps »ò free ÃüÁîµÄÊä³öÀ´È·±£½»»»·ÖÇøÒѱ»ÆôÓÃÁË¡£
ÒªÌí¼Ó½»»»Îļþ£º
Åж¨Ð½»»»ÎļþµÄ´óС£¬½«´óС³ËÒÔ 1024 À´Åж¨¿éµÄ´óС¡£ÀýÈ磬´óСµÄ 64 MB µÄ½»»»ÎļþµÄ¿é´óСΪ 65536¡£
ÔÚ shell ÌáʾÏÂÒÔ¸ùÓû§Éí·Ý¼üÈëÒÔÏÂÃüÁÆäÖÐµÄ count µÈÓÚÏëÒªµÄ¿é´óС£º
dd if=/dev/zero of=/swapfile bs=1024 count=65536
ʹÓÃÒÔÏÂÃüÁîÀ´ÉèÖý»»»Îļþ£º
mkswap /swapfile
ÒªÁ¢¼´ÆôÓý»»»Îļþ¶ø²»ÊÇÔÚÒýµ¼Ê±×Ô¶¯ÆôÓã¬Ê¹ÓÃÒÔÏÂÃüÁ
swapon /swapfile
ÒªÔÚÒýµ¼Ê±ÆôÓ㬱༠/etc/fstab ÎļþÀ´°üº¬ÒÔÏÂÐУº
/swapfile swap swap defaults 0 0
ϵͳÏ´ÎÒýµ¼Ê±£¬Ëü¾Í»áÆôÓÃн¨µÄ½»»»Îļþ¡£
ÐÂÌíÁ˽»»»·ÖÇø²¢ÆôÓÃËüÖ®ºó£¬Çë²é¿´ cat /proc/swaps »ò free ÃüÁîµÄÊä³öÀ´È·±£½»»»·ÖÇøÒѱ»ÆôÓÃÁË¡£
2.3. ɾ³ý½»»»¿Õ¼ä
Ҫɾ³ý½»»»·ÖÇø£º
Ó²ÅÌÇý¶¯Æ÷²»ÄÜÔÚ±»Ê¹Ó㨷ÖÇø²»Äܱ»¹ÒÔØ£¬½»»»·ÖÇø²»Äܱ»ÆôÓã©¡£Òª´ïµ½ÕâһĿµÄµÄ×î¼òµ¥·½·¨ ÊÇÔÚ¾ÈԮģʽÏÂÒýµ¼ÄãµÄϵͳ¡£Çë²ÎÔÄ µÚ9Õ À´»ñµÃ½«ÏµÍ³Òýµ¼Èë¾ÈԮģʽµÄ˵Ã÷¡£µ±Ìáʾ¹ÒÔØÎļþϵͳʱ£¬Ñ¡Ôñ ¡¸Ìø¹ý¡¹ ¡£
Èç¹ûÇý¶¯Æ÷²»°üº¬Èκα»Ê¹ÓõķÖÇø£¬Ä㻹¿ÉÒÔжÔØÕâЩ·ÖÇø£¬Ê¹Óà swapoff ÃüÁîÀ´¹Ø±ÕÓ²ÅÌÇý¶¯Æ÷ÉϵÄËùÓн»»»¿Õ¼ä¡£
ÔÚ shell ÌáʾÏÂÒÔ¸ùÓû§Éí·Ý¼üÈëÒÔÏÂÃüÁîÀ´È·¶¨½»»»·ÖÇøÒѱ»½ûÓã¨ÕâÀïµÄ /dev/hdb2 Êǽ»»»·ÖÇø£©£º
swapoff /dev/hdb2
´Ó /etc/fstab ÎļþÖÐɾ³ýÕâ¸öÏîÄ¿¡£
ʹÓà parted »ò fdisk À´É¾³ý·ÖÇø¡£Ö»ÓÐ parted ÔÚÕâÀï»á±»ËµÃ÷¡£ÒªÊ¹Óà parted À´É¾³ý·ÖÇø£º
ÔÚ shell ÌáʾÏÂÒÔ¸ùÓû§Éí·Ý¼üÈëÃüÁ parted /dev/ hdb ¡£ÕâÀïµÄ /dev/ hdb ÊÇÄãµÄ´øÓн»»»¿Õ¼äµÄÓ²ÅÌÇý¶¯Æ÷µÄÉ豸Ãû³Æ¡£
ÔÚ (parted) ÌáʾÏ£¬¼üÈë print À´²é¿´ÏÖ´æµÄ·ÖÇø²¢Åж¨ÄãÏëɾ³ýµÄ½»»»·ÖÇøµÄ´ÎÒªºÅÂë¡£
ÔÚ (parted) ÌáʾÏ£¬¼üÈë rm MINOR £¬ÕâÀïµÄ MINOR ÊÇÄãÏëɾ³ýµÄ·ÖÇøµÄ´ÎÒªºÅÂë¡£
¾¯¸æ:¸Ä±ä»áÁ¢¼´·¢Éú£¬Äã±ØÐë¼üÈëÕýÈ·µÄ´ÎÒªºÅÂë¡£
¼üÈë quit À´Í˳ö parted ¡£
Ҫɾ³ý½»»»Îļþ£º
ÔÚ shell ÌáʾÏÂÒÔ¸ùÓû§Éí·ÝÖ´ÐÐÒÔÏÂÃüÁîÀ´½ûÓý»»»Îļþ£¨ÕâÀïµÄ /swapfile Êǽ»»»Îļþ£©£º
swapoff /swapfile
´Ó /etc/fstab ÖÐɾ³ý¸ÃÏîÄ¿¡£
ɾ³ýʵ¼ÊÎļþ£º
rm /swapfile
2.4. Òƶ¯½»»»¿Õ¼ä
Òª°Ñ½»»»¿Õ¼ä´Óij´¦ÒƵ½ÁíÒ»´¦£¬ÇëÊ×ÏÈ×ñÑɾ³ý½»»»¿Õ¼äµÄ˵Ã÷£¬ÔÙ×ñÑÌí¼Ó½»»»¿Õ¼äµÄ˵Ã÷¡£
mic1og ÓÚ 2007-11-21 09:37:50·¢±í:
ÓÖ³¤ÖªÊ¶ÁË,ÄãÕ¦ÖªµÀµÄÄÇô¶àÄØ,ºÇºÇ¡¡:0)1
3611291 ÓÚ 2006-06-06 13:53:34·¢±í:
²»´í²»´í~``