Skip to main content

Quality Community Sharing

Original Source: Adapting Alpine Linux for LuckFox Pico – Benefits of Using Alpine Linux

Image Download: AlpineLinux.zip

Introduction: Why Adapt to Alpine Linux

"Why not Ubuntu or Debian, which are more popular among users?" This is a question many friends ask at first. Alpine Linux consumes fewer resources, employs a lighter package management system, and its 5MB minimal rootfs outshines other distributions. Therefore, Alpine Linux is the optimal choice.

For those unfamiliar with Alpine Linux, it's recommended to experience it by downloading and installing the firmware.

1. Download Firmware and Flash

After downloading the NAND firmware compressed package from the article link, follow these steps:

  1. Extract the downloaded package and open the SocToolKit software.
  2. While the device is unpowered, press and hold the BOOT button, then insert the USB.
  3. Once the software detects the maskrom device, click the search path button and select the extracted directory. Confirm and check all download items.
  4. Click the download button.

2. Connect Serial Port and Log In

After the download is complete, disconnect the USB, power off, and connect the serial port to configure the system.

Follow the instructions on the LuckFox official wiki for serial port connection. Open the serial port tool, connect the development board to the network and power, and view the startup information on the development board. The image has enabled root account login without a password via the serial port.

Check if the root filesystem is writable to proceed with the configuration.

3. Network Configuration

Boards with limited resources may not have various network tools pre-installed. ifconfig and ip commands are commonly used for networking.

Alpine Linux provides network services, and you can configure static IP or DHCP dynamic IP by editing the /etc/network/interfaces file. Below is a template for configuring the board's IP as 192.168.50.59 and the gateway as 192.168.50.1.

auto eth0
iface eth0 inet static
address 192.168.50.59
netmask 255.255.255.0
gateway 192.168.50.1

It is recommended to use a static IP for easy SSH remote login. After configuration, start the networking service. The image already has this service enabled by default. If you can ping local and external IPs but cannot resolve domain names, update the /etc/resolv.conf file with the local DNS server's IP.

This article assumes a wired network connection for optimal use of the package manager and network advantages. USB RNDIS is not configured, so it's advisable to use a wired connection.

4. SSH Remote Login

The image has SSH remote service installed and configured, allowing root remote login. If connected via serial port, use the following commands:

passwd

Change the root password and then use an SSH client to log in. Example configuration for Termius is provided below.

Once configured, you can SSH remotely.

5. Package Manager APK Usage

Like many users, the primary reason for adapting a distribution is to avoid compilation and install software packages directly. Alpine Linux's package manager commands are straightforward, with three main commands to remember:

  • apk update: Update the local index.
  • apk add: Install a software package.
  • apk del: Remove a software package.

For instance, installing GCC only requires running the command apk add gcc.

After installation, you can check the version with gcc -v.

NAND flash space is limited, so it's not recommended to install large software packages. After installing GCC, there is limited remaining space. Use apk del gcc to remove GCC and its dependencies.

After removing GCC, the available space increases.

The provided image has been modified to use the Aliyun repository. If the installation speed is slow, consider changing to other mirrors by modifying the /etc/apk/repositories file. In most cases, APK handles software package installation and removal automatically, dealing with dependencies.

6. Service Management

Due to limited resources on the board, OpenRC is used to manage services. All available services are in the /etc/init.d/ directory. Common commands include:

  • rc-status: View running services in the default runlevel.
  • rc-update add: Add a service to the runlevel service list.
  • rc-update del: Remove a service from the corresponding runlevel service list.
  • rc-service: Manage service start and stop.

When adding or removing services, you need to specify the runlevel, such as default or boot. Typically, the default runlevel is sufficient, and special services require individual configuration. For example, to view the services in the default runlevel, run the command rc-status.

Try disabling the SSH service and then enabling it again. Run rc-update del sshd to disable the SSH service, and rc-update add sshd default to enable it during startup.

If you don't want to restart the board, use rc-service to manage the current system's services. For more details, refer to the OpenRC documentation.