I put Alpine Linux in Larkbox and made it my home server

Introduction

INDIGOGO crowdfunding CHUWI LarkBox . A very small PC with a housing size of 61x61x43 (H) mm and a weight of 127 g. Windows 10 Home is pre-installed. The specifications are as follows.

Device Spec
CPU Intel Celeron J4115
RAM 6GB LPDDR4
storage 128GB eMMC
Wi-Fi 802.11a/ac/b/g/n
Bluetooth 5.1

In addition, there is a 2242 size SATA SSD slot, which can be expanded up to 2TB. It is sold on the mail order site at a price of about 20,000 yen. The investment amount of crowdfunding was about 16,000 yen, so it's a little profitable.

If you search for "NUC" on Amazon, you will find a mountain of tiny PCs with a concept similar to LarkBox. If you want to get it cheaply by crowdfunding, as of 2020/9, INDIGOGO is soliciting GMK NucBox , so why not apply?

LarkBox is a poor spec to use as a Windows PC, so put Alpine Linux and use it as your home server. Since it has a TDP of 10W, it generates very little heat and consumes power, so I think it is suitable for servers. However, since there is no wired LAN port, it is fatal as a server. .. .. In the streets, it seems that some people use Raspberry Pi 4 as their home server, and although Raspberry Pi 4 has a wired LAN port, the CPU is powerless and it should be about a file server, but it is true that the web application runs hard I think it's impossible. I would like to confirm how much it can be done with LarkBox.

This article is a reminder of the procedure for putting Alpine Linux in LarkBox.

It's not a very tantalizing shot, but I'll give you a photo. Footprint similar to 4 AA batteries.

larkbox.jpg

Larkbox setup

On my home server, I also want to run Time Capsule for Mac backup, so 128GB of storage is not enough. Therefore, add 1TB M2.SSD. Open the back cover and insert it into the slot. The housing is made of resin, which seems to have low heat dissipation performance, and when the resin back cover is opened, there is a resin inner lid, and the base is inside. SSDs are trapped in a narrow space between the inner lid and the back cover where no air flows, and heat dissipation is quite anxious.

To enter the BIOS, press the power button and then press the escape key repeatedly.

Install Alpine Linux

Download and install the EXTENDED package from the Alpine Linux site . At first, I tried to install the STANDARD package, but the STANDARD package is too minimal to use without even pinging. The 128GB storage is so huge for Alpine Linux that I prefer the EXTENDED package here.

Burn the downloaded ISO file alpine-extended-3.12.0-x86_64.iso to a USB stick and boot from it. Log in as root. (No root password)

 setup-alpine

Start the installation with. The Alpine Linux installer doesn't look like a major distribution installer. It is necessary to answer the questions one by one interactively.

Windows Home was pre-installed on eMMC, but I removed it without hesitation. I'll put the root and swap here, and put / var (250GB) and / home (750GB) on SSD1TB. I'm thinking of installing only docker directly, and installing necessary apps with docker-compose. Therefore, reserve a large / var used by docker. I think there is an idea that the route should be put in SSD instead of slow eMMC. I thought so, but it didn't change much, so I think eMMC is okay with the route.

The response at the time of installation is as follows.

Select keyboard layout: jp
Available variants: jp
Enter system hostname: larkbox
Which one do you want to initialize?: wlan0
Type the wireless network name to connect to: *******
Type the "*******" network Pre-Shared Key: *******
Ip address for wlan0: 192.168.1.xx
Netmask?: 255.255.255.0
Gateway: 192.168.1.1
DNS domain name?
DNS nameserver(s)?: 192.168.1.1
New password: *******
Retype Password: *******
Which timezone are you in?: Asia/Tokyo
TP/FTP proxy URL?: none
Enter mirror number (1-43) or URL to add: f
Which SSH server? (‘openssh’, ‘dropbear’ or ‘none’): openssh
Which NTP client to run? (‘busybox’, ‘openntpd’, ‘chrony’, or ‘none’):chrony
Which disk(s) would you like to use?: mmcblk0
How would you like to use it?: sys 

For the installation, I referred to the following article. https://qiita.com/mo_chiee/items/f539df1bd172f41bc85a Alpine Linux 3.10.3 installation instructions

https://qiita.com/tohka383/items/e7d758a6281fa45e5e16 Docker on Alpine Linux on VirtualBox

After answering all the installation questions, update the package repository.

Modify / etc / apk / repositories as follows

/media/cdrom/apks
http://sjc.edge.kernel.org/alpine/v3.12/main
http://sjc.edge.kernel.org/alpine/v3.12/community
http://sjc.edge.kernel.org/alpine/edge/main
http://sjc.edge.kernel.org/alpine/edge/community
http://sjc.edge.kernel.org/alpine/edge/testing

Updated with the following command.

 apk update
 apk upgrade

Insert Docker

 apk add docker docker-compose
 service docker start
 rc-update add docker boot

Allow sudo

 apk add sudo
 visudo
 %wheel ALL=(ALL) ALL

To

%wheel ALL=(ALL) ALL

change to

Add your own login account

 addgroup wheel
# adduser my login account
# adduser my login account wheel
# adduser login account docker

Power off once

 poweroff

It's not shutdown.

Remove the USB memory and change the BIOS settings to boot from the eMMC. When I boot, oh, the network isn't connected! Did I have to persist the settings immediately after installation?

Continued installation

network settings

The first series of installations was done with the setup-alpine script, but there is a setup-xxxx script that installs only the individual items. Of the installation script, the network settings part

 setup-interfaces

Connect to Wifi again.

Which one do you want to initialize?: wlan0
Type the wireless network name to connect to: *******
Type the "*******" network Pre-Shared Key: *******
Ip address for wlan0: 192.168.1.xx
Netmask?: 255.255.255.0
Gateway: 192.168.1.1

Don't forget to make the connection persistent.

 rc-update add wpa_supplicant boot

Disk settings

In the initial installation, I partitioned the root and swap into the eMMC and installed the system, but the added 1TB SSD remains untouched. So, next, enable 1TB SSD.

 setup-disk

I want to set / var (250GB) and / home (750GB) to be placed on SSD1TB, but the setup-disk script seems to cut only one partition.

Available disks are:
  sda   (1024.2 GB ATA      NT-1TB-TM       )
Which disk(s) would you like to use? (or '?' for help or 'none') [sda]
How would you like to use it? ('sys', 'data', 'lvm' or '?' for help) [?] data

Looking at what happened to the disc with this,

 df -h
Filesystem                Size      Used Available Use% Mounted on
devtmpfs                 10.0M         0     10.0M   0% /dev
shm                       2.8G         0      2.8G   0% /dev/shm
/dev/mmcblk0p3          110.2G      1.2G    103.4G   1% /
tmpfs                   576.6M    228.0K    576.4M   0% /run
/dev/mmcblk0p1          511.0M    272.0K    510.7M   0% /boot/efi
/dev/sda2               934.0G         0    934.0G   0% /var
cgroup_root              10.0M         0     10.0M   0% /sys/fs/cgroup

/ Var was created on SSD1TB (sda). Delete the / var partition and create / var (250GB) and / home (750GB) again.

Get partitioning tool

 apk add -U gptfdisk sgdisk
 gdisk /dev/sda

To repartition sda. The usage of gdisk is the same as fdisk.

Original partition

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         8390655   4.0 GiB     8200
   2         8390656      2000409230   949.9 GiB   8300

Partition after change

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         8390655   4.0 GiB     8200
   2         8390656       506395300   237.5 GiB   8300  Linux filesystem
   3       506396672      2000409230   712.4 GiB   8300  Linux filesystem

Reboot once

 reboot

Format disk

 mkfs.ext4 /dev/sda2
 mkfs.ext4 /dev/sda3

Check the UUID of the disk

 blkid
/dev/mmcblk0p3: UUID="4594ac58-ef59-420e-93f1-423b09cb92ee" TYPE="ext4"
/dev/mmcblk0p2: UUID="387d4b96-060b-4906-80a7-0c066015d468" TYPE="swap"
/dev/mmcblk0p1: UUID="801B-8E71" TYPE="vfat"
/dev/sda3: UUID="346cbfb9-e881-430b-9005-41881ef5bf1c" TYPE="ext4"
/dev/sda2: UUID="14c53e65-b833-4961-b760-3697ea52acbb" TYPE="ext4"
/dev/sda1: UUID="0fe2b3e9-1468-4a73-aa41-a8eed52f91a8" TYPE="swap"

Added mount point to / etc / fstab

UUID=14c53e65-b833-4961-b760-3697ea52acbb       /var            ext4    defaults 1 2
UUID=346cbfb9-e881-430b-9005-41881ef5bf1c       /home            ext4    defaults 1 2

reboot

 reboot

Verification

 df -h
Filesystem                Size      Used Available Use% Mounted on
devtmpfs                 10.0M         0     10.0M   0% /dev
shm                       2.8G         0      2.8G   0% /dev/shm
/dev/mmcblk0p3          110.2G      1.2G    103.3G   1% /
tmpfs                   576.6M    228.0K    576.4M   0% /run
/dev/mmcblk0p1          511.0M    272.0K    510.7M   0% /boot/efi
/dev/sda2               232.7G     60.4M    220.8G   0% /var
/dev/sda3               700.2G     72.0M    664.5G   0% /home
cgroup_root              10.0M         0     10.0M   0% /sys/fs/cgroup

System installation complete.

Package installation

Only docker, nginx, and samba are installed directly. nginx is used as a reverse proxy that bundles multiple web applications. If you run samba with docker, fine credential control is complicated, so insert it directly.

docker is already installed when the system is installed.

samba

samba installation

 apk add samba

/etc/samba/smb.conf settings

[global]
   unix charset = UTF-8
   dos charset = CP932
   workgroup = WORKGROUP
   server string = %h server (Samba, Alpine)
   dns proxy = no
   interfaces = 127.0.0.0/8 192.168.1.0/24
   bind interfaces only = yes
   map to guest = Bad User
   log file = /var/log/samba/log.%m
   max log size = 1000
   syslog = 0
   panic action = /usr/share/samba/panic-action %d
   server role = standalone server
   passdb backend = tdbsam
   obey pam restrictions = yes
   unix password sync = no
   passwd program = /usr/bin/passwd %u
   passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
   pam password change = yes
   map to guest = bad user
   usershare allow guests = yes
   fruit:metadata = netatalk
   fruit:encoding = native

[larkbox]
   path = /home/samba/share/
   writable = yes
   browseable = yes
   guest ok = no
   guest only = no
   create mode = 0664
   directory mode = 0775
 valid user = my account

[TimeCapsule]
   comment = Backup for Mac Computers
   path = /home/samba/timecapsule
   writable = yes
   browsable = yes
   guest ok = no
   fruit:time machine = yes
   uit:time machine max size = 500M
 valid user = my account

user registration

# pdbedit -a -u my account

samba restart

 service samba restart

Startup settings

 rc-update add samba

Set to enable name resolution of host name

 apk add avahi
 apk add dbus
 rc-update add dbus
 rc-update add avahi-daemon
 service avahi-daemon restart

/ etc / avahi / services settings

<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
    <name replace-wildcards="yes">%h</name>
    <service>
        <type>_smb._tcp</type>
        <port>445</port>
    </service>
</service-group>

Service restart

 service avahi-daemon restart

nginx

install nginx

 apk add nginx

Create /etc/nginx/conf.d/default.conf

server {
    listen 80;

    server_name larkbox;
    client_max_body_size 128m;

    index index.html index.htm index.php;

    location / {
        proxy_pass http://localhost:8080/;
        access_log off;
    }

}

Start nginx.

 /etc/init.d/nginx start

Startup settings

 rc-update add nginx

Web app installation

Web apps you want to put in are docker-compose from one end.

For the time being, try installing apache and docker management tool Portainer.

Apache+php+MySQL

I have set apache to access on port 8080, but I can access it on port 80 via the nginx reverse proxy. When accessing the server in the home LAN from the iPhone, the hosts file cannot be set on the iPhone, so the name must be resolved by the proxy server. Therefore, apache also has a proxy server function. The proxy port number was 8888.

docker-compose.yaml

version: '3'

services:
  php:
    image: php:7.2-apache
    volumes:
      - ./php.ini:/usr/local/etc/php/php.ini
      - ./html:/var/www/html
      - ./apache2/apache2.conf:/etc/apache2/apache2.conf
      - ./apache2/proxy-html.conf:/etc/apache2/proxy-html.conf
      - ./apache2/hosts:/etc/hosts
    ports:
      - 8080:80
      - 8888:8888
    restart: always
  mysql:
    image: mysql:5.7
    volumes:
      - ./mysql:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=root
      - MYSQL_DATABASE=test
      - MYSQL_USER=test
      - MYSQL_PASSWORD=test
    restart: always
  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    environment:
      - PMA_ARBITRARY=1
      - PMA_HOST=mysql
      - PMA_USER=test
      - PMA_PASSWORD=test
    links:
      - mysql
    ports:
      - 4040:80
    volumes:
      - ./phpmyadmin/sessions:/sessions
    restart: always

./apache2/apache2.conf

LoadModule proxy_html_module /usr/lib/apache2/modules/mod_proxy_html.so
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
LoadModule proxy_connect_module /usr/lib/apache2/modules/mod_proxy_connect.so
LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so
 
<IfModule proxy_html_module>
  Include /etc/apache2/proxy-html.conf
</IfModule>

./apache2/proxy-html.conf

<IfModule mod_proxy.c>
  ProxyRequests On
  ProxyVia On
  Listen 8888
  <Proxy *>
    Order deny,allow
    Deny from all
    Allow from all
  </Proxy>
</IfModule>

./apache2/hosts

127.0.0.1       localhost
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.27.0.2      450ce809bc23
192.168.1.2     centos7
127.0.0.1       localhost
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.27.0.2      450ce809bc23
192.168.1.x     larkbox
 192.168.1.1 Home router name

Start-up

$ docker-compose up -d

with this, http://larkbox:8080/ Allows access to apache, but with nginx reverse proxy http://larkbox/ You will be able to access it with.

Portainer

docker-compose.yaml

version: '2'
services:
  portainer:
    image: portainer/portainer
    ports:
      - 9000:9000
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
	  - ./data:/data
    restart: always

Start-up

$ docker-compose up -d

with this, http://larkbox:9000/ You will be able to access it with If you add the nginx configuration file /etc/nginx/conf.d/default.conf as follows,

/etc/nginx/conf.d/default.conf

server {
    ...
    location /portainer/ {
        proxy_pass http://localhost:9000;
        rewrite /portainer/(.*)$ /$1 break;
        access_log off;
    }

http://larkbox/portainer You will be able to access it with.

What is the essential performance as a server?

Before the introduction of Larkbox, the server was CentOS 7 (memory 8GB) on VirtualBox on Windows Pro on Nuc (memory 32GB) of Core i7-8559U, but there is not much change in experience. Impression that it can be used reasonably though it is a server without a wired LAN.

I also tried it with a shit heavy app. I installed Fess13 and crawled it, but just displaying the top page of Fess13 is crappy. But that doesn't mean it doesn't work. I was able to crawl.

The heat dissipation that I was worried about seems to be okay.

A good server is ready.

Recommended Posts

I put Alpine Linux in Larkbox and made it my home server
Since the font size and window size are large in Zoom for Linux, I made it smaller
I put Linux (Ubuntu) in VAIO SX14.
Put Docker in Windows Home and run a simple web server with Python
Put Linux in your Chromebook and use R ...
I made a script to put a snippet in README.md
I made my goimports
I made a server with Python socket and ssl and tried to access it from a browser
I want to copy an English paper from pdf and put it in Google Translate
I made my own OSS because I wanted to contribute to it
I made it because I want JSON data that can be used freely in demos and prototypes
When I put Django in my home directory, I was addicted to static files with permission errors
I made my own language. (1)
I made an Xubuntu server.
I made my own language (2)
I made my own AML
I want to create a pipfile and reflect it in docker
I made a Chatbot using LINE Messaging API and Python (2) ~ Server ~
I made a chatbot with Tensor2Tensor and this time it worked
I made a POST script to create an issue on Github and register it in the Project