

{"id":603,"date":"2015-07-30T17:41:23","date_gmt":"2015-07-30T08:41:23","guid":{"rendered":"https:\/\/curecode.jp\/tech\/?p=603"},"modified":"2015-07-30T17:41:23","modified_gmt":"2015-07-30T08:41:23","slug":"raspberrypi-ramdisk","status":"publish","type":"post","link":"https:\/\/curecode.jp\/tech\/raspberrypi-ramdisk\/","title":{"rendered":"Raspberry Pi\u306e\u30ed\u30b0\u3092RAMDISK\u306b\u7f6e\u304f\u65b9\u6cd5"},"content":{"rendered":"<p>\u7518\u304f\u306a\u3044\u30e9\u30ba\u30d9\u30ea\u30fc\u30d1\u30a4\u3053\u3068<a href=\"http:\/\/www.raspberrypi.org\" target=\"_blank\">RaspberryPi<\/a>\u306etmp\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3084\u30ed\u30b0\u30d5\u30a1\u30a4\u30eb\u3092RAMDISK\u306b\u7f6e\u304f\u65b9\u6cd5\u3067\u3059\u3002<\/p>\n<p>\u5b89\u4fa1\u3067\u7701\u96fb\u529b\u7701\u30b9\u30da\u30fc\u30b9\u3001\u9759\u304b\u306aLinux\u30de\u30b7\u30f3\u3068\u3057\u3066\u4f7f\u3048\u3001\u306a\u304a\u304b\u3064GPIO\u7aef\u5b50\u3082\u5099\u3048\u3066\u304a\u308a\u3001\u5404\u7a2e\u30bb\u30f3\u30b5\u30fc\u7b49\u3092\u63a5\u7d9a\u3059\u308b\u3053\u3068\u3067\u3053\u306e\u9803\u6d41\u884c\u308a\u306eIoT(Internet of Things)\u30c7\u30d0\u30a4\u30b9\u3082\u958b\u767a\u3067\u304d\u3061\u3083\u3046Raspberry Pi\uff08\u4ee5\u4e0b\u30e9\u30ba\u30d1\u30a4\uff09\u3002<\/p>\n<p>Apache\u7b49\u3092\u5c0e\u5165\u3057\u3066\u5e38\u6642\u7a3c\u52d5\u306eWeb\u30b5\u30fc\u30d0\u30fc\u3068\u3057\u3066\u3082\u4f7f\u3048\u308b\u30e9\u30ba\u30d1\u30a4\u3067\u3059\u304c\u3001\u30e9\u30ba\u30d1\u30a4\u306e\u8a18\u61b6\u88c5\u7f6e\u306fHDD\u3067\u306f\u306a\u304fmicroSD\u30ab\u30fc\u30c9\u3067\u3059\u3002\u306a\u306e\u3067swap\u3092\u4f7f\u7528\u3057\u305f\u308a24\u6642\u9593\u7a3c\u52d5\u3067Apache\u306e\u30ed\u30b0\u30d5\u30a1\u30a4\u30eb\u7b49\u3092\u66f8\u304d\u3053\u3093\u3067\u3044\u304f\u3068\u66f8\u304d\u8fbc\u307f\u56de\u6570\u5236\u9650\u306b\u3088\u308aSD\u30ab\u30fc\u30c9\u306e\u5bff\u547d\u304c\u3069\u3093\u3069\u3093\u524a\u308c\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067swap\u30d5\u30a1\u30a4\u30eb\u306e\u4f5c\u6210\u3092\u505c\u6b62\u3055\u305b\u3001RAMDISK\u3092\u4f5c\u6210\u3057\u3066SD\u30ab\u30fc\u30c9\u306e\u5ef6\u547d\u3092\u56f3\u308b\u305f\u3081\u306e\u624b\u9806\u3067\u3059\u3002<\/p>\n<p>(\u4f7f\u7528OS\u306fRaspbian\u3067\u3059\u3002)<\/p>\n<h3>1.swap\u3092\u7121\u52b9\u5316<\/h3>\n<p>free\u3067\u78ba\u8a8d\u3059\u308b\u3068swap\u30d5\u30a1\u30a4\u30eb\u304c100MB\u307b\u3069\u3042\u308b\u306e\u304c\u308f\u304b\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\" title=\"free\">free\r\n             total       used       free     shared    buffers     cached\r\nMem:        949408     469904     479504          0      30172     263712\r\n-\/+ buffers\/cache:     176020     773388\r\nSwap:       102396          0     102396<\/pre>\n<p>swap\u3092\u7121\u52b9\u5316\u3057\u307e\u3059<\/p>\n<pre class=\"lang:default decode:true \">sudo swapoff --all\r\nfree\r\n             total       used       free     shared    buffers     cached\r\nMem:        949408     469904     479504          0      30172     263712\r\n-\/+ buffers\/cache:     176020     773388\r\nSwap:       \u3000\u3000\u3000\u3000\u30000          0     \u3000\u3000\u3000\u3000\u30000<\/pre>\n<p>SWAP\u304c\u6d88\u3048\u307e\u3057\u305f<\/p>\n<p>\u3053\u306e\u307e\u307e\u3060\u3068\u518d\u8d77\u52d5\u3057\u305f\u6642\u306bswap\u304c\u5fa9\u6d3b\u3059\u308b\u306e\u3067<\/p>\n<pre class=\"lang:default decode:true \">sudo apt-get remove dphys-swapfile<\/pre>\n<p>\u3067swap\u3092\u81ea\u52d5\u751f\u6210\u3059\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u6d88\u3057\u307e\u3059\u3002<\/p>\n<p>reboot\u3057\u3066free\u3067swap\u304c\u751f\u6210\u3055\u308c\u3066\u3044\u306a\u3044\u306e\u3092\u78ba\u8a8d\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u5e38\u6642\u7a3c\u52d5\u306eweb\u30b5\u30fc\u30d0\u30fc\u3068\u3057\u3066\u4f7f\u308f\u306a\u3044\u306a\u3089swap\u3092\u6d88\u3059\u3060\u3051\u3067\u3082\u5ef6\u547d\u5de5\u4f5c\u3068\u3057\u3066\u306f\u5341\u5206\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<\/p>\n<h3>2.RAM\u30c7\u30a3\u30b9\u30af\u306e\u4f5c\u6210<\/h3>\n<p>\u6b21\u306fRAMDISK\u306bApache\u306e\u30ed\u30b0\u3084\u4e00\u6642\u30d5\u30a1\u30a4\u30eb\u3092\u79fb\u3057\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002\u307e\u305afstab\u3092\u7de8\u96c6\u3057\u3066\u30de\u30a6\u30f3\u30c8\u8a2d\u5b9a\u306e\u5909\u66f4\u3092\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">sudo vim \/etc\/fstab\u3000\r\n\r\nproc            \/proc           proc    defaults          0       0\r\n\/dev\/mmcblk0p5  \/boot           vfat    defaults          0       2\r\n\/dev\/mmcblk0p6  \/               ext4    defaults,noatime  0       1\r\n# a swapfile is not a swap partition, so no using swapon|off from here on, use  dphys-swapfile swap[on|off]  for that\r\n#### ramdisk\r\n\/\/\u4ee5\u4e0b\u3092\u8ffd\u52a0\r\ntmpfs           \/tmp            tmpfs   defaults,size=32m 0       0\r\ntmpfs           \/var\/tmp        tmpfs   defaults,size=16m 0       0\r\ntmpfs           \/var\/log        tmpfs   defaults,size=32m 0       0\r\ntmpfs           \/var\/www\/mrtg   tmpfs   defaults,size=2m  0       0<\/pre>\n<p>\u7de8\u96c6\u3057\u7d42\u3048\u305f\u3089reboot\u3057\u3066\u30de\u30a6\u30f3\u30c8\u78ba\u8a8d\u3092\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"lang:vim decode:true\">df -h\r\n\r\n\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9   \u30b5\u30a4\u30ba  \u4f7f\u7528  \u6b8b\u308a \u4f7f\u7528% \u30de\u30a6\u30f3\u30c8\u4f4d\u7f6e\r\nrootfs            28G  2.9G   24G   11% \/\r\n\/dev\/root         28G  2.9G   24G   11% \/\r\ndevtmpfs         460M     0  460M    0% \/dev\r\ntmpfs             93M  272K   93M    1% \/run\r\ntmpfs            5.0M     0  5.0M    0% \/run\/lock\r\ntmpfs            186M     0  186M    0% \/run\/shm\r\n\/dev\/mmcblk0p5    60M   19M   42M   32% \/boot\r\ntmpfs             32M  8.0K   32M    1% \/tmp\r\ntmpfs             16M     0   16M    0% \/var\/tmp\r\ntmpfs             32M  2.0M   31M    7% \/var\/log\r\n\/dev\/mmcblk0p3    27M  444K   25M    2% \/media\/SETTINGS\r\n<\/pre>\n<p>tmpfs\u304c\u304d\u3061\u3093\u3068\u30de\u30a6\u30f3\u30c8\u3055\u308c\u3066\u3044\u307e\u3059\u306d\u3002<\/p>\n<p>RAMDISK\u306b\u79fb\u3059\/var\/log \u5185\u306e\u30d5\u30a1\u30a4\u30eb\u306e\u6e96\u5099\u3092\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u8d77\u52d5\u6642\u306b\/var\/log\u4ee5\u4e0b\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u4f5c\u6210\u3059\u308binit\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true \">vim \/etc\/init.d\/make-varlog-files\r\n\r\n#!\/bin\/bash\r\n#\r\n### BEGIN INIT INFO\r\n# Provides:          make-varlog-files\r\n# Default-Start:     2 3 4 5\r\n# Default-Stop:      0 1 6\r\n# Required-Start:\r\n# Required-Stop:\r\n# Short-Description: Create \/var\/log\/... files on tmpfs at startup\r\n# Description:       Create \/var\/log\/... files needed by system daemon\r\n### END INIT INFO\r\n\r\n#\r\n# main()\r\n#\r\ncase \"${1:-''}\" in\r\n  'start')\r\n\r\n    ############################\r\n    # prepare \/var\/log subdir for ramdisk init on every boot\r\n\r\n    mkdir -p \/var\/log\/ConsoleKit\r\n    mkdir -p \/var\/log\/apache2\r\n    mkdir -p \/var\/log\/apt\r\n    mkdir -p \/var\/log\/fsck\r\n    mkdir -p \/var\/log\/ntpstats\r\n    mkdir -p \/var\/log\/samba\r\n\r\n    chown root.adm \/var\/log\/apache2\r\n    chmod 750 \/var\/log\/apache2\r\n    chown ntp.ntp \/var\/log\/ntpstats\r\n    chown root.adm \/var\/log\/samba\r\n\r\n    ############################\r\n    # prepare \/var\/log file for ramdisk init on every boot\r\n\r\n    touch \/var\/log\/lastlog\r\n    touch \/var\/log\/wtmp\r\n    touch \/var\/log\/btmp\r\n    touch \/var\/log\/apache2\/access.log\r\n    touch \/var\/log\/apache2\/error.log\r\n    touch \/var\/log\/apache2\/other_vhosts_access.log\r\n    touch \/var\/log\/apache2\/ssl_access.log\r\n\r\n    chown root.adm  \/var\/log\/apache2\r\n    chown root.adm \/var\/log\/apache2\/access.log\r\n    chmod 640 \/var\/log\/apache2\/access.log\r\n    chown root.adm \/var\/log\/apache2\/error.log\r\n    chmod 640 \/var\/log\/apache2\/error.log\r\n    chown root.utmp \/var\/log\/lastlog\r\n    chown root.utmp \/var\/log\/wtmp\r\n    chown root.utmp \/var\/log\/btmp\r\n   ;;\r\n  'stop')\r\n   ;;\r\n  'restart')\r\n   ;;\r\n  'reload'|'force-reload')\r\n   ;;\r\n  'status')\r\n   ;;\r\n  *)\r\n   echo \"Usage: $SELF start\"\r\n   exit 1\r\n   ;;\r\nesac<\/pre>\n<p>\u3053\u306einit\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u8d77\u52d5\u7528\u30ea\u30f3\u30af\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true \">sudo update-rc.d make-varlog-files defaults 01 10<\/pre>\n<p>\u4f55\u304b\u30a8\u30e9\u30fc\u51fa\u3066\u307e\u3059\u306d&#8230;\u3002<\/p>\n<pre class=\"lang:default decode:true \">&gt;insserv: script make-varlog-files is not an executable regular file, skipped!<\/pre>\n<p>\u305d\u3046\u3044\u3048\u3070\u5b9f\u884c\u6a29\u4ed8\u3051\u5fd8\u308c\u3066\u307e\u3057\u305f\u306d\u3002chmod\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"lang:default decode:true \">chmod 755 \/etc\/init.d\/make-varlog-files<\/pre>\n<p>\u3053\u308c\u3067\u3082\u3046\u4e00\u5ea6\u30ea\u30f3\u30af\u3092\u4f5c\u6210\u3059\u308b\u3068\u30a8\u30e9\u30fc\u3082\u306a\u304f\u901a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u6700\u5f8c\u306b\u30e9\u30f3\u30ec\u30d9\u30eb\uff12\u7528\u306e\u8d77\u52d5\u30b9\u30af\u30ea\u30d7\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u78ba\u8a8d\u3057\u3068\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"lang:default decode:true \">ls \/etc\/rc2.d\/\r\nK05nfs-common  S01cgroup-bin         S01motd          S02apache2         S03mysql  S03vsftpd        S05rc.local\r\nK05rpcbind     S01dhcpcd             S01rsyslog       S03cron            S03ntp    S04avahi-daemon  S05rmnologin\r\nREADME         S01ifplugd            S01sudo          S03dbus            S03rsync  S04lightdm\r\nS01bootlogs    S01make-varlog-files  S01triggerhappy  S03dphys-swapfile  S03ssh    S05plymouth<\/pre>\n<p>\u3053\u3053\u3067\u3001<code>S01make-varlog-files<\/code>\u304c<code>S02apache2<\/code>\u3088\u308a\u82e5\u3044\u6570\u5b57\u306b\u6307\u5b9a\u3055\u308c\u3066\u308b\u306e\u3067Apache\u306e\u8d77\u52d5\u6761\u4ef6\u3068\u3057\u3066\u306f\u554f\u984c\u306a\u3044\u3067\u3059\u3002<\/p>\n<p>\u3053\u308c\u3067\u30e9\u30ba\u30d1\u30a4\u306e\u4e00\u6642\u30d5\u30a1\u30a4\u30eb\u3084\u30ed\u30b0\u304cRAMDISK\u306b\u4fdd\u5b58\u3055\u308c\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002\u5ef6\u547d\u5de5\u4f5c\u5b8c\u4e86\u3067\u3059\u3002<\/p>\n<p>\u3053\u306e\u72b6\u614b\u3060\u3068RAMDISK\u306b\u30ed\u30b0\u304c\u8a18\u9332\u3055\u308c\u3066\u3044\u304f\u305f\u3081\u3001\u305d\u306e\u307e\u307e\u30e9\u30ba\u30d1\u30a4\u306e\u96fb\u6e90\u3092\u843d\u3068\u3059\u3068\u30ed\u30b0\u306f\u6d88\u3048\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<p>\u4f55\u304b\u8a18\u9332\u3057\u3066\u304a\u304d\u305f\u3044\u30ed\u30b0\u304c\u3042\u308b\u5834\u5408\u3001cron\u3067\u5b9a\u6642\u30b7\u30e3\u30c3\u30c8\u30c0\u30a6\u30f3\u524d\u306b\u30e1\u30fc\u30eb\u3067\u30ed\u30b0\u3092\u9001\u4fe1\u3059\u308b\u3088\u3046\u306b\u3057\u305f\u308a\u5b9a\u671f\u7684\u306b\u30ed\u30b0\u3092SD\u30ab\u30fc\u30c9\u306b\u66f8\u304d\u51fa\u3059\u3088\u3046\u306b\u3059\u308b\u3068\u3044\u3044\u3067\u3059\u3002<\/p>\n<h3>IT\u30a8\u30f3\u30b8\u30cb\u30a2\u52df\u96c6\u4e2d\uff01<\/h3>\n<p>\u30ad\u30e5\u30a2\u30b3\u30fc\u30c9\u682a\u5f0f\u4f1a\u793e\u306fIT\u30a8\u30f3\u30b8\u30cb\u30a2\u3092\u52df\u96c6\u3057\u3066\u304a\u308a\u307e\u3059\u3002\u5c11\u4eba\u6570\u306e\u8077\u5834\u306a\u306e\u3067\u3001\u4e0a\u6d41\u30fb\u4e0b\u6d41\u3084\u30b5\u30fc\u30d0\u30fc\u30fb\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u5bfe\u5fdc\u306e\u57a3\u6839\u306a\u304f\u3001\u3042\u306a\u305f\u306e\u5f37\u307f\u3092\u6d3b\u304b\u3057\u306a\u304c\u3089 \u3044\u308d\u3044\u308d\u306a\u3053\u3068\u306b\u30c1\u30e3\u30ec\u30f3\u30b8\u53ef\u80fd\u3067\u3059\u3002\u30a8\u30f3\u30b8\u30cb\u30a2\u3068\u3057\u3066\u306e\u672a\u7d4c\u9a13\u306e\u65b9\u3001\u7d4c\u9a13\u304c\u5c11\u306a\u3044\u65b9\u3082\u6b53\u8fce\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u4e0b\u8a18\u3088\u308aIT\u30a8\u30f3\u30b8\u30cb\u30a2\u52df\u96c6\u306e\u63a1\u7528\u60c5\u5831\u3092\u3054\u89a7\u3044\u305f\u3060\u3051\u307e\u3059\u3002<\/p>\n<div class=\"curecode_recruit_bn\">\n\t\t\t\t<a href=\"https:\/\/curecode.jp\/recruit\/itengineer\/\" target=\"_blank\" rel=\"noopener noreferrer\"><br \/>\n\t\t\t\t\t\t<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/curecode.jp\/tech\/wp-content\/themes\/tech\/images\/it_recruit.png?20241220\" alt=\"\u4e8b\u696d\u62e1\u5927\u306b\u4f34\u3044\u65b0\u3057\u3044\u9818\u57df\u306b\u4e00\u7dd2\u306b\u53d6\u308a\u7d44\u3093\u3067\u3044\u304f\u30e1\u30f3\u30d0\u30fc\u3092\u52df\u96c6\u3057\u307e\u3059\u3002\"  width=\"500\" height=\"180\"\/><br \/>\n\t\t\t\t<\/a>\n\t\t<\/div>\n<h3>\u30ad\u30e5\u30a2\u30b3\u30fc\u30c9\u516c\u5f0f\u30a4\u30f3\u30b9\u30bf\u30b0\u30e9\u30e0<\/h3>\n<p>\u30ad\u30e5\u30a2\u30b3\u30fc\u30c9\u682a\u5f0f\u4f1a\u793e\u306e\u65b0\u30b5\u30fc\u30d3\u30b9\u60c5\u5831\u3084\u3001\u30aa\u30d5\u30a3\u30b9\u30e9\u30a4\u30d5\u306e\u7d20\u6575\u306a\u77ac\u9593\u307e\u3067\u3002\u79c1\u305f\u3061\u306e\u65e5\u3005\u306e\u55b6\u307f\u3092\u3054\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<div class=\"curecode_recruit_bn\">\n\t\t\t\t<a href=\"https:\/\/www.instagram.com\/curecode\/\" target=\"_blank\" rel=\"noopener noreferrer\"><br \/>\n\t\t\t\t\t\t<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/curecode.jp\/tech\/wp-content\/themes\/tech\/images\/insta_bn.png?20241220\" alt=\"\u4e8b\u696d\u62e1\u5927\u306b\u4f34\u3044\u65b0\u3057\u3044\u9818\u57df\u306b\u4e00\u7dd2\u306b\u53d6\u308a\u7d44\u3093\u3067\u3044\u304f\u30e1\u30f3\u30d0\u30fc\u3092\u52df\u96c6\u3057\u307e\u3059\u3002\"  width=\"500\" height=\"180\"\/><br \/>\n\t\t\t\t<\/a>\n\t\t<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u7518\u304f\u306a\u3044\u30e9\u30ba\u30d9\u30ea\u30fc\u30d1\u30a4\u3053\u3068RaspberryPi\u306etmp\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3084\u30ed\u30b0\u30d5\u30a1\u30a4\u30eb\u3092RAMDISK\u306b [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":649,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[74],"class_list":["post-603","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","tag-raspberrypi"],"_links":{"self":[{"href":"https:\/\/curecode.jp\/tech\/wp-json\/wp\/v2\/posts\/603","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/curecode.jp\/tech\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/curecode.jp\/tech\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/curecode.jp\/tech\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/curecode.jp\/tech\/wp-json\/wp\/v2\/comments?post=603"}],"version-history":[{"count":25,"href":"https:\/\/curecode.jp\/tech\/wp-json\/wp\/v2\/posts\/603\/revisions"}],"predecessor-version":[{"id":652,"href":"https:\/\/curecode.jp\/tech\/wp-json\/wp\/v2\/posts\/603\/revisions\/652"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/curecode.jp\/tech\/wp-json\/wp\/v2\/media\/649"}],"wp:attachment":[{"href":"https:\/\/curecode.jp\/tech\/wp-json\/wp\/v2\/media?parent=603"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/curecode.jp\/tech\/wp-json\/wp\/v2\/categories?post=603"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/curecode.jp\/tech\/wp-json\/wp\/v2\/tags?post=603"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}