TinyCore 的好處是, 系統跑起來之後, 都在 RAM 中,
所以不會一直存取 MicroSD or USB flash drive, 以免固定讀取
同樣的地方造成 NAND 壽命出問題.
TinyCore 的網站在 http://www.tinycorelinux.net/
建立 server 的步驟有 :
1. create TinyCore system on MicroSD card :
先從 TinyCore 網站下載 RPi 的 image, RPi 只有一種選擇,
不像 x86 有三種 image 選擇.
下載的 piCore-xx-x-x.zip 反解壓成 .img 檔案後,
用 dd 或者 rufus 將 image 寫到 MicroSD card 上.
2. create extra storage space :
將做好的 microSD card 在 RPi 上開機後, login : rc, passwd : piCore
接下來用 fdisk 看系統的分割 :
Disk /dev/mmcblk0: 59 GB, 63218647040 bytes, 123473920 sectors
1929280 cylinders, 4 heads, 16 sectors/track
Units: sectors of 1 * 512 = 512 bytes
Device Boot StartCHS EndCHS StartLBA EndLBA Sectors Size Id Type
/dev/mmcblk0p1 128,0,1 127,3,16 8192 139263 131072 64.0M c Win95 FAT32 (LBA)
/dev/mmcblk0p2 128,0,1 639,3,16 139264 172031 32768 16.0M 83 Linux
ChrootDirectory /home/newuser
ForceCommand internal-sftp
AllowTcpForwarding no#!/bin/sh # If you are booting Tiny Core from a very fast storage such as SSD / NVMe Drive and getting # "ifconfig: SIOCSIFADDR: No such Device" or "route: SIOCADDRT: Network is unreachable" # error during system boot, use this sleep statemet, otherwise you can remove it - sleep .2 # kill dhcp client for eth0 sleep 1 if [ -f /var/run/udhcpc.eth0.pid ]; then kill `cat /var/run/udhcpc.eth0.pid` sleep 0.1 fi # configure interface eth0 ifconfig eth0 192.168.0.1 netmask 255.255.255.0 broadcast 192.168.0.255 up route add default gw 192.168.0.254
echo nameserver 192.168.0.254 > /etc/resolv.conf
iptables -A INPUT -p tcp -s localhost -m tcp -m multiport ! --dports 22,80 -j ACCEPT
iptables -A INPUT -p tcp -m tcp -m multiport ! --dports 22,80 -j DROP
#!/bin/sh
# Block all incoming/outgoing traffic except for ssh
iptables -Z # zero counters
iptables -F # flush (delete) rules
iptables -X # delete all extra chains
# Set default filter policy to DROP
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP
# Allow DNS
#iptables -A INPUT --proto udp --sport 53 --jump ACCEPT
#iptables -A OUTPUT --proto udp --dport 53 --jump ACCEPT
#iptables -A OUTPUT --proto tcp --dport 53 --jump ACCEPT
# Allow unlimited traffic on loopback (localhost)
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
# Allow ssh (22)
iptables -A INPUT -p tcp -m multiport --dports 22 -j ACCEPT
# Continue accepting packets after connection is established (and moved to some random >1024 port)
iptables -A INPUT --match state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT --match state --state ESTABLISHED,RELATED -j ACCEPT