ÆÁ¾ØÅ¥
2015.05.06 / 24:43

OpenWrt¿¡¼­ ½º¿Ò¸Þ¸ð¸® ¼³Á¤ ¹× »ç¿ë

Â÷Àϵ己
Ãßõ ¼ö 205

°øÀ¯±â¿¡ OpenWrt¸¦ ¼³Ä¡ÇÏ¿© »ç¿ëÇÏ´Ùº¸¸é ¸Þ¸ð¸®°¡ ºÎÁ·ÇÑ °æ¿ì°¡ ÀÖ´Ù. ±×·¡¼­ ÀåÂøµÈ USB¿ÜÀåÇϵ忡 ½º¿ÒÆÄÀÏÀ» »ý¼ºÇÏ¿© ½º¿Ò¸Þ¸ð¸®·Î È°¿ëÇÏ´Â ¹æ¹ý¿¡ ´ëÇØ Æ÷½ºÆÃÇغ»´Ù.


1. ÆÐÅ°Áö ¼³Ä¡

¿ì¼± ¾Æ·¡¿Í °°ÀÌ ÆÐÅ°Áö¸¦ ¼³Ä¡ÇÑ´Ù.

root@OpenWrt:/# opkg install swap-utils
Installing swap-utils (2.21.2-1) to root...
Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/swap-utils_2.21.2-1_ar71xx.ipk.
Installing libblkid (2.21.2-1) to root...
Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/libblkid_2.21.2-1_ar71xx.ipk.
Installing libuuid (2.21.2-1) to root...
Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/libuuid_2.21.2-1_ar71xx.ipk.
Configuring libuuid.
Configuring libblkid.
Configuring swap-utils.
root@OpenWrt:/#


2. ½º¿ÒÆÄÀÏ »ý¼º

´ÙÀ½ ¸í·É¾î·Î ½º¿ÒÆÄÀÏÀ» »ý¼ºÇÑ´Ù. ÀÌ¹Ì ¿ÜÀåÇϵ尡 /mnt/usbdrive¿¡ ¸¶¿îÆ®µÈ »óŸ¦ ÀüÁ¦·Î ÇÑ´Ù. ´ç¿¬È÷ /mnt/usbdrive Æú´õ ¹Ø¿¡ 'swap'µð·ºÅ͸®´Â ¾Æ·¡ ¸í·É¾î Àü¿¡ »ý¼ºÇØ¾ß ÇÑ´Ù.

root@OpenWrt:/# dd if=/dev/zero of=/mnt/usbdrive/swap/swapfile count=100000
100000+0 records in
100000+0 records out
root@OpenWrt:/#

ÀÌ °úÁ¤Àº ½Ã°£ÀÌ Á» °É¸°´Ù. 1000ºí·Ï´ç 512KB°¡ ÀâÈ÷´Âµ¥, 100000ºí·ÏÀº 51200KB°¡ ÀâÈ÷°Ô µÈ´Ù. 


3. ½º¿Ò°ø°£ »ý¼º

´ÙÀ½°ú °°ÀÌ ½º¿Ò°ø°£À» »ý¼ºÇÑ´Ù.

root@OpenWrt:/# mkswap /mnt/usbdrive/swap/swapfile
Setting up swapspace version 1, size = 49996 KiB
no label, UUID=2b46f45f-1706-42dc-8285-59897a4fdd62
root@OpenWrt:/# 


4. ½º¿Ò¸Þ¸ð¸® »ç¿ë

¾Æ·¡¿Í °°ÀÌ ½º¿Ò¸Þ¸ð¸®¸¦ ¿Ã¸°´Ù.

root@OpenWrt:/# swapon /mnt/usbdrive/swap/swapfile


5. ½º¿Ò¸Þ¸ð¸® È®ÀÎ

´ÙÀ½°ú °°ÀÌ ½º¿Ò¸Þ¸ð¸®°¡ Á¦´ë·Î ÀâÇû´ÂÁö È®ÀÎÇØ º»´Ù.

root@OpenWrt:/# free

totalusedfreesharedbuffers
Mem:6167220068416040608
-/+ buffers:1946042212
Swap:49996049996


6. ºÎÆýà ÀÚµ¿ ¼³Á¤

°øÀ¯±â ºÎÆýà ½º¿Ò¸Þ¸ð¸®¸¦ Àâ°í ½ÍÀ¸¸é ´ÙÀ½°ú °°ÀÌ ÀÔ·ÂÇÏ¿© ÆÄÀÏÀ» ÆíÁýÇÑ´Ù.

root@OpenWrt:~# vi /etc/rc.local


¾Æ·¡¿Í °°ÀÌ ¿ÜÀåÇÏµå ¸¶¿îÆ®¿Í ½º¿Ò¸Þ¸ð¸® »ç¿ë ¸í·É¾î¸¦ Ãß°¡ÇØÁÖ¸é ºÎÆýà ÀÚµ¿À¸·Î ¼öÇàµÈ´Ù.

# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.

mount -t ext4 /dev/sda1 /mnt/usbdrive
swapon /mnt/usbdrive/swap/swapfile

exit 0


7. ½º¿Ò¸Þ¸ð¸® ÇØÁ¦

½º¿Ò¸Þ¸ð¸® »ç¿ëÀ» ÇØÁ¦ÇÏ·Á¸é ´ÙÀ½°ú °°ÀÌ ÀÔ·ÂÇÑ´Ù.

root@OpenWrt:~# swapoff /mnt/usbdrive/swap/swapfile


±×¸®°í free ¸í·ÉÀ¸·Î È®ÀÎÇØ º¸¸é ½º¿Ò¸Þ¸ð¸®°¡ ÇØÁ¦µÇ¾î ÀÖÀ½À» º¼ ¼ö ÀÖ´Ù.

root@OpenWrt:~# free

totalusedfreesharedbuffers
Mem:6167258252342001228
-/+ buffers:570244648
Swap:000