Óû§¿ÉÒÔÔÚÈκΠLinux ²Ù×÷ϵͳµÄ°²×°¹ý³ÌÖлòÕßÊÇÆäËü±ØÒªµÄʱºò´´½¨½»»»¿Õ¼ä¡£Èç¹ûÄãÔÚ°²×° Linux µÄʱºòÍü¼ÇÁË´´½¨»òÊÇÄãÏëÒªÔÙÔö¼Ó½»»»·ÖÇøµÄ¿Õ¼ä£¬ÄãËæʱ¶¼¿ÉÒÔÔÙ´´½¨»òÔö¼Ó¡£
ÓÐʱºòÔÚÄã°²×°ºóÒ¡Éý¼¶ RAM µÄʱºòÐèÒªÔö¼ÓÒ»µã½»»»·ÖÇøµÄ¿Õ¼ä£¬±ÈÈçÄãÒª½«ÄãµÄϵͳµÄ RAM ´Ó 1GB Éý¼¶µ½ 2GB Ä㣬ÄÇôÄã¾Í²»µÃ²»½«ÄãµÄ½»»»·ÖÇø¿Õ¼äÒ²Éý¼¶Ò»Ï£¨´Ó 2GB µ½ 4GB£©£¬ÕâÊÇÒòΪËüʹÓõÄÈÝÁ¿ÊÇÎïÀí RAM µÄË«±¶ÈÝÁ¿¡££¨LCTT Òë×¢£ºÆäʵÕâÀïÊǸöÎóÇø£¬½»»»·ÖÇø²»Ò»¶¨·ÇµÃÊÇË«±¶µÄÎïÀíÄÚ´æÈÝÁ¿£¬Ö»ÊǹßÀýÈç´Ë¡£ÊÂʵÉÏ£¬Èç¹ûÄãµÄÎïÀíÄÚ´æ×ã¹»µÄ»°£¬ÄãÍêÈ«¿ÉÒÔ²»Óý»»»·ÖÇø----ÔÚÕâÀïµÄÇéÐÎÏ£¬»òÐíÄãÔö¼ÓÁËÎïÀíÄڴ棬¾Íû±ØÒªÔö¼Ó½»»»·ÖÇø´óСÁË¡££©
½»»»¿Õ¼äÊǵ±ÎïÀíÄڴ棨RAM Ëæ»ú´æÈ¡´æ´¢Æ÷£©µÄÓÃÁ¿ÒÑÂúʱ£¬±»±£ÁôÓÃ×÷ÐéÄâÄÚ´æµÄ´ÅÅÌÉϵĿռ䡣 Èç¹ûϵͳÔÚ RAM ÂúÔØʱÐèÒª¸ü¶àµÄÄÚ´æ×ÊÔ´£¬ÄÚ´æÖеķǻҳÃ潫±»Òƶ¯µ½½»»»¿Õ¼ä£¬ÕâÑù¿ÉÒÔ°ïÖúϵͳÔËÐÐÓ¦ÓóÌÐò¸ü¶àµÄʱ¼ä£¬µ«²»Ó¦¸Ã°ÑËüµ±×ö RAM µÄÀ©Õ¹¡£
½¨ÒéÄã´´½¨Ò»¸öרÓõĽ»»»·ÖÇø£¬µ«ÊÇÈç¹ûÄãûÓпÉÓõķÖÇø£¬ÄÇô¿ÉÒÔʹÓý»»»Îļþ£¬»ò½»»»·ÖÇøºÍ½»»»ÎļþµÄ×éºÏ¡£ ½»»»¿Õ¼äͨ³£½¨ÒéÓû§ÖÁÉÙ 4 GB£¬Óû§Ò²¿ÉÒÔ¸ù¾Ý×Ô¼ºµÄÒªÇóºÍ»·¾³´´½¨½»»»¿Õ¼ä¡£
ÎÒ·¢ÏÖ´ó²¿·Ö VM ºÍ ÔÆ·þÎñÆ÷¶¼Ã»Óн»»»·ÖÇø£¬ËùÒÔÔÚÕâÖÖÇé¿öÏ£¬ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏÂÈýÖÖ·½·¨´´½¨£¬À©Õ¹»òÔö¼Ó½»»»¿Õ¼ä¡£
ÈçºÎ¼ì²âµ±Ç°½»»»·ÖÇø´óС
ͨ¹ý free & swapon ÃüÁîÀ´¼ì²âµ±Ç°µÄ½»»»·ÖÇø¿Õ¼äµÄ´óС¡£
$ free -h
total used free shared buff/cache available
Mem: 2.0G 1.3G 139M 45M 483M 426M
Swap: 2.0G 655M 1.4G
$ swapon --show
NAME TYPE SIZE USED PRIO
/dev/sda5 partition 2G 655.2M -1
ÉÏÃæµÄÊä³öÏÔʾÁ˵±Ç°µÄ½»»»·ÖÇø¿Õ¼äÊÇ 2GB ¡£
·½·¨ 1 : ͨ¹ý fallocate ÃüÁî´´½¨½»»»Îļþ
fallocate ³ÌÐòÊÇÁ¢¼´´´½¨Ô¤·ÖÅä´óСµÄÎļþµÄ×î¼Ñ·½·¨¡£
ÏÂÃæÕâ¸öÃüÁî»á´´½¨Ò»¸ö 1GB ´óС µÄ /swapfile¡£
$ sudo fallocate -l 1G /swapfile
¼ì²éһϴ´½¨µÄÎļþµÄ´óСÊÇ·ñÕýÈ·¡£
$ ls -lh /swapfile
-rw-r--r-- 1 root root 1.0G Jun 7 09:49 /swapfile
½«¸ÃÎļþµÄȨÏÞÉèÖÃΪ 600 ÕâÑùÖ»ÓÐ root Óû§¿ÉÒÔ·ÃÎÊÕâ¸öÎļþ¡£
$ sudo chmod 600 /swapfile
ͨ¹ýÔËÐÐÒÔϵÄÃüÁîÀ´½«´ËÎļþת»»Îª½»»»Îļþ¡£
$ sudo mkswap /swapfile
Setting up swapspace version 1, size = 1024 MiB (1073737728 bytes)
no label, UUID=cda50e0e-41f3-49c7-af61-b8cb4a33a464
ͨ¹ýÔËÐÐÒÔϵÄÃüÁîÀ´Ê¹½»»»ÎļþÉúЧ¡£
$ sudo swapon /swapfile
½«Ð´´½¨µÄ½»»»ÎļþÌí¼Óµ½ fstab ÎļþÖУ¬ÕâÑù½»»»·ÖÇø¿Õ¼äµÄÐ޸ļ´Ê¹ÔÚÖØÆôºóÒ²¿ÉÒÔÉúЧ¡£
$ vi /etc/fstab
/swapfile swap swap defaults 0 0
¼ì²éÒ»ÏÂд´½¨µÄ½»»»Îļþ¡£
$ swapon --show
NAME TYPE SIZE USED PRIO
/dev/sda5 partition 2G 657.8M -1
/swapfile file 1024M 0B -2
ÏÖÔÚÎÒ¿ÉÒÔ¿´µ½Ò»¸öÐ嵀 1GB µÄ /swapfile1 ÎļþÁË¡£ÖØÆôϵͳÒÔʹеĽ»»»ÎļþÉúЧ¡£
·½·¨ 2 : ͨ¹ý dd ÃüÁîÀ´´´½¨½»»»Îļþ
dd ÃüÁîÊÇÁíÒ»¸öʵÓóÌÐò£¬¿ÉÒÔ°ïÖúÎÒÃÇÁ¢¼´´´½¨Ô¤·ÖÅä´óСµÄÎļþ¡£
ÒÔÏ dd ÃüÁ´´½¨ 1GB µÄ /swapfile1¡£
$ sudo dd if=/dev/zero of=/swapfile1 bs=1G count=1
1+0 records in
1+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 16.6154 s, 64.6 MB/s
Ïê½â£º if=/dev/zero ÊÇÊäÈëÎļþ£¬/dev/zero ÊÇÀà Unix ²Ù×÷ϵͳÖеÄÒ»¸öÌØÊâÎļþ£¬ËüÌṩ´ÓËü¶ÁÈ¡µÄ¾¡¿ÉÄܶàµÄ¿Õ×Ö·û£¨ASCII NUL£¬0x00£©¡£
of=/swapfile1 ÉèÖÃÊä³öÎļþ¡£
bs=1G Ò»´ÎÐÔ¶ÁдµÄ´óСΪ 1GB
count=1 ½ö¸´ÖÆÒ»¸öÊäÈë¿é
¼ì²éһϴ´½¨µÄÎļþµÄ´óСÊÇ·ñÕýÈ·¡£
$ ls -lh /swapfile1
-rw-r--r-- 1 root root 1.0G Jun 7 09:58 /swapfile1
½«¸ÃÎļþµÄȨÏÞÉèÖÃΪ 600 ÕâÑùÖ»ÓÐ root Óû§¿ÉÒÔ·ÃÎÊÕâ¸öÎļþ¡£
$ sudo chmod 600 /swapfile1
ͨ¹ýÔËÐÐÒÔϵÄÃüÁîÀ´½«´ËÎļþת»»Îª½»»»Îļþ¡£
$ sudo mkswap /swapfile1
Setting up swapspace version 1, size = 1024 MiB (1073737728 bytes)
no label, UUID=96def6d7-b2da-4954-aa72-aa32316ec993
ͨ¹ýÔËÐÐÒÔϵÄÃüÁîÀ´Ê¹½»»»ÎļþÉúЧ¡£
$ sudo swapon /swapfile1
½«Ð´´½¨µÄ½»»»ÎļþÌí¼Óµ½ fstab ÎļþÖУ¬ÕâÑù½»»»·ÖÇø¿Õ¼äµÄÐ޸ļ´Ê¹ÔÚÖØÆôºóÒ²¿ÉÒÔÉúЧ¡£
$ vi /etc/fstab
/swapfile1 swap swap defaults 0 0
¼ì²éд´½¨µÄ½»»»Îļþ¡£
$ swapon --show
NAME TYPE SIZE USED PRIO
/dev/sda5 partition 2G 1.3G -1
/swapfile file 1024M 0B -2
/swapfile1 file 1024M 0B -3
ÏÖÔÚÎÒ¿ÉÒÔ¿´µ½Ò»¸öÐ嵀 1GB µÄ /swapfile1 ÁË¡£ÖØÆôϵͳÒÔʹеĽ»»»ÎļþÉúЧ¡£
·½·¨ 3 : ͨ¹ýÓ²ÅÌ·ÖÇøÀ´´´½¨½»»»Îļþ
ÎÒÃÇÒ²ÍƼöʹÓÃͨ¹ýÓ²ÅÌ·ÖÇøµÄ·½Ê½À´´´½¨½»»»·ÖÇø¡£
Èç¹ûÄãÒѾÔÚÄãµÄÁíÒ»¸öÓ²ÅÌÉÏͨ¹ý fdisk ÃüÁî´´½¨ÁËÒ»¸öеķÖÇø£¬¼ÙÉèÎÒÃÇÒѾ´´½¨ÁËÒ»¸ö½Ð×ö /dev/sda4 µÄ·ÖÇø¡£
ʹÓà mkswap ÃüÁîÀ´½«Õâ¸ö·ÖÇøת»»³É½»»»·ÖÇø¡£
$ sudo mkswap /dev/sda4
ͨ¹ýÔËÐÐÒÔÏÂÃüÁîÀ´Ê¹½»»»ÎļþÉúЧ¡£
$ sudo swapon /dev/sda4
°ÑÐÂÔöµÄ½»»»ÎļþÌí¼Óµ½ fstab ÎļþÖУ¬ÕâÑù¼´Ê¹ÊÇÖØÆôÁËϵͳ½»»»·ÖÇøµÄÐÞ¸ÄÒ²ÄÜÉúЧ¡£
$ vi /etc/fstab
/dev/sda4 swap swap defaults 0 0
¼ì²éд´½¨µÄ½»»»Îļþ¡£
$ swapon --show
NAME TYPE SIZE USED PRIO
/dev/sda5 partition 2G 1.3G -1
/swapfile file 1024M 0B -2
/swapfile1 file 1024M 0B -3
/dev/sda4 partition 1G 0B -4
ÎÒ¿ÉÒÔ¿´µ½ÐµĽ»»»·ÖÇø 1GB µÄ /dev/sda4¡£ÖØÆôϵͳ¾Í¿ÉÒÔʹÓÃеĽ»»»·ÖÇøÁË¡£
±¾ÎÄתÔØ×Ô£ºhttp://www.linuxprobe.com/linux-create-partition.html
Ãâ·ÑÌṩ×îÐÂLinux¼¼Êõ½Ì³ÌÊé¼®£¬Îª¿ªÔ´¼¼Êõ°®ºÃÕßŬÁ¦×öµÃ¸ü¶à¸üºÃ£¬¿ªÔ´Õ¾µã£ºhttp://www.linuxprobe.com/
Сº¢Ò»¸ö ÓÚ 2017-09-11 10:48:50·¢±í:
ѧϰһÏ£¬Ð»Ð»·ÖÏí£¡
jackyduys ÓÚ 2017-09-10 17:23:01·¢±í:
Linux ÉϽ»»»·ÖÇøµÄ¼òµ¥²Ù×÷£¬ºÃÓÃ
Ronny ÓÚ 2017-09-10 09:20:26·¢±í:
Linux ÉϽ»»»·ÖÇøµÄ¼òµ¥²Ù×÷£¬ºÃÓÃ