Sunday 12 February 2017

Git: on a (Compute) Stick

Intel - Compute Stick (17419054735)

How to make a home Git server out of an Intel Compute Stick STCK1A8LFC.

It is assumed readers have enough knowledge of Linux and IP networking to know when to alter instructions to suit their own network and needs. Some of these instructions are destructive!

Requirements

  • Single-user Git server
  • Infrequent push/pull
  • Physically unobtrusive
  • Networked from any room - i.e. WiFi
  • Headless

You can probably achieve the same results with a Pi but I bought a Compute Stick instead.

Sections

  1. STCK1A8LFC Compute Stick Specification
  2. Peripherals
  3. Recovering the OS
  4. Headless Operation and the STCK1A8LFC BIOS
  5. Booting to Command Prompt
  6. Ubuntu Headless WiFi
  7. Remote Login
  8. Mount the MicroSD Card
  9. Git Server

STCK1A8LFC Compute Stick Specification

A STCK1A8LFC is terrible as a desktop PC.

  • Model: STCK1A8LFC
  • CPU: Intel Atom Z3735F; 1.33GHz 4-core; 2MB L2 cache; integrated graphics, memory controller, platform controller hub
  • RAM: 1GB single-channel DDR3L/L-RS 1.35V 1333MHz
  • Storage: 8GB Embedded MultiMediaCard (eMMC)
  • Wireless: 802.11bgn; Bluetooth 4.0
  • Ports: HDMI v1.4a (male); USB 2.0 Connector; MicroSD (8 to 128GB); 5V DC Connector (micro-USB)
  • OS: Ubuntu 14.04 LTS (Trusty Tahr)

Intel has since released Compute Sticks with better specifications. To date, the STCK1A8LFC is the only one that comes with Linux pre-installed.

Factory partition scheme:

  • /dev/mmcblk0p1 EFI System Partition (50MB FAT)
  • /dev/mmcblk0p2 PQSERVICE Recovery Partition (1.3GB FAT)
  • /dev/mmcblk0p3 Filesystem (5.3GB Ext4)
  • /dev/mmcblk0p4 Swap (980MB Ext4)

Peripherals

I used the following peripherals to set up the device:

  • 7-port powered USB 3.0 Hub
  • USB keyboard
  • USB mouse
  • HDMI monitor

I also added a 32GB MicroSDHC card for storage as Ubuntu swallows most of the stock file system.

See also Tested Peripherals for Intel Compute Stick STCK1A32WFC and STCK1A8LFC.

Sigh!

Instead of booting to Ubuntu the Stick gave me a GRUB prompt and trying to cat the GRUB config locked up the device. Holding down F10 during POST allows selection of the boot device and access to the recovery partition. After recovery I ran badblocks -sv /dev/mmcblk0 and it reported zero errors.

Intel doesn't provide a download image of the OS in case you ever need to reinstall from scratch. I took an image of the entire eMMC using:

Headless Operation and the STCK1A8LFC BIOS

Prior to version 31 of the FCBYT10H.86A BIOS there are issues with headless boot. You can check your BIOS version by holding down F2 during POST.

BIOS upgrade process:

  1. Place the .BIO file on a FAT32 USB or MicroSD device and connect it
  2. Hold down F7 during POST
  3. Select the storage device
  4. Select the file and press enter at the prompt
  5. Wait for the process to complete

Booting to Command Prompt

You can get a root shell in Ubuntu using sudo -i.

Backup the original GRUB config:

cp -n /etc/default/grub /etc/default/grub.orig

Edit /etc/default/grub to enable booting to a command prompt:


GRUB_DEFAULT=0
GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX="text locale=en_GB.UTF-8

Change the locale code to your own.

Update Grub from the configuration:

update-grub

Reboot to the console.

Ubuntu Headless WiFi

  • NetworkManager - network management daemon
  • nmcli - command line tool for controlling NetworkManager

This section is dependent on local network configurations. NetworkManager is installed by default.

This command lists the available WiFi access points:

nmcli dev wifi list

The following key file /etc/NetworkManager/system-connections/SOMESSID defines a connection to the SOMESSID network with the passphrase SOME_PASS_PHRASE. The static IP 10.10.10.10 is allocated and the gateway is 10.10.10.1.

[connection]
id=SOMESSID
uuid=FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF
type=802-11-wireless

[802-11-wireless-security]
key-mgmt=wpa-psk
auth-alg=open
psk=SOME_PASS_PHRASE

[802-11-wireless]
ssid=SOMESSID
mode=infrastructure
mac-address=FF:FF:FF:FF:FF:FF
security=802-11-wireless-security

[ipv4]
method=manual
dns=8.8.8.8,8.8.4.4
addresses=10.10.10.10/24,10.10.10.1

[ipv6]
method=auto

The MAC address is specific to the device; the UUID is random.

The WiFi connection can be made by providing the SSID and will survive reboots:

nmcli c up id SOMESSID

Remote Login

Install the OpenSSH daemon:

sudo apt-get install openssh-server openssh-client
sudo service ssh status

Mount the MicroSD Card

The MicroSD slot holds the storage for the Git repositories. Format the card as Ext4:

mkfs.ext4 /dev/mmcblk1p1

Backup fstab:

cp /etc/fstab /etc/fstab.orig

Use the blkid command to find the UUID of /dev/mmcblk1p1 and add a line similar to this to /etc/fstab:

UUID=FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF /git            ext4    errors=remount-ro 0       0

Create the mount point and mount the drive:

mkdir /git
mount /git

Git Server

Install Git:

apt-get install git

Create a user for owning the files:

adduser linus
chown linus /git
chgrp linus /git

Use sudo -i -u linus to switch to the new user and create a repository:

cd /git
mkdir foo
cd foo
git init
cd ..
git clone --bare foo foo.git

Clone the empty repository from a development PC using a command of the form git clone linus@10.10.10.10:/git/foo.git.

No comments:

Post a Comment

All comments are moderated